1# Copyright 2014 The Chromium Authors. All rights reserved. 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5import os 6 7from pylib import cmd_helper 8from pylib import constants 9 10class JavaTestRunner(object): 11 """Runs java tests on the host.""" 12 13 def __init__(self, options): 14 self._package_filter = options.package_filter 15 self._runner_filter = options.runner_filter 16 self._sdk_version = options.sdk_version 17 self._test_filter = options.test_filter 18 self._test_suite = options.test_suite 19 20 def SetUp(self): 21 pass 22 23 def RunTest(self, _test): 24 """Runs junit tests from |self._test_suite|.""" 25 command = ['java', 26 '-jar', os.path.join(constants.GetOutDirectory(), 'lib.java', 27 '%s.jar' % self._test_suite)] 28 if self._test_filter: 29 command.extend(['-gtest-filter', self._test_filter]) 30 if self._package_filter: 31 command.extend(['-package-filter', self._package_filter]) 32 if self._runner_filter: 33 command.extend(['-runner-filter', self._runner_filter]) 34 if self._sdk_version: 35 command.extend(['-sdk-version', self._sdk_version]) 36 return cmd_helper.RunCmd(command) 37 38 def TearDown(self): 39 pass 40 41