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 """Reads a .isolated, creates a tree of hardlinks and runs the test. | 6 """Reads a .isolated, creates a tree of hardlinks and runs the test. |
7 | 7 |
8 Keeps a local cache. | 8 Keeps a local cache. |
9 """ | 9 """ |
10 | 10 |
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 try: | 490 try: |
491 settings = isolateserver.fetch_isolated( | 491 settings = isolateserver.fetch_isolated( |
492 isolated_hash=isolated_hash, | 492 isolated_hash=isolated_hash, |
493 storage=storage, | 493 storage=storage, |
494 cache=cache, | 494 cache=cache, |
495 algo=algo, | 495 algo=algo, |
496 outdir=outdir, | 496 outdir=outdir, |
497 os_flavor=get_flavor(), | 497 os_flavor=get_flavor(), |
498 require_command=True) | 498 require_command=True) |
499 except isolateserver.ConfigError as e: | 499 except isolateserver.ConfigError as e: |
500 print >> sys.stderr, str(e) | 500 tools.report_error(e) |
501 return 1 | 501 return 1 |
502 | 502 |
503 if settings.read_only: | 503 if settings.read_only: |
504 logging.info('Making files read only') | 504 logging.info('Making files read only') |
505 make_writable(outdir, True) | 505 make_writable(outdir, True) |
506 cwd = os.path.normpath(os.path.join(outdir, settings.relative_cwd)) | 506 cwd = os.path.normpath(os.path.join(outdir, settings.relative_cwd)) |
507 logging.info('Running %s, cwd=%s' % (settings.command, cwd)) | 507 logging.info('Running %s, cwd=%s' % (settings.command, cwd)) |
508 | 508 |
509 # TODO(csharp): This should be specified somewhere else. | 509 # TODO(csharp): This should be specified somewhere else. |
510 # TODO(vadimsh): Pass it via 'env_vars' in manifest. | 510 # TODO(vadimsh): Pass it via 'env_vars' in manifest. |
511 # Add a rotating log file if one doesn't already exist. | 511 # Add a rotating log file if one doesn't already exist. |
512 env = os.environ.copy() | 512 env = os.environ.copy() |
513 if MAIN_DIR: | 513 if MAIN_DIR: |
514 env.setdefault('RUN_TEST_CASES_LOG_FILE', | 514 env.setdefault('RUN_TEST_CASES_LOG_FILE', |
515 os.path.join(MAIN_DIR, RUN_TEST_CASES_LOG)) | 515 os.path.join(MAIN_DIR, RUN_TEST_CASES_LOG)) |
516 try: | 516 try: |
517 with tools.Profiler('RunTest'): | 517 with tools.Profiler('RunTest'): |
518 return subprocess.call(settings.command, cwd=cwd, env=env) | 518 return subprocess.call(settings.command, cwd=cwd, env=env) |
519 except OSError: | 519 except OSError: |
520 print >> sys.stderr, 'Failed to run %s; cwd=%s' % (settings.command, cwd) | 520 tools.report_error('Failed to run %s; cwd=%s' % (settings.command, cwd)) |
521 return 1 | 521 return 1 |
522 finally: | 522 finally: |
523 if outdir: | 523 if outdir: |
524 rmtree(outdir) | 524 rmtree(outdir) |
525 | 525 |
526 | 526 |
527 def main(): | 527 def main(): |
528 tools.disable_buffering() | 528 tools.disable_buffering() |
529 parser = tools.OptionParserWithLogging( | 529 parser = tools.OptionParserWithLogging( |
530 usage='%prog <options>', | 530 usage='%prog <options>', |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 algo = isolateserver.get_hash_algo(options.namespace) | 595 algo = isolateserver.get_hash_algo(options.namespace) |
596 | 596 |
597 try: | 597 try: |
598 # |options.cache| may not exist until DiskCache() instance is created. | 598 # |options.cache| may not exist until DiskCache() instance is created. |
599 cache = DiskCache(options.cache, policies, algo) | 599 cache = DiskCache(options.cache, policies, algo) |
600 outdir = make_temp_dir('run_tha_test', options.cache) | 600 outdir = make_temp_dir('run_tha_test', options.cache) |
601 return run_tha_test( | 601 return run_tha_test( |
602 options.isolated or options.hash, storage, cache, algo, outdir) | 602 options.isolated or options.hash, storage, cache, algo, outdir) |
603 except Exception as e: | 603 except Exception as e: |
604 # Make sure any exception is logged. | 604 # Make sure any exception is logged. |
| 605 tools.report_error(e) |
605 logging.exception(e) | 606 logging.exception(e) |
606 return 1 | 607 return 1 |
607 | 608 |
608 | 609 |
609 if __name__ == '__main__': | 610 if __name__ == '__main__': |
610 # Ensure that we are always running with the correct encoding. | 611 # Ensure that we are always running with the correct encoding. |
611 fix_encoding.fix_encoding() | 612 fix_encoding.fix_encoding() |
612 sys.exit(main()) | 613 sys.exit(main()) |
OLD | NEW |