OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Top level script for running all python unittests in the NaCl SDK | 6 """Top level script for running all python unittests in the NaCl SDK. |
7 """ | 7 """ |
8 | 8 |
9 from __future__ import print_function | 9 from __future__ import print_function |
10 | 10 |
11 import argparse | 11 import argparse |
12 import os | 12 import os |
13 import subprocess | 13 import subprocess |
14 import sys | 14 import sys |
15 import unittest | 15 import unittest |
16 | 16 |
(...skipping 26 matching lines...) Expand all Loading... |
43 'easy_template_test', | 43 'easy_template_test', |
44 'elf_test', | 44 'elf_test', |
45 'fix_deps_test', | 45 'fix_deps_test', |
46 'getos_test', | 46 'getos_test', |
47 'get_shared_deps_test', | 47 'get_shared_deps_test', |
48 'httpd_test', | 48 'httpd_test', |
49 'nacl_config_test', | 49 'nacl_config_test', |
50 'oshelpers_test', | 50 'oshelpers_test', |
51 'parse_dsc_test', | 51 'parse_dsc_test', |
52 'quote_test', | 52 'quote_test', |
53 'sdktools_commands_test', | |
54 'sdktools_config_test', | 53 'sdktools_config_test', |
55 'sdktools_test', | |
56 'sel_ldr_test', | 54 'sel_ldr_test', |
| 55 'test_projects_test', |
57 'update_nacl_manifest_test', | 56 'update_nacl_manifest_test', |
58 'verify_filelist_test', | 57 'verify_filelist_test', |
59 'verify_ppapi_test', | 58 'verify_ppapi_test', |
60 ] | 59 ] |
61 | 60 |
| 61 # These tests for 'sdktools' are more like system tests and take a lot |
| 62 # longer to run. If --quick is passed then we don't run these. |
| 63 TEST_MODULES_BIG = [ |
| 64 'sdktools_commands_test', |
| 65 'sdktools_test', |
| 66 ] |
| 67 |
| 68 |
62 def ExtractToolchains(): | 69 def ExtractToolchains(): |
63 subprocess.check_output([sys.executable, PKG_VER, | 70 cmd = [sys.executable, PKG_VER, |
64 '--packages', ','.join(EXTRACT_PACKAGES), | 71 '--packages', ','.join(EXTRACT_PACKAGES), |
65 '--tar-dir', TAR_DIR, | 72 '--tar-dir', TAR_DIR, |
66 '--dest-dir', TOOLCHAIN_OUT, | 73 '--dest-dir', TOOLCHAIN_OUT, |
67 'extract']) | 74 'extract'] |
| 75 subprocess.check_call(cmd) |
| 76 |
68 | 77 |
69 def main(args): | 78 def main(args): |
70 parser = argparse.ArgumentParser(description=__doc__) | 79 parser = argparse.ArgumentParser(description=__doc__) |
71 parser.add_argument('-v', '--verbose', action='store_true') | 80 parser.add_argument('-v', '--verbose', action='store_true') |
| 81 parser.add_argument('--quick', action='store_true') |
72 options = parser.parse_args(args) | 82 options = parser.parse_args(args) |
73 | 83 |
74 # Some of the unit tests use parts of toolchains. Extract to TOOLCHAIN_OUT. | 84 # Some of the unit tests use parts of toolchains. Extract to TOOLCHAIN_OUT. |
75 print('Extracting toolchains...') | 85 print('Extracting toolchains...') |
76 ExtractToolchains() | 86 ExtractToolchains() |
77 | 87 |
78 suite = unittest.TestSuite() | 88 suite = unittest.TestSuite() |
79 for module_name in TEST_MODULES: | 89 modules = TEST_MODULES |
| 90 if not options.quick: |
| 91 modules += TEST_MODULES_BIG |
| 92 |
| 93 for module_name in modules: |
80 module = __import__(module_name) | 94 module = __import__(module_name) |
81 suite.addTests(unittest.defaultTestLoader.loadTestsFromModule(module)) | 95 suite.addTests(unittest.defaultTestLoader.loadTestsFromModule(module)) |
82 | 96 |
83 if options.verbose: | 97 if options.verbose: |
84 verbosity = 2 | 98 verbosity = 2 |
85 else: | 99 else: |
86 verbosity = 1 | 100 verbosity = 1 |
87 | 101 |
88 print('Running unittests...') | 102 print('Running unittests...') |
89 result = unittest.TextTestRunner(verbosity=verbosity).run(suite) | 103 result = unittest.TextTestRunner(verbosity=verbosity).run(suite) |
90 return int(not result.wasSuccessful()) | 104 return int(not result.wasSuccessful()) |
91 | 105 |
| 106 |
92 if __name__ == '__main__': | 107 if __name__ == '__main__': |
93 sys.exit(main(sys.argv[1:])) | 108 sys.exit(main(sys.argv[1:])) |
OLD | NEW |