1
0

gyptest-small.py 1.4 KB

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