Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Side by Side Diff: build/android/pylib/junit/test_runner.py

Issue 1003463002: Add json output to Junit tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and addressed nyquist's comment. Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 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 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import json
5 import os 6 import os
7 import tempfile
6 8
7 from pylib import cmd_helper 9 from pylib import cmd_helper
8 from pylib import constants 10 from pylib import constants
11 from pylib.base import base_test_result
12 from pylib.results import json_results
9 13
10 class JavaTestRunner(object): 14 class JavaTestRunner(object):
11 """Runs java tests on the host.""" 15 """Runs java tests on the host."""
12 16
13 def __init__(self, args): 17 def __init__(self, args):
14 self._package_filter = args.package_filter 18 self._package_filter = args.package_filter
15 self._runner_filter = args.runner_filter 19 self._runner_filter = args.runner_filter
16 self._sdk_version = args.sdk_version 20 self._sdk_version = args.sdk_version
17 self._test_filter = args.test_filter 21 self._test_filter = args.test_filter
18 self._test_suite = args.test_suite 22 self._test_suite = args.test_suite
19 23
20 def SetUp(self): 24 def SetUp(self):
21 pass 25 pass
22 26
23 def RunTest(self, _test): 27 def RunTest(self, _test):
24 """Runs junit tests from |self._test_suite|.""" 28 """Runs junit tests from |self._test_suite|."""
25 29 with tempfile.NamedTemporaryFile() as json_file:
26 command = ['java', 30 command = ['java',
27 '-Drobolectric.dependency.dir=%s' % 31 '-Drobolectric.dependency.dir=%s' %
28 os.path.join(constants.GetOutDirectory(), 'lib.java'), 32 os.path.join(constants.GetOutDirectory(), 'lib.java'),
29 '-jar', os.path.join(constants.GetOutDirectory(), 'lib.java', 33 '-jar', os.path.join(constants.GetOutDirectory(), 'lib.java',
30 '%s.jar' % self._test_suite)] 34 '%s.jar' % self._test_suite),
31 35 '-json-results-file', json_file.name]
32 if self._test_filter: 36 if self._test_filter:
33 command.extend(['-gtest-filter', self._test_filter]) 37 command.extend(['-gtest-filter', self._test_filter])
34 if self._package_filter: 38 if self._package_filter:
35 command.extend(['-package-filter', self._package_filter]) 39 command.extend(['-package-filter', self._package_filter])
36 if self._runner_filter: 40 if self._runner_filter:
37 command.extend(['-runner-filter', self._runner_filter]) 41 command.extend(['-runner-filter', self._runner_filter])
38 if self._sdk_version: 42 if self._sdk_version:
39 command.extend(['-sdk-version', self._sdk_version]) 43 command.extend(['-sdk-version', self._sdk_version])
40 return cmd_helper.RunCmd(command) 44 return_code = cmd_helper.RunCmd(command)
45 results_list = json_results.ParseResultsFromJson(
46 json.loads(json_file.read()))
47 return (results_list, return_code)
41 48
42 def TearDown(self): 49 def TearDown(self):
43 pass 50 pass
44 51
OLDNEW
« no previous file with comments | « build/android/pylib/junit/test_dispatcher.py ('k') | build/android/pylib/results/json_results.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698