Oleh Prypin | 3a51b0e | 2019-07-17 15:17:53 +0200 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | |
| 3 | # Copyright (c) 2019 The WebRTC project authors. All Rights Reserved. |
| 4 | # |
| 5 | # Use of this source code is governed by a BSD-style license |
| 6 | # that can be found in the LICENSE file in the root of the source |
| 7 | # tree. An additional intellectual property rights grant can be found |
| 8 | # in the file PATENTS. All contributing project authors may |
| 9 | # be found in the AUTHORS file in the root of the source tree. |
| 10 | |
| 11 | import argparse |
| 12 | import logging |
| 13 | import subprocess |
| 14 | import sys |
| 15 | |
| 16 | |
| 17 | def main(): |
| 18 | parser = argparse.ArgumentParser() |
| 19 | parser.add_argument('--isolated-script-test-output') |
| 20 | parser.add_argument('--isolated-script-test-perf-output') |
| 21 | args, unrecognized_args = parser.parse_known_args() |
| 22 | |
| 23 | test_command = _ForcePythonInterpreter(unrecognized_args) |
| 24 | if args.isolated_script_test_output: |
| 25 | test_command += ['--isolated_script_test_output', |
| 26 | args.isolated_script_test_output] |
| 27 | if args.isolated_script_test_perf_output: |
| 28 | test_command += ['--isolated_script_test_perf_output', |
| 29 | args.isolated_script_test_perf_output] |
| 30 | logging.info('Running %r', test_command) |
| 31 | |
| 32 | return subprocess.call(test_command) |
| 33 | |
| 34 | |
| 35 | def _ForcePythonInterpreter(cmd): |
| 36 | """Returns the fixed command line to call the right python executable.""" |
| 37 | out = cmd[:] |
| 38 | if out[0] == 'python': |
| 39 | out[0] = sys.executable |
| 40 | elif out[0].endswith('.py'): |
| 41 | out.insert(0, sys.executable) |
| 42 | return out |
| 43 | |
| 44 | |
| 45 | if __name__ == '__main__': |
| 46 | # pylint: disable=W0101 |
| 47 | logging.basicConfig(level=logging.INFO) |
| 48 | sys.exit(main()) |