| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2015 The Chromium Authors. All rights reserved. | 2 # Copyright 2015 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 """Runs isolate bundled Telemetry unittests. | 6 """Runs isolate bundled Telemetry unittests. |
| 7 | 7 |
| 8 This script attempts to emulate the contract of gtest-style tests | 8 This script attempts to emulate the contract of gtest-style tests |
| 9 invoked via recipes. The main contract is that the caller passes the | 9 invoked via recipes. The main contract is that the caller passes the |
| 10 argument: | 10 argument: |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 # Add src/testing/ into sys.path for importing xvfb. | 30 # Add src/testing/ into sys.path for importing xvfb. |
| 31 sys.path.append(os.path.join(os.path.dirname(__file__), '..')) | 31 sys.path.append(os.path.join(os.path.dirname(__file__), '..')) |
| 32 import xvfb | 32 import xvfb |
| 33 | 33 |
| 34 | 34 |
| 35 def main(): | 35 def main(): |
| 36 parser = argparse.ArgumentParser() | 36 parser = argparse.ArgumentParser() |
| 37 parser.add_argument( | 37 parser.add_argument( |
| 38 '--isolated-script-test-output', type=argparse.FileType('w'), | 38 '--isolated-script-test-output', type=argparse.FileType('w'), |
| 39 required=True) | 39 required=True) |
| 40 parser.add_argument( | |
| 41 '--isolated-script-test-chartjson-output', type=argparse.FileType('w'), | |
| 42 required=False) | |
| 43 parser.add_argument('--xvfb', help='Start xvfb.', action='store_true') | 40 parser.add_argument('--xvfb', help='Start xvfb.', action='store_true') |
| 44 args, rest_args = parser.parse_known_args() | 41 args, rest_args = parser.parse_known_args() |
| 42 # Remove the chartjson extra arg until this script cares about chartjson |
| 43 # results from telemetry |
| 44 index = 0 |
| 45 for arg in rest_args: |
| 46 if '--isolated-script-test-chartjson-output' in arg: |
| 47 rest_args.pop(index) |
| 48 break |
| 49 index += 1 |
| 45 | 50 |
| 46 xvfb_proc = None | 51 xvfb_proc = None |
| 47 openbox_proc = None | 52 openbox_proc = None |
| 48 xcompmgr_proc = None | 53 xcompmgr_proc = None |
| 49 env = os.environ.copy() | 54 env = os.environ.copy() |
| 50 if args.xvfb and xvfb.should_start_xvfb(env): | 55 if args.xvfb and xvfb.should_start_xvfb(env): |
| 51 xvfb_proc, openbox_proc, xcompmgr_proc = xvfb.start_xvfb(env=env, | 56 xvfb_proc, openbox_proc, xcompmgr_proc = xvfb.start_xvfb(env=env, |
| 52 build_dir='.') | 57 build_dir='.') |
| 53 assert xvfb_proc and openbox_proc and xcompmgr_proc, 'Failed to start xvfb' | 58 assert xvfb_proc and openbox_proc and xcompmgr_proc, 'Failed to start xvfb' |
| 54 # Compatibility with gtest-based sharding. | 59 # Compatibility with gtest-based sharding. |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 | 104 |
| 100 if __name__ == '__main__': | 105 if __name__ == '__main__': |
| 101 # Conform minimally to the protocol defined by ScriptTest. | 106 # Conform minimally to the protocol defined by ScriptTest. |
| 102 if 'compile_targets' in sys.argv: | 107 if 'compile_targets' in sys.argv: |
| 103 funcs = { | 108 funcs = { |
| 104 'run': None, | 109 'run': None, |
| 105 'compile_targets': main_compile_targets, | 110 'compile_targets': main_compile_targets, |
| 106 } | 111 } |
| 107 sys.exit(common.run_script(sys.argv[1:], funcs)) | 112 sys.exit(common.run_script(sys.argv[1:], funcs)) |
| 108 sys.exit(main()) | 113 sys.exit(main()) |
| OLD | NEW |