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

Unified Diff: third_party/typ/typ/json_results.py

Issue 2690743002: Roll typ v0.9.9 -> v0.9.11 (5822dda0..f6afa2bb). (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
Index: third_party/typ/typ/json_results.py
diff --git a/third_party/typ/typ/json_results.py b/third_party/typ/typ/json_results.py
index bb693a2636d9ea2b068ba67633fe785eeac6987d..6d1eb81c47bdd152ee88afc83ea873355606ab6c 100644
--- a/third_party/typ/typ/json_results.py
+++ b/third_party/typ/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:
@@ -105,7 +104,10 @@ def make_full_results(metadata, seconds_since_epoch, all_test_names, results):
def make_upload_request(test_results_server, builder, master, testtype,
full_results):
- url = 'https://%s/testfile/upload' % test_results_server
+ if test_results_server.startswith('http'):
+ url = '%s/testfile/upload' % test_results_server
+ else:
+ url = 'https://%s/testfile/upload' % test_results_server
attrs = [('builder', builder),
('master', master),
('testtype', testtype)]
@@ -141,8 +143,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 +155,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 | « third_party/typ/typ/fakes/tests/test_result_server_fake_test.py ('k') | third_party/typ/typ/tests/json_results_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698