OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env python |
| 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 |
| 4 # found in the LICENSE file. |
| 5 |
| 6 """Runs a script that can run as an isolate (or not). |
| 7 |
| 8 The main requirement is that |
| 9 |
| 10 --isolated-script-test-output=[FILENAME] |
| 11 |
| 12 is passed on the command line to run_isolated_script_tests. This gets |
| 13 remapped to the command line argument --write-full-results-to. |
| 14 |
| 15 json is written to that file in the format produced by |
| 16 common.parse_common_test_results. |
| 17 |
| 18 This script is intended to be the base command invoked by the isolate, |
| 19 followed by a subsequent Python script. It could be generalized to |
| 20 invoke an arbitrary executable. |
| 21 """ |
| 22 |
| 23 # TODO(tansell): Remove this script once LayoutTests can accept the isolated |
| 24 # arguments and start xvfb itself. |
| 25 |
| 26 import argparse |
| 27 import json |
| 28 import os |
| 29 import pprint |
| 30 import sys |
| 31 |
| 32 |
| 33 import common |
| 34 |
| 35 # Add src/testing/ into sys.path for importing xvfb. |
| 36 sys.path.append(os.path.join(os.path.dirname(__file__), '..')) |
| 37 import xvfb |
| 38 |
| 39 |
| 40 def main(): |
| 41 parser = argparse.ArgumentParser() |
| 42 parser.add_argument('--isolated-script-test-output', type=str, |
| 43 required=True) |
| 44 parser.add_argument('--xvfb', help='start xvfb', action='store_true') |
| 45 |
| 46 # This argument is ignored for now. |
| 47 parser.add_argument('--isolated-script-test-chartjson-output', type=str) |
| 48 |
| 49 args, rest_args = parser.parse_known_args() |
| 50 |
| 51 env = os.environ |
| 52 cmd = [sys.executable] + rest_args |
| 53 cmd += ['--write-full-results-to', args.isolated_script_test_output] |
| 54 if args.xvfb: |
| 55 return xvfb.run_executable(cmd, env) |
| 56 else: |
| 57 return common.run_command(cmd, env=env) |
| 58 |
| 59 |
| 60 # This is not really a "script test" so does not need to manually add |
| 61 # any additional compile targets. |
| 62 def main_compile_targets(args): |
| 63 json.dump([], args.output) |
| 64 |
| 65 |
| 66 if __name__ == '__main__': |
| 67 # Conform minimally to the protocol defined by ScriptTest. |
| 68 if 'compile_targets' in sys.argv: |
| 69 funcs = { |
| 70 'run': None, |
| 71 'compile_targets': main_compile_targets, |
| 72 } |
| 73 sys.exit(common.run_script(sys.argv[1:], funcs)) |
| 74 sys.exit(main()) |
OLD | NEW |