| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 | 2 |
| 3 # Copyright (c) 2012 Google Inc. All rights reserved. | 3 # Copyright (c) 2012 Google Inc. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 """ | 7 """ |
| 8 Runs small tests. | 8 Runs small tests. |
| 9 """ | 9 """ |
| 10 | 10 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 # Add pylib to the import path (so tests can import their dependencies). | 21 # Add pylib to the import path (so tests can import their dependencies). |
| 22 # This is consistant with the path.append done in the top file "gyp". | 22 # This is consistant with the path.append done in the top file "gyp". |
| 23 sys.path.append(os.path.join(test._cwd, 'pylib')) | 23 sys.path.append(os.path.join(test._cwd, 'pylib')) |
| 24 | 24 |
| 25 # Add new test suites here. | 25 # Add new test suites here. |
| 26 files_to_test = [ | 26 files_to_test = [ |
| 27 'pylib/gyp/MSVSSettings_test.py', | 27 'pylib/gyp/MSVSSettings_test.py', |
| 28 'pylib/gyp/easy_xml_test.py', | 28 'pylib/gyp/easy_xml_test.py', |
| 29 'pylib/gyp/generator/msvs_test.py', | 29 'pylib/gyp/generator/msvs_test.py', |
| 30 'pylib/gyp/generator/ninja_test.py', | 30 'pylib/gyp/generator/ninja_test.py', |
| 31 'pylib/gyp/common_test.py', |
| 31 ] | 32 ] |
| 32 | 33 |
| 33 # Collect all the suites from the above files. | 34 # Collect all the suites from the above files. |
| 34 suites = [] | 35 suites = [] |
| 35 for filename in files_to_test: | 36 for filename in files_to_test: |
| 36 # Carve the module name out of the path. | 37 # Carve the module name out of the path. |
| 37 name = os.path.splitext(os.path.split(filename)[1])[0] | 38 name = os.path.splitext(os.path.split(filename)[1])[0] |
| 38 # Find the complete module path. | 39 # Find the complete module path. |
| 39 full_filename = os.path.join(test._cwd, filename) | 40 full_filename = os.path.join(test._cwd, filename) |
| 40 # Load the module. | 41 # Load the module. |
| 41 module = imp.load_source(name, full_filename) | 42 module = imp.load_source(name, full_filename) |
| 42 # Add it to the list of test suites. | 43 # Add it to the list of test suites. |
| 43 suites.append(unittest.defaultTestLoader.loadTestsFromModule(module)) | 44 suites.append(unittest.defaultTestLoader.loadTestsFromModule(module)) |
| 44 # Create combined suite. | 45 # Create combined suite. |
| 45 all_tests = unittest.TestSuite(suites) | 46 all_tests = unittest.TestSuite(suites) |
| 46 | 47 |
| 47 # Run all the tests. | 48 # Run all the tests. |
| 48 result = unittest.TextTestRunner(verbosity=2).run(all_tests) | 49 result = unittest.TextTestRunner(verbosity=2).run(all_tests) |
| 49 if result.failures or result.errors: | 50 if result.failures or result.errors: |
| 50 test.fail_test() | 51 test.fail_test() |
| 51 | 52 |
| 52 test.pass_test() | 53 test.pass_test() |
| OLD | NEW |