OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2012 The Swarming Authors. All rights reserved. | 2 # Copyright 2012 The Swarming Authors. All rights reserved. |
3 # Use of this source code is governed under the Apache License, Version 2.0 that | 3 # Use of this source code is governed under the Apache License, Version 2.0 that |
4 # can be found in the LICENSE file. | 4 # can be found in the LICENSE file. |
5 | 5 |
6 """Runs the whole set of swarming client unit tests on swarming itself. | 6 """Runs the whole set of swarming client unit tests on swarming itself. |
7 | 7 |
8 This is done in a few steps: | 8 This is done in a few steps: |
9 - Archive the whole directory as a single .isolated file. | 9 - Archive the whole directory as a single .isolated file. |
10 - Create one test-specific .isolated for each test to run. The file is created | 10 - Create one test-specific .isolated for each test to run. The file is created |
11 directly and archived manually with isolateserver.py. | 11 directly and archived manually with isolateserver.py. |
12 - Trigger each of these test-specific .isolated file per OS. | 12 - Trigger each of these test-specific .isolated file per OS. |
13 - Get all results out of order. | 13 - Get all results out of order. |
14 """ | 14 """ |
15 | 15 |
16 __version__ = '0.1' | 16 __version__ = '0.1' |
17 | 17 |
18 import glob | 18 import glob |
19 import logging | 19 import logging |
20 import os | 20 import os |
21 import shutil | |
22 import subprocess | 21 import subprocess |
23 import sys | 22 import sys |
24 import tempfile | 23 import tempfile |
25 import time | 24 import time |
26 | 25 |
27 ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | 26 ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) |
28 | 27 |
29 # Must be first import. | 28 # Must be first import. |
30 import parallel_execution | 29 import parallel_execution |
31 | 30 |
32 from third_party import colorama | 31 from third_party import colorama |
33 from third_party.depot_tools import fix_encoding | 32 from third_party.depot_tools import fix_encoding |
| 33 from utils import file_path |
34 from utils import tools | 34 from utils import tools |
35 | 35 |
36 | 36 |
37 def check_output(cmd): | 37 def check_output(cmd): |
38 return subprocess.check_output([sys.executable] + cmd, cwd=ROOT_DIR) | 38 return subprocess.check_output([sys.executable] + cmd, cwd=ROOT_DIR) |
39 | 39 |
40 | 40 |
41 def archive_tree(isolate_server): | 41 def archive_tree(isolate_server): |
42 """Archives a whole tree and return the sha1 of the .isolated file. | 42 """Archives a whole tree and return the sha1 of the .isolated file. |
43 | 43 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 ] + isolateds | 86 ] + isolateds |
87 if logging.getLogger().isEnabledFor(logging.INFO): | 87 if logging.getLogger().isEnabledFor(logging.INFO): |
88 cmd.append('--verbose') | 88 cmd.append('--verbose') |
89 items = [i.split() for i in check_output(cmd).splitlines()] | 89 items = [i.split() for i in check_output(cmd).splitlines()] |
90 assert len(items) == len(tests) | 90 assert len(items) == len(tests) |
91 assert all( | 91 assert all( |
92 items[i][1].endswith(os.path.basename(tests[i]) + '.isolated') | 92 items[i][1].endswith(os.path.basename(tests[i]) + '.isolated') |
93 for i in xrange(len(tests))) | 93 for i in xrange(len(tests))) |
94 return zip(tests, [i[0] for i in items]) | 94 return zip(tests, [i[0] for i in items]) |
95 finally: | 95 finally: |
96 shutil.rmtree(tempdir) | 96 file_path.rmtree(tempdir) |
97 | 97 |
98 | 98 |
99 | 99 |
100 def run_swarming_tests_on_swarming( | 100 def run_swarming_tests_on_swarming( |
101 swarming_server, isolate_server, priority, oses, tests, logs, | 101 swarming_server, isolate_server, priority, oses, tests, logs, |
102 no_idempotent): | 102 no_idempotent): |
103 """Archives, triggers swarming jobs and gets results.""" | 103 """Archives, triggers swarming jobs and gets results.""" |
104 print('Archiving the whole tree.') | 104 print('Archiving the whole tree.') |
105 start = time.time() | 105 start = time.time() |
106 tree_isolated = archive_tree(isolate_server) | 106 tree_isolated = archive_tree(isolate_server) |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 tests, | 207 tests, |
208 options.logs, | 208 options.logs, |
209 options.no_idempotent) | 209 options.no_idempotent) |
210 | 210 |
211 | 211 |
212 if __name__ == '__main__': | 212 if __name__ == '__main__': |
213 fix_encoding.fix_encoding() | 213 fix_encoding.fix_encoding() |
214 tools.disable_buffering() | 214 tools.disable_buffering() |
215 colorama.init() | 215 colorama.init() |
216 sys.exit(main()) | 216 sys.exit(main()) |
OLD | NEW |