| 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 python script under an isolate | |
| 7 | |
| 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 | |
| 10 argument: | |
| 11 | |
| 12 --isolated-script-test-output=[FILENAME] | |
| 13 | |
| 14 json is written to that file in the format produced by | |
| 15 common.parse_common_test_results. | |
| 16 | |
| 17 This script is intended to be the base command invoked by the isolate, | |
| 18 followed by a subsequent Python script.""" | |
| 19 | |
| 20 import argparse | |
| 21 import json | |
| 22 import os | |
| 23 import sys | |
| 24 | |
| 25 | |
| 26 import common | |
| 27 | |
| 28 # Add src/testing/ into sys.path for importing xvfb. | |
| 29 sys.path.append(os.path.join(os.path.dirname(__file__), '..')) | |
| 30 import xvfb | |
| 31 | |
| 32 | |
| 33 def main(): | |
| 34 parser = argparse.ArgumentParser() | |
| 35 parser.add_argument('--isolated-script-test-output', type=str, | |
| 36 required=True) | |
| 37 args, rest_args = parser.parse_known_args() | |
| 38 # Remove the chartjson extra arg until this script cares about chartjson | |
| 39 # results | |
| 40 index = 0 | |
| 41 for arg in rest_args: | |
| 42 if '--isolated-script-test-chartjson-output' in arg: | |
| 43 rest_args.pop(index) | |
| 44 break | |
| 45 index += 1 | |
| 46 | |
| 47 ret = common.run_command([sys.executable] + rest_args) | |
| 48 with open(args.isolated_script_test_output, 'w') as fp: | |
| 49 json.dump({'valid': True, | |
| 50 'failures': ['failed'] if ret else []}, fp) | |
| 51 return ret | |
| 52 | |
| 53 def main_compile_targets(args): | |
| 54 json.dump(['devtools_closure_compile'], args.output) | |
| 55 | |
| 56 | |
| 57 if __name__ == '__main__': | |
| 58 # Conform minimally to the protocol defined by ScriptTest. | |
| 59 if 'compile_targets' in sys.argv: | |
| 60 funcs = { | |
| 61 'run': None, | |
| 62 'compile_targets': main_compile_targets, | |
| 63 } | |
| 64 sys.exit(common.run_script(sys.argv[1:], funcs)) | |
| 65 sys.exit(main()) | |
| OLD | NEW |