diff --git a/gm/rebaseline_server/__init__.py b/gm/rebaseline_server/__init__.py new file mode 100644 index 0000000000..02d71e90af --- /dev/null +++ b/gm/rebaseline_server/__init__.py @@ -0,0 +1 @@ +# Needed so that test_all.py will recurse into this directory. diff --git a/gm/rebaseline_server/base_unittest.py b/gm/rebaseline_server/base_unittest.py index 0699db65d0..32b4bb9d74 100755 --- a/gm/rebaseline_server/base_unittest.py +++ b/gm/rebaseline_server/base_unittest.py @@ -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) diff --git a/gm/rebaseline_server/test_all.py b/gm/rebaseline_server/test_all.py index 299d1340f2..282ec85732 100755 --- a/gm/rebaseline_server/test_all.py +++ b/gm/rebaseline_server/test_all.py @@ -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 diff --git a/gm/test_all.py b/gm/test_all.py new file mode 100755 index 0000000000..282ec85732 --- /dev/null +++ b/gm/test_all.py @@ -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() diff --git a/gm/tests/run.sh b/gm/tests/run.sh index 333f3effc0..52ed6f309f 100755 --- a/gm/tests/run.sh +++ b/gm/tests/run.sh @@ -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