summaryrefslogtreecommitdiffstats
path: root/infra/scripts/runtest_wrapper.py
blob: 825a4aba31248d4b41e41e710f5adc9648b4b4a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python
# Copyright 2015 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

"""Wrapper for runtest.py, makes it possible to control src-side
which file gets used and test the changes on trybots before landing."""


import argparse
import copy
import os
import subprocess
import sys


SRC_DIR = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))


def main(argv):
  parser = argparse.ArgumentParser()
  # TODO(phajdan.jr): Remove after cleaning up build repo side.
  parser.add_argument(
      '--path-build', help='Path to the build repo')
  parser.add_argument('args', nargs='*', help='Arguments to pass to runtest.py')
  args = parser.parse_args(argv)

  env = copy.copy(os.environ)
  pythonpath = env.get('PYTHONPATH', '').split(':')
  pythonpath.append(os.path.join(
      SRC_DIR, 'infra', 'scripts', 'legacy', 'scripts'))
  pythonpath.append(os.path.join(
      SRC_DIR, 'infra', 'scripts', 'legacy', 'site_config'))
  env['PYTHONPATH'] = ':'.join(pythonpath)

  return subprocess.call([
      sys.executable,
      os.path.join(SRC_DIR, 'infra', 'scripts', 'legacy',
                   'scripts', 'slave', 'runtest.py')
  ] + args.args, env=env)


if __name__ == '__main__':
  sys.exit(main(sys.argv[1:]))