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

Unified 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, 9 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/pylib/junit/test_runner.py
diff --git a/build/android/pylib/junit/test_runner.py b/build/android/pylib/junit/test_runner.py
index b85967b40d444d6ad7fa50c102c936085d0f7e2b..bf9741285d0249e879c1f565ce931b3b5fb67760 100644
--- a/build/android/pylib/junit/test_runner.py
+++ b/build/android/pylib/junit/test_runner.py
@@ -2,10 +2,14 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+import json
import os
+import tempfile
from pylib import cmd_helper
from pylib import constants
+from pylib.base import base_test_result
+from pylib.results import json_results
class JavaTestRunner(object):
"""Runs java tests on the host."""
@@ -22,22 +26,25 @@ class JavaTestRunner(object):
def RunTest(self, _test):
"""Runs junit tests from |self._test_suite|."""
-
- command = ['java',
- '-Drobolectric.dependency.dir=%s' %
- os.path.join(constants.GetOutDirectory(), 'lib.java'),
- '-jar', os.path.join(constants.GetOutDirectory(), 'lib.java',
- '%s.jar' % self._test_suite)]
-
- if self._test_filter:
- command.extend(['-gtest-filter', self._test_filter])
- if self._package_filter:
- command.extend(['-package-filter', self._package_filter])
- if self._runner_filter:
- command.extend(['-runner-filter', self._runner_filter])
- if self._sdk_version:
- command.extend(['-sdk-version', self._sdk_version])
- return cmd_helper.RunCmd(command)
+ with tempfile.NamedTemporaryFile() as json_file:
+ command = ['java',
+ '-Drobolectric.dependency.dir=%s' %
+ os.path.join(constants.GetOutDirectory(), 'lib.java'),
+ '-jar', os.path.join(constants.GetOutDirectory(), 'lib.java',
+ '%s.jar' % self._test_suite),
+ '-json-results-file', json_file.name]
+ if self._test_filter:
+ command.extend(['-gtest-filter', self._test_filter])
+ if self._package_filter:
+ command.extend(['-package-filter', self._package_filter])
+ if self._runner_filter:
+ command.extend(['-runner-filter', self._runner_filter])
+ if self._sdk_version:
+ command.extend(['-sdk-version', self._sdk_version])
+ return_code = cmd_helper.RunCmd(command)
+ results_list = json_results.ParseResultsFromJson(
+ json.loads(json_file.read()))
+ return (results_list, return_code)
def TearDown(self):
pass
« 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