Index: scripts/slave/recipe_modules/json/api.py |
diff --git a/scripts/slave/recipe_modules/json/api.py b/scripts/slave/recipe_modules/json/api.py |
index 487f0320b40f99e22b2ae033e9f992d2b35d6d5b..0ba17507fd192e61b549fa5a81f852d6b4169cda 100644 |
--- a/scripts/slave/recipe_modules/json/api.py |
+++ b/scripts/slave/recipe_modules/json/api.py |
@@ -11,6 +11,8 @@ from cStringIO import StringIO |
from slave import recipe_api |
+from .util import TestResults |
+ |
class StringListIO(object): |
def __init__(self): |
self.lines = [StringIO()] |
@@ -31,54 +33,6 @@ class StringListIO(object): |
self.lines[-1] = self.lines[-1].getvalue() |
-def convert_trie_to_flat_paths(trie, prefix=None): |
- # Cloned from webkitpy.layout_tests.layout_package.json_results_generator |
- # so that this code can stand alone. |
- result = {} |
- for name, data in trie.iteritems(): |
- if prefix: |
- name = prefix + "/" + name |
- |
- if len(data) and not "actual" in data and not "expected" in data: |
- result.update(convert_trie_to_flat_paths(data, name)) |
- else: |
- result[name] = data |
- |
- return result |
- |
- |
-class TestResults(object): |
- def __init__(self, jsonish): |
- self.raw = jsonish |
- |
- self.tests = convert_trie_to_flat_paths(jsonish.get('tests', {})) |
- self.passes = {} |
- self.unexpected_passes = {} |
- self.failures = {} |
- self.unexpected_failures = {} |
- self.flakes = {} |
- self.unexpected_flakes = {} |
- |
- for (test, result) in self.tests.iteritems(): |
- key = 'unexpected_' if result.get('is_unexpected') else '' |
- actual_result = result['actual'] |
- data = actual_result |
- if ' PASS' in actual_result: |
- key += 'flakes' |
- elif actual_result == 'PASS': |
- key += 'passes' |
- data = result |
- else: |
- key += 'failures' |
- getattr(self, key)[test] = data |
- |
- def __getattr__(self, key): |
- if key in self.raw: |
- return self.raw[key] |
- raise AttributeError("'%s' object has no attribute '%s'" % |
- (self.__class__, key)) # pragma: no cover |
- |
- |
class JsonOutputPlaceholder(recipe_api.Placeholder): |
"""JsonOutputPlaceholder is meant to be a placeholder object which, when added |
to a step's cmd list, will be replaced by annotated_run with the command |
@@ -188,4 +142,3 @@ class JsonApi(recipe_api.RecipeApi): |
'--factory-properties', prop_str, |
'--build-properties', prop_str |
] |
- |