Chromium Code Reviews| 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 21 matching lines...) Expand all Loading... | |
| 32 import isolateserver | 32 import isolateserver |
| 33 | 33 |
| 34 | 34 |
| 35 # Absolute path to this file (can be None if running from zip on Mac). | 35 # Absolute path to this file (can be None if running from zip on Mac). |
| 36 THIS_FILE_PATH = os.path.abspath(__file__) if __file__ else None | 36 THIS_FILE_PATH = os.path.abspath(__file__) if __file__ else None |
| 37 | 37 |
| 38 # Directory that contains this file (might be inside zip package). | 38 # Directory that contains this file (might be inside zip package). |
| 39 BASE_DIR = os.path.dirname(THIS_FILE_PATH) if __file__ else None | 39 BASE_DIR = os.path.dirname(THIS_FILE_PATH) if __file__ else None |
| 40 | 40 |
| 41 # Directory that contains currently running script file. | 41 # Directory that contains currently running script file. |
| 42 MAIN_DIR = os.path.dirname(os.path.abspath(zip_package.get_main_script_path())) | 42 MAIN_DIR = ( |
|
Vadim Sh.
2013/10/01 18:59:51
nit: I'd change it into regular 'if' and added com
M-A Ruel
2013/10/01 19:06:35
Done.
| |
| 43 os.path.dirname(os.path.abspath(zip_package.get_main_script_path())) | |
| 44 if zip_package.get_main_script_path() else None) | |
| 43 | 45 |
| 44 # Types of action accepted by link_file(). | 46 # Types of action accepted by link_file(). |
| 45 HARDLINK, HARDLINK_WITH_FALLBACK, SYMLINK, COPY = range(1, 5) | 47 HARDLINK, HARDLINK_WITH_FALLBACK, SYMLINK, COPY = range(1, 5) |
| 46 | 48 |
| 47 # The name of the log file to use. | 49 # The name of the log file to use. |
| 48 RUN_ISOLATED_LOG_FILE = 'run_isolated.log' | 50 RUN_ISOLATED_LOG_FILE = 'run_isolated.log' |
| 49 | 51 |
| 50 # The name of the log to use for the run_test_cases.py command | 52 # The name of the log to use for the run_test_cases.py command |
| 51 RUN_TEST_CASES_LOG = 'run_test_cases.log' | 53 RUN_TEST_CASES_LOG = 'run_test_cases.log' |
| 52 | 54 |
| (...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 507 if settings.read_only: | 509 if settings.read_only: |
| 508 logging.info('Making files read only') | 510 logging.info('Making files read only') |
| 509 make_writable(outdir, True) | 511 make_writable(outdir, True) |
| 510 cwd = os.path.normpath(os.path.join(outdir, settings.relative_cwd)) | 512 cwd = os.path.normpath(os.path.join(outdir, settings.relative_cwd)) |
| 511 logging.info('Running %s, cwd=%s' % (settings.command, cwd)) | 513 logging.info('Running %s, cwd=%s' % (settings.command, cwd)) |
| 512 | 514 |
| 513 # TODO(csharp): This should be specified somewhere else. | 515 # TODO(csharp): This should be specified somewhere else. |
| 514 # TODO(vadimsh): Pass it via 'env_vars' in manifest. | 516 # TODO(vadimsh): Pass it via 'env_vars' in manifest. |
| 515 # Add a rotating log file if one doesn't already exist. | 517 # Add a rotating log file if one doesn't already exist. |
| 516 env = os.environ.copy() | 518 env = os.environ.copy() |
| 517 env.setdefault('RUN_TEST_CASES_LOG_FILE', | 519 if MAIN_DIR: |
| 518 os.path.join(MAIN_DIR, RUN_TEST_CASES_LOG)) | 520 env.setdefault('RUN_TEST_CASES_LOG_FILE', |
| 521 os.path.join(MAIN_DIR, RUN_TEST_CASES_LOG)) | |
| 519 try: | 522 try: |
| 520 with tools.Profiler('RunTest'): | 523 with tools.Profiler('RunTest'): |
| 521 return subprocess.call(settings.command, cwd=cwd, env=env) | 524 return subprocess.call(settings.command, cwd=cwd, env=env) |
| 522 except OSError: | 525 except OSError: |
| 523 print >> sys.stderr, 'Failed to run %s; cwd=%s' % (settings.command, cwd) | 526 print >> sys.stderr, 'Failed to run %s; cwd=%s' % (settings.command, cwd) |
| 524 return 1 | 527 return 1 |
| 525 finally: | 528 finally: |
| 526 if outdir: | 529 if outdir: |
| 527 rmtree(outdir) | 530 rmtree(outdir) |
| 528 | 531 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 606 except Exception, e: | 609 except Exception, e: |
| 607 # Make sure any exception is logged. | 610 # Make sure any exception is logged. |
| 608 logging.exception(e) | 611 logging.exception(e) |
| 609 return 1 | 612 return 1 |
| 610 | 613 |
| 611 | 614 |
| 612 if __name__ == '__main__': | 615 if __name__ == '__main__': |
| 613 # Ensure that we are always running with the correct encoding. | 616 # Ensure that we are always running with the correct encoding. |
| 614 fix_encoding.fix_encoding() | 617 fix_encoding.fix_encoding() |
| 615 sys.exit(main()) | 618 sys.exit(main()) |
| OLD | NEW |