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

Unified Diff: tools/testrunner/local/progress.py

Issue 285193009: Let test driver export json results. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Unified test name. Created 6 years, 7 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 | « tools/run-tests.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/testrunner/local/progress.py
diff --git a/tools/testrunner/local/progress.py b/tools/testrunner/local/progress.py
index 03116ee768d758cb1d0d6b3d6f8ab94dc08a7a0c..870dcc6b0bc10eee2543c257d9513387a4732fc4 100644
--- a/tools/testrunner/local/progress.py
+++ b/tools/testrunner/local/progress.py
@@ -26,11 +26,17 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+import json
+import os
import sys
import time
from . import junit_output
+
+ABS_PATH_PREFIX = os.getcwd() + os.sep
+
+
def EscapeCommand(command):
parts = []
for part in command:
@@ -277,6 +283,55 @@ class JUnitTestProgressIndicator(ProgressIndicator):
fail_text)
+class JsonTestProgressIndicator(ProgressIndicator):
+
+ def __init__(self, progress_indicator, json_test_results, arch, mode):
+ self.progress_indicator = progress_indicator
+ self.json_test_results = json_test_results
+ self.arch = arch
+ self.mode = mode
+ self.results = []
+
+ def Starting(self):
+ self.progress_indicator.runner = self.runner
+ self.progress_indicator.Starting()
+
+ def Done(self):
+ self.progress_indicator.Done()
+ complete_results = []
+ if os.path.exists(self.json_test_results):
+ with open(self.json_test_results, "r") as f:
+ # Buildbot might start out with an empty file.
+ complete_results = json.loads(f.read() or "[]")
+
+ complete_results.append({
+ "arch": self.arch,
+ "mode": self.mode,
+ "results": self.results,
+ })
+
+ with open(self.json_test_results, "w") as f:
+ f.write(json.dumps(complete_results))
+
+ def AboutToRun(self, test):
+ self.progress_indicator.AboutToRun(test)
+
+ def HasRun(self, test, has_unexpected_output):
+ self.progress_indicator.HasRun(test, has_unexpected_output)
+ if not has_unexpected_output:
+ return
+ self.results.append({
+ "name": test.GetLabel(),
+ "flags": test.flags,
+ "command": EscapeCommand(self.runner.GetCommand(test)).replace(
+ ABS_PATH_PREFIX, ""),
+ "stdout": test.output.stdout,
+ "stderr": test.output.stderr,
+ "exit_code": test.output.exit_code,
+ "result": "CRASH" if test.output.HasCrashed() else "FAIL",
+ })
+
+
PROGRESS_INDICATORS = {
'verbose': VerboseProgressIndicator,
'dots': DotsProgressIndicator,
« no previous file with comments | « tools/run-tests.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698