summaryrefslogtreecommitdiffstats
path: root/infra/scripts/runtest_wrapper.py
blob: e97f12528bf9894b6c4acbfc3c6aa35b423e1f13 (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
45
46
#!/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()
  parser.add_argument('args', nargs='*', help='Arguments to pass to runtest.py')
  args = parser.parse_args(argv)

  env = copy.copy(os.environ)
  # Reset PYTHONPATH to make sure we're not accidentally using
  # the buildbot-provided value and build-side modules. That would make
  # changes inside this directory not take effect on buildbot.
  pythonpath = []
  pythonpath.append(os.path.join(
      SRC_DIR, 'infra', 'scripts', 'legacy', 'scripts'))
  pythonpath.append(os.path.join(
      SRC_DIR, 'infra', 'scripts', 'legacy', 'site_config'))
  pythonpath.append(os.path.join(
      SRC_DIR, 'third_party'))
  env['PYTHONPATH'] = os.pathsep.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:]))