summaryrefslogtreecommitdiff
path: root/framework/backends
diff options
context:
space:
mode:
Diffstat (limited to 'framework/backends')
-rw-r--r--framework/backends/json.py23
-rw-r--r--framework/backends/junit.py6
2 files changed, 25 insertions, 4 deletions
diff --git a/framework/backends/json.py b/framework/backends/json.py
index 4cc7957b0..99f7e87a4 100644
--- a/framework/backends/json.py
+++ b/framework/backends/json.py
@@ -42,7 +42,7 @@ __all__ = [
]
# The current version of the JSON results
-CURRENT_JSON_VERSION = 7
+CURRENT_JSON_VERSION = 8
# The level to indent a final file
INDENT = 4
@@ -290,6 +290,7 @@ def _update_results(results, filepath):
4: _update_four_to_five,
5: _update_five_to_six,
6: _update_six_to_seven,
+ 7: _update_seven_to_eight,
}
while results.results_version < CURRENT_JSON_VERSION:
@@ -567,6 +568,26 @@ def _update_six_to_seven(result):
return result
+def _update_seven_to_eight(result):
+ """Update json results from version 7 to 8.
+
+ This update replaces the time attribute float with a TimeAttribute object,
+ which stores a start time and an end time, and provides methods for getting
+ total and delta.
+
+ This value is used for both TestResult.time and TestrunResult.time_elapsed.
+
+ """
+ for test in result.tests.viewvalues():
+ test.time = results.TimeAttribute(end=test.time)
+
+ result.time_elapsed = results.TimeAttribute(end=result.time_elapsed)
+
+ result.results_version = 8
+
+ return result
+
+
REGISTRY = Registry(
extensions=['', '.json'],
backend=JSONBackend,
diff --git a/framework/backends/junit.py b/framework/backends/junit.py
index a2cdd49a5..ee1cf288a 100644
--- a/framework/backends/junit.py
+++ b/framework/backends/junit.py
@@ -196,7 +196,7 @@ class JUnitBackend(FileBackend):
element = etree.Element('testcase', name=full_test_name,
classname=classname,
# Incomplete will not have a time.
- time=str(data.time),
+ time=str(data.time.total),
status=str(data.result))
# If this is an incomplete status then none of these values will be
@@ -253,7 +253,7 @@ def _load(results_file):
name = name[:-1]
result.result = test.attrib['status']
- result.time = float(test.attrib['time'])
+ result.time = results.TimeAttribute(end=float(test.attrib['time']))
result.err = test.find('system-err').text
# The command is prepended to system-out, so we need to separate those
@@ -263,7 +263,7 @@ def _load(results_file):
result.out = '\n'.join(out[1:])
run_result.tests[name] = result
-
+
return run_result