make gm self-tests launch python unittests automatically

(not just within the rebaseline_server subdirectory)

Generally useful, but needed asap for my work on http://skbug.com/2752 ('split existing "gpu" GM results into "gl" and "gles"')

BUG=skia:677
NOTREECHECKS=True
NOTRY=True
R=rmistry@google.com
TBR=rmistry

Author: epoger@google.com

Review URL: https://codereview.chromium.org/398043002
This commit is contained in:
epoger 2014-07-16 08:28:23 -07:00 коммит произвёл Commit bot
Родитель 7940100fae
Коммит 33ac9506fb
5 изменённых файлов: 36 добавлений и 8 удалений

Просмотреть файл

@ -0,0 +1 @@
# Needed so that test_all.py will recurse into this directory.

Просмотреть файл

@ -26,9 +26,14 @@ OUTPUT_DIR_EXPECTED = os.path.join(TESTDATA_DIR, 'outputs', 'expected')
class TestCase(unittest.TestCase):
def setUp(self):
# Get the name of this test, in such a way that it will be consistent
# regardless of the directory it is run from (throw away package names,
# if any).
test_name = '.'.join(self.id().split('.')[-3:])
self._input_dir = os.path.join(TESTDATA_DIR, 'inputs')
self._output_dir_actual = os.path.join(OUTPUT_DIR_ACTUAL, self.id())
self._output_dir_expected = os.path.join(OUTPUT_DIR_EXPECTED, self.id())
self._output_dir_actual = os.path.join(OUTPUT_DIR_ACTUAL, test_name)
self._output_dir_expected = os.path.join(OUTPUT_DIR_EXPECTED, test_name)
create_empty_dir(self._output_dir_actual)
self._temp_dir = tempfile.mkdtemp()
@ -125,4 +130,4 @@ def find_different_files(dir1, dir2, ignore_subtree_names=None):
def main(test_case_class):
"""Run the unit tests within the given class."""
suite = unittest.TestLoader().loadTestsFromTestCase(test_case_class)
results = unittest.TextTestRunner(verbosity=2).run(suite)
unittest.TextTestRunner(verbosity=2).run(suite)

Просмотреть файл

@ -7,9 +7,6 @@ Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
Run all unittests within this directory tree, recursing into subdirectories.
TODO(epoger): Launch this automatically on the housekeeper bot, but first make
sure it works properly after having been checked out (from both git and svn)
"""
import os

25
gm/test_all.py Executable file
Просмотреть файл

@ -0,0 +1,25 @@
#!/usr/bin/python
"""
Copyright 2014 Google Inc.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
Run all unittests within this directory tree, recursing into subdirectories.
"""
import os
import unittest
def main():
suite = unittest.TestLoader().discover(os.path.dirname(__file__),
pattern='*_test.py')
results = unittest.TextTestRunner(verbosity=2).run(suite)
print repr(results)
if not results.wasSuccessful():
raise Exception('failed one or more unittests')
if __name__ == '__main__':
main()

Просмотреть файл

@ -264,8 +264,8 @@ for CASE in $FAILING_CASES; do
assert_fails "python gm/display_json_results.py $GM_OUTPUTS/$CASE/$OUTPUT_EXPECTED_SUBDIR/json-summary.txt"
done
# Exercise all rebaseline_server unittests.
assert_passes "python gm/rebaseline_server/test_all.py"
# Exercise all Python unittests.
assert_passes "python gm/test_all.py"
echo
if [ $ENCOUNTERED_ANY_ERRORS == 0 ]; then