Patrik Höglund | 28b8a0b | 2020-03-26 20:30:50 +0100 | [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(): |
Mirko Bonadei | 8cc6695 | 2020-10-30 10:13:45 +0100 | [diff] [blame] | 18 | parser = argparse.ArgumentParser() |
| 19 | parser.add_argument('--isolated-script-test-perf-output') |
| 20 | args, unrecognized_args = parser.parse_known_args() |
Patrik Höglund | 28b8a0b | 2020-03-26 20:30:50 +0100 | [diff] [blame] | 21 | |
Mirko Bonadei | 8cc6695 | 2020-10-30 10:13:45 +0100 | [diff] [blame] | 22 | test_command = _ForcePythonInterpreter(unrecognized_args) |
| 23 | if args.isolated_script_test_perf_output: |
| 24 | test_command += [ |
| 25 | '--isolated_script_test_perf_output=' + |
| 26 | args.isolated_script_test_perf_output |
| 27 | ] |
| 28 | logging.info('Running %r', test_command) |
Patrik Höglund | 28b8a0b | 2020-03-26 20:30:50 +0100 | [diff] [blame] | 29 | |
Mirko Bonadei | 8cc6695 | 2020-10-30 10:13:45 +0100 | [diff] [blame] | 30 | return subprocess.call(test_command) |
Patrik Höglund | 28b8a0b | 2020-03-26 20:30:50 +0100 | [diff] [blame] | 31 | |
| 32 | |
| 33 | def _ForcePythonInterpreter(cmd): |
Mirko Bonadei | 8cc6695 | 2020-10-30 10:13:45 +0100 | [diff] [blame] | 34 | """Returns the fixed command line to call the right python executable.""" |
| 35 | out = cmd[:] |
| 36 | if out[0] == 'python': |
| 37 | out[0] = sys.executable |
| 38 | elif out[0].endswith('.py'): |
| 39 | out.insert(0, sys.executable) |
| 40 | return out |
Patrik Höglund | 28b8a0b | 2020-03-26 20:30:50 +0100 | [diff] [blame] | 41 | |
| 42 | |
| 43 | if __name__ == '__main__': |
Mirko Bonadei | 8cc6695 | 2020-10-30 10:13:45 +0100 | [diff] [blame] | 44 | # pylint: disable=W0101 |
| 45 | logging.basicConfig(level=logging.INFO) |
| 46 | sys.exit(main()) |