• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2014 The Chromium Authors
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5
6from pylib.gtest import gtest_test_instance
7from pylib.instrumentation import instrumentation_test_instance
8from pylib.junit import junit_test_instance
9from pylib.monkey import monkey_test_instance
10from pylib.local.device import local_device_environment
11from pylib.local.device import local_device_gtest_run
12from pylib.local.device import local_device_instrumentation_test_run
13from pylib.local.device import local_device_monkey_test_run
14from pylib.local.machine import local_machine_environment
15from pylib.local.machine import local_machine_junit_test_run
16
17
18def CreateTestRun(env, test_instance, error_func):
19  if isinstance(env, local_device_environment.LocalDeviceEnvironment):
20    if isinstance(test_instance, gtest_test_instance.GtestTestInstance):
21      return local_device_gtest_run.LocalDeviceGtestRun(env, test_instance)
22    if isinstance(test_instance,
23                  instrumentation_test_instance.InstrumentationTestInstance):
24      return (local_device_instrumentation_test_run
25              .LocalDeviceInstrumentationTestRun(env, test_instance))
26    if isinstance(test_instance, monkey_test_instance.MonkeyTestInstance):
27      return (local_device_monkey_test_run
28              .LocalDeviceMonkeyTestRun(env, test_instance))
29
30  if isinstance(env, local_machine_environment.LocalMachineEnvironment):
31    if isinstance(test_instance, junit_test_instance.JunitTestInstance):
32      return (local_machine_junit_test_run
33              .LocalMachineJunitTestRun(env, test_instance))
34
35  error_func('Unable to create test run for %s tests in %s environment'
36             % (str(test_instance), str(env)))
37  raise RuntimeError('error_func must call exit inside.')
38