blob: bdafefb7a7cfd64e4d7506d5a2fc062357c5f057 [file] [log] [blame]
Patrik Höglund28b8a0b2020-03-26 20:30:50 +01001#!/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
11import argparse
12import logging
13import subprocess
14import sys
15
16
17def main():
Jeremy Leconte994bf452022-01-12 10:51:16 +010018 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()
Patrik Höglund28b8a0b2020-03-26 20:30:50 +010022
Jeremy Leconte994bf452022-01-12 10:51:16 +010023 test_command = _ForcePythonInterpreter(unrecognized_args)
24 if args.isolated_script_test_output:
Jeremy Lecontecbfa2352022-02-07 20:38:28 +010025 test_command += ['--gtest_output=json:' + args.isolated_script_test_output]
Jeremy Leconte994bf452022-01-12 10:51:16 +010026 if args.isolated_script_test_perf_output:
27 test_command += [
28 '--isolated_script_test_perf_output=' +
29 args.isolated_script_test_perf_output
30 ]
31 logging.info('Running %r', test_command)
Patrik Höglund28b8a0b2020-03-26 20:30:50 +010032
Jeremy Leconte994bf452022-01-12 10:51:16 +010033 return subprocess.call(test_command)
Patrik Höglund28b8a0b2020-03-26 20:30:50 +010034
35
36def _ForcePythonInterpreter(cmd):
Jeremy Leconte994bf452022-01-12 10:51:16 +010037 """Returns the fixed command line to call the right python executable."""
38 out = cmd[:]
39 if out[0] == 'python':
40 out[0] = sys.executable
41 elif out[0].endswith('.py'):
42 out.insert(0, sys.executable)
43 return out
Patrik Höglund28b8a0b2020-03-26 20:30:50 +010044
45
46if __name__ == '__main__':
Jeremy Leconte994bf452022-01-12 10:51:16 +010047 logging.basicConfig(level=logging.INFO)
48 sys.exit(main())