OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/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 """Do all the steps required to build and test against nacl.""" | 6 """Do all the steps required to build and test against nacl.""" |
7 | 7 |
8 | 8 |
9 import optparse | 9 import optparse |
10 import os.path | 10 import os.path |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 shutil.rmtree(path, ignore_errors=True) | 49 shutil.rmtree(path, ignore_errors=True) |
50 else: | 50 else: |
51 try: | 51 try: |
52 os.remove(path) | 52 os.remove(path) |
53 except Exception: | 53 except Exception: |
54 pass | 54 pass |
55 else: | 55 else: |
56 print 'Skipping %s' % path | 56 print 'Skipping %s' % path |
57 | 57 |
58 | 58 |
59 # TODO(ncbray): this is somewhat unsafe. We should fix the underlying problem. | |
60 def CleanTempDir(): | |
61 # Only delete files and directories like: | |
62 # a) C:\temp\83C4.tmp | |
63 # b) /tmp/.org.chromium.Chromium.EQrEzl | |
64 file_name_re = re.compile( | |
65 r'[\\/]([0-9a-fA-F]+\.tmp|\.org\.chrom\w+\.Chrom\w+\..+)$') | |
66 file_name_filter = lambda fn: file_name_re.search(fn) is not None | |
67 | |
68 path = os.environ.get('TMP', os.environ.get('TEMP', '/tmp')) | |
69 if len(path) >= 4 and os.path.isdir(path): | |
70 print | |
71 print "Cleaning out the temp directory." | |
72 print | |
73 TryToCleanContents(path, file_name_filter) | |
74 else: | |
75 print | |
76 print "Cannot find temp directory, not cleaning it." | |
77 print | |
78 | |
79 | |
80 def RunCommand(cmd, cwd, env): | 59 def RunCommand(cmd, cwd, env): |
81 sys.stdout.write('\nRunning %s\n\n' % ' '.join(cmd)) | 60 sys.stdout.write('\nRunning %s\n\n' % ' '.join(cmd)) |
82 sys.stdout.flush() | 61 sys.stdout.flush() |
83 retcode = subprocess.call(cmd, cwd=cwd, env=env) | 62 retcode = subprocess.call(cmd, cwd=cwd, env=env) |
84 if retcode != 0: | 63 if retcode != 0: |
85 sys.stdout.write('\nFailed: %s\n\n' % ' '.join(cmd)) | 64 sys.stdout.write('\nFailed: %s\n\n' % ' '.join(cmd)) |
86 sys.exit(retcode) | 65 sys.exit(retcode) |
87 | 66 |
88 | 67 |
89 def RunTests(name, cmd, env): | 68 def RunTests(name, cmd, env): |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 cmd.append('chrome_browser_tests') | 207 cmd.append('chrome_browser_tests') |
229 | 208 |
230 # Propagate path to JSON output if present. | 209 # Propagate path to JSON output if present. |
231 # Note that RunCommand calls sys.exit on errors, so potential errors | 210 # Note that RunCommand calls sys.exit on errors, so potential errors |
232 # from one command won't be overwritten by another one. Overwriting | 211 # from one command won't be overwritten by another one. Overwriting |
233 # a successful results file with either success or failure is fine. | 212 # a successful results file with either success or failure is fine. |
234 if options.json_build_results_output_file: | 213 if options.json_build_results_output_file: |
235 cmd.append('json_build_results_output_file=%s' % | 214 cmd.append('json_build_results_output_file=%s' % |
236 options.json_build_results_output_file) | 215 options.json_build_results_output_file) |
237 | 216 |
238 CleanTempDir() | |
239 | |
240 if options.enable_newlib: | 217 if options.enable_newlib: |
241 RunTests('nacl-newlib', cmd, env) | 218 RunTests('nacl-newlib', cmd, env) |
242 | 219 |
243 if options.enable_glibc: | 220 if options.enable_glibc: |
244 RunTests('nacl-glibc', cmd + ['--nacl_glibc'], env) | 221 RunTests('nacl-glibc', cmd + ['--nacl_glibc'], env) |
245 | 222 |
246 | 223 |
247 def MakeCommandLineParser(): | 224 def MakeCommandLineParser(): |
248 parser = optparse.OptionParser() | 225 parser = optparse.OptionParser() |
249 parser.add_option('-m', '--mode', dest='mode', default='Debug', | 226 parser.add_option('-m', '--mode', dest='mode', default='Debug', |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 else: | 287 else: |
311 options.enable_glibc = 0 | 288 options.enable_glibc = 0 |
312 | 289 |
313 if args: | 290 if args: |
314 parser.error('ERROR: invalid argument') | 291 parser.error('ERROR: invalid argument') |
315 BuildAndTest(options) | 292 BuildAndTest(options) |
316 | 293 |
317 | 294 |
318 if __name__ == '__main__': | 295 if __name__ == '__main__': |
319 Main() | 296 Main() |
OLD | NEW |