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 |
| 39 ret = common.run_command([sys.executable] + rest_args) |
| 40 with open(args.isolated_script_test_output) as fp: |
| 41 json.dump({'valid': True, |
| 42 'failures': ['failed'] if ret else []}, fp) |
| 43 |
| 44 def main_compile_targets(args): |
| 45 json.dump(['devtools_eslint'], args.output) |
| 46 |
| 47 |
| 48 if __name__ == '__main__': |
| 49 funcs = { |
| 50 'run': main, |
| 51 'compile_targets': main_compile_targets, |
| 52 } |
| 53 sys.exit(common.run_script(sys.argv[1:], funcs)) |
OLD | NEW |