| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import functools | 5 import functools |
| 6 import collections | 6 import collections |
| 7 import contextlib | 7 import contextlib |
| 8 import json | 8 import json |
| 9 | 9 |
| 10 from cStringIO import StringIO | 10 from cStringIO import StringIO |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 | 75 |
| 76 if self.add_json_log: | 76 if self.add_json_log: |
| 77 key = self.name + ('' if valid else ' (invalid)') | 77 key = self.name + ('' if valid else ' (invalid)') |
| 78 with contextlib.closing(StringListIO()) as listio: | 78 with contextlib.closing(StringListIO()) as listio: |
| 79 json.dump(ret, listio, indent=2, sort_keys=True) | 79 json.dump(ret, listio, indent=2, sort_keys=True) |
| 80 presentation.logs[key] = listio.lines | 80 presentation.logs[key] = listio.lines |
| 81 | 81 |
| 82 return ret | 82 return ret |
| 83 | 83 |
| 84 | 84 |
| 85 # TODO(phajdan.jr): Rename to LayoutTestResultsOutputPlaceholder. | |
| 86 class TestResultsOutputPlaceholder(JsonOutputPlaceholder): | 85 class TestResultsOutputPlaceholder(JsonOutputPlaceholder): |
| 87 def result(self, presentation, test): | 86 def result(self, presentation, test): |
| 88 ret = super(TestResultsOutputPlaceholder, self).result(presentation, test) | 87 ret = super(TestResultsOutputPlaceholder, self).result(presentation, test) |
| 89 return TestResults(ret) | 88 return TestResults(ret) |
| 90 | 89 |
| 91 | 90 |
| 92 # TODO(martiniss) replace this with step.AggregateResults once | 91 # TODO(martiniss) replace this with step.AggregateResults once |
| 93 # aggregate steps lands | 92 # aggregate steps lands |
| 94 class GTestResultsOutputPlaceholder(JsonOutputPlaceholder): | 93 class GTestResultsOutputPlaceholder(JsonOutputPlaceholder): |
| 95 def result(self, presentation, test): | 94 def result(self, presentation, test): |
| (...skipping 15 matching lines...) Expand all Loading... |
| 111 @recipe_util.returns_placeholder | 110 @recipe_util.returns_placeholder |
| 112 def input(self, data): | 111 def input(self, data): |
| 113 """A placeholder which will expand to a file path containing <data>.""" | 112 """A placeholder which will expand to a file path containing <data>.""" |
| 114 return self.m.raw_io.input(self.dumps(data), '.json') | 113 return self.m.raw_io.input(self.dumps(data), '.json') |
| 115 | 114 |
| 116 @recipe_util.returns_placeholder | 115 @recipe_util.returns_placeholder |
| 117 def output(self, add_json_log=True): | 116 def output(self, add_json_log=True): |
| 118 """A placeholder which will expand to '/tmp/file'.""" | 117 """A placeholder which will expand to '/tmp/file'.""" |
| 119 return JsonOutputPlaceholder(self, add_json_log) | 118 return JsonOutputPlaceholder(self, add_json_log) |
| 120 | 119 |
| 121 # TODO(phajdan.jr): Rename to layout_test_results. | |
| 122 @recipe_util.returns_placeholder | 120 @recipe_util.returns_placeholder |
| 123 def test_results(self, add_json_log=True): | 121 def test_results(self, add_json_log=True): |
| 124 """A placeholder which will expand to '/tmp/file'. | 122 """A placeholder which will expand to '/tmp/file'. |
| 125 | 123 |
| 126 The recipe must provide the expected --json-test-results flag. | 124 The recipe must provide the expected --json-test-results flag. |
| 127 | 125 |
| 128 The test_results will be an instance of the TestResults class. | 126 The test_results will be an instance of the TestResults class. |
| 129 """ | 127 """ |
| 130 return TestResultsOutputPlaceholder(self, add_json_log) | 128 return TestResultsOutputPlaceholder(self, add_json_log) |
| 131 | 129 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 | 161 |
| 164 It's vastly preferable to have your recipe only pass the bare minimum | 162 It's vastly preferable to have your recipe only pass the bare minimum |
| 165 of arguments to steps. Passing property objects obscures the data that | 163 of arguments to steps. Passing property objects obscures the data that |
| 166 the script actually consumes from the property object. | 164 the script actually consumes from the property object. |
| 167 """ | 165 """ |
| 168 prop_str = self.dumps(dict(self.m.properties)) | 166 prop_str = self.dumps(dict(self.m.properties)) |
| 169 return [ | 167 return [ |
| 170 '--factory-properties', prop_str, | 168 '--factory-properties', prop_str, |
| 171 '--build-properties', prop_str | 169 '--build-properties', prop_str |
| 172 ] | 170 ] |
| OLD | NEW |