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

Unified Diff: typ/json_results.py

Issue 2693503003: Add test times to the JSON results. (Closed)
Patch Set: Created 3 years, 10 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 | « no previous file | typ/tests/json_results_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: typ/json_results.py
diff --git a/typ/json_results.py b/typ/json_results.py
index bb693a2636d9ea2b068ba67633fe785eeac6987d..3f2053152d474012e303ab547181c107c2e0d7bf 100644
--- a/typ/json_results.py
+++ b/typ/json_results.py
@@ -90,8 +90,7 @@ def make_full_results(metadata, seconds_since_epoch, all_test_names, results):
full_results['tests'] = OrderedDict()
for test_name in all_test_names:
- value = OrderedDict()
- value['actual'] = _actual_results_for_test(test_name, results)
+ value = _results_for_test(test_name, results)
if test_name in skipped_tests:
value['expected'] = 'SKIP'
else:
@@ -141,8 +140,10 @@ def _passing_test_names(results):
return set(r.name for r in results.results if r.actual == ResultType.Pass)
-def _actual_results_for_test(test_name, results):
+def _results_for_test(test_name, results):
+ value = OrderedDict()
actuals = []
+ times = []
for r in results.results:
if r.name == test_name:
if r.actual == ResultType.Failure:
@@ -151,10 +152,18 @@ def _actual_results_for_test(test_name, results):
actuals.append('PASS')
elif r.actual == ResultType.Skip:
actuals.append('SKIP')
+
+ # The time a test takes is a floating point number of seconds;
+ # if we were to encode this unmodified, then when we converted it
+ # to JSON it might make the file significantly larger. Instead
+ # we truncate the file to ten-thousandths of a second, which is
+ # probably more than good enough for most tests.
+ times.append(round(r.took, 4))
if not actuals: # pragma: untested
actuals.append('SKIP')
- return ' '.join(actuals)
-
+ value['actual'] = ' '.join(actuals)
+ value['times'] = times
+ return value
def _add_path_to_trie(trie, path, value):
if TEST_SEPARATOR not in path:
« no previous file with comments | « no previous file | typ/tests/json_results_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698