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

Unified Diff: scripts/slave/recipe_modules/auto_bisect/bisector.py

Issue 1827313002: Reland of Add bisect config validation. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build.git@master
Patch Set: Allow None as a valid value for all non-required fields. Created 4 years, 9 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/recipe_modules/auto_bisect/bisector.py
diff --git a/scripts/slave/recipe_modules/auto_bisect/bisector.py b/scripts/slave/recipe_modules/auto_bisect/bisector.py
index 162d3ff4b32f6574fb2701fea7668d3dc4470ce2..8e074135488f5ca26f55eb19d52b03fd6f4477f5 100644
--- a/scripts/slave/recipe_modules/auto_bisect/bisector.py
+++ b/scripts/slave/recipe_modules/auto_bisect/bisector.py
@@ -7,6 +7,7 @@ import re
import time
import urllib
+from . import config_validation
from . import depot_config
from . import revision_state
@@ -75,11 +76,12 @@ class Bisector(object):
"""
super(Bisector, self).__init__()
self._api = api
+ self.result_codes = set()
self.ensure_sync_master_branch()
self.bisect_config = bisect_config
self.config_step()
+ self._validate_config()
self.revision_class = revision_class
- self.result_codes = set()
self.last_tested_revision = None
# Test-only properties.
@@ -189,8 +191,9 @@ class Bisector(object):
return significantly_different
def config_step(self):
- """Yields a simple echo step that outputs the bisect config."""
+ """Yields a step that prints the bisect config."""
api = self.api
+
# bisect_config may come as a FrozenDict (which is not serializable).
bisect_config = dict(self.bisect_config)
@@ -201,12 +204,22 @@ class Bisector(object):
for k, v in bisect_config.iteritems():
if isinstance(v, basestring):
bisect_config[k] = fix_windows_backslashes(v)
+
# We sort the keys to prevent problems with orders changing when
# recipe_simulation_test compares against expectation files.
config_string = json.dumps(bisect_config, indent=2, sort_keys=True)
- result = api.m.step('config', [])
+ step = api.m.step('config', [])
config_lines = config_string.splitlines()
- result.presentation.logs['Bisect job configuration'] = config_lines
+ step.presentation.logs['Bisect job configuration'] = config_lines
+
+ def _validate_config(self):
+ """Raises an error and halts the bisect job if the config is invalid."""
+ try:
+ config_validation.validate_bisect_config(self.bisect_config)
+ except config_validation.ValidationFail as error:
+ self.surface_result('BAD_CONFIG')
+ self.api.m.halt(error.message)
+ raise self.api.m.step.StepFailure(error.message)
@property
def api(self):

Powered by Google App Engine
This is Rietveld 408576698