aboutsummaryrefslogtreecommitdiff
path: root/catapult/devil/bin/run_py_devicetests
blob: 9329f3a8ec5b660759f8d70e4ef05d885f710bf7 (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
47
48
49
50
#!/usr/bin/env vpython
# Copyright 2016 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.

import logging
import os
import sys

_CATAPULT_PATH = os.path.abspath(
    os.path.join(os.path.dirname(__file__), '..', '..'))
_DEVIL_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
_TYP_PATH = os.path.abspath(os.path.join(_CATAPULT_PATH, 'third_party', 'typ'))

sys.path.append(_TYP_PATH)
import typ

sys.path.append(_DEVIL_PATH)
from devil.android import device_test_case


def _SetUpLogging():
  parsed_args = typ.arg_parser.ArgumentParser().parse_args(args=sys.argv[1:])
  verbosity = parsed_args.verbose
  level = None
  if verbosity == 0:
    level = logging.WARNING
  elif verbosity == 1:
    level = logging.INFO
  elif verbosity >= 2:
    level = logging.DEBUG
  else:
    raise RuntimeError(
        'Logging verbosity of {} is not allowed.'.format(verbosity))
  logging.basicConfig(level=level)


def main():
  _SetUpLogging()
  runner = typ.Runner()
  runner.setup_fn = device_test_case.PrepareDevices
  return runner.main(
      coverage_source=[_DEVIL_PATH],
      jobs=1,
      suffixes=['*_devicetest.py'],
      top_level_dir=_DEVIL_PATH)


if __name__ == '__main__':
  sys.exit(main())