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

Unified Diff: scripts/slave/recipes/blink_trybot.py

Issue 23889036: Refactor the way that TestApi works so that it is actually useful. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Move gclient test_api to got_revisions cl Created 7 years, 3 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: scripts/slave/recipes/blink_trybot.py
diff --git a/scripts/slave/recipes/blink_trybot.py b/scripts/slave/recipes/blink_trybot.py
index a610c7fbdb79f8e7e6f26a11df5c23eda7e71c3d..a0a0a20b20e9c51e7fdf88f10c1155beae3ced48 100644
--- a/scripts/slave/recipes/blink_trybot.py
+++ b/scripts/slave/recipes/blink_trybot.py
@@ -173,61 +173,20 @@ def GenSteps(api):
)
-## Test Code
-# TODO(iannucci): Find some way that the json module can provide these methods
-# in the test api, since they'll be useful for anyone who uses
-# the 'json.test_results' object.
-def add_result(r, name, expected, actual=None):
- """Adds a test result to a 'json test results' compatible object.
- Args:
- r - The test result object to add to
- name - A full test name delimited by '/'. ex. 'some/category/test.html'
- expected - The string value for the 'expected' result of this test.
- actual (optional) - If not None, this is the actual result of the test.
- Otherwise this will be set equal to expected.
-
- The test will also get an 'is_unexpected' key if actual != expected.
- """
- actual = actual or expected
- entry = r.setdefault('tests', {})
- for token in name.split('/'):
- entry = entry.setdefault(token, {})
- entry['expected'] = expected
- entry['actual'] = actual
- if expected != actual:
- entry['is_unexpected'] = True
-
-
-def canned_test_output(good, passes=9001):
- """Produces a 'json test results' compatible object with some canned tests.
- Args:
- good - Determines if this test result is passing or not.
- passes - The number of (theoretically) passing tests.
- """
- bad = lambda fail_val: None if good else fail_val
- r = {"num_passes": passes}
- add_result(r, 'good/totally-awesome.html', 'PASS')
- add_result(r, 'flake/totally-flakey.html', 'PASS', bad('TIMEOUT PASS'))
- add_result(r, 'tricky/totally-maybe-not-awesome.html', 'PASS', bad('FAIL'))
- add_result(r, 'bad/totally-bad-probably.html', 'PASS', bad('FAIL'))
- return r
-
-
-def step_mock(suffix, good):
- """Produces the step mock for a single webkit tests step.
- Args:
- good - Determines if the result of this step was good or bad.
- suffix - The suffix of the step name.
- """
- return {
- ('webkit_tests (%s)' % suffix): {
- 'json': {'test_results': canned_test_output(good) },
- '$R': 0 if good else 1
+def GenTests(api):
+ def step_mock(suffix, good):
+ """Produces the step mock for a single webkit tests step.
+ Args:
+ good - Determines if the result of this step was good or bad.
+ suffix - The suffix of the step name.
+ """
+ mock = api.json.canned_test_output(good)
+ mock['$R'] = 0 if good else 1
+ return {
+ ('webkit_tests (%s)' % suffix): mock
}
- }
-def GenTests(api):
for result, good in [('success', True), ('fail', False)]:
for build_config in ['Release', 'Debug']:
for plat in ('win', 'mac', 'linux'):
@@ -239,7 +198,7 @@ def GenTests(api):
step_mocks.update(step_mock('without patch', good))
yield ('%s_%s_%s%s' % (plat, result, build_config.lower(), suffix)), {
- 'properties': api.properties_tryserver(
+ 'properties': api.properties.tryserver(
build_config=build_config,
config_name='blink',
root='src/third_party/WebKit',
@@ -256,7 +215,7 @@ def GenTests(api):
warn_on_flakey_data = step_mock('with patch', False)
warn_on_flakey_data.update(step_mock('without patch', True))
yield 'warn_on_flakey', {
- 'properties': api.properties_tryserver(
+ 'properties': api.properties.tryserver(
build_config='Release',
config_name='blink',
root='src/third_party/WebKit',

Powered by Google App Engine
This is Rietveld 408576698