Make ConfigUpdater runs conditional on milestone for pytest.
Make the ConfigUpdater runs run either the legacy approach or new pytest
approach by looking at the milestone. Milestones <= 83 do not have the
changes per moving to pytest and thus run the old approach.
BUG=chromium:1062657
TEST=./run_tests
Change-Id: I374384fa489748fbaf484929e54fae6c3783d3fe
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/2174462
Commit-Queue: David Burger <dburger@chromium.org>
Tested-by: David Burger <dburger@chromium.org>
Reviewed-by: Mike Nichols <mikenichols@chromium.org>
diff --git a/cbuildbot/stages/config_stages.py b/cbuildbot/stages/config_stages.py
index 5d2dc60..87a8c57 100644
--- a/cbuildbot/stages/config_stages.py
+++ b/cbuildbot/stages/config_stages.py
@@ -296,6 +296,38 @@
return False
def _RunUnitTest(self):
+ """Run chromeos_config_unittest on top of the changes.
+
+ Runs either the new pytest style test or old test depending
+ on the milestone version.
+ TODO(crbug/1062657): remove the legacy fallback when ConfigUpdater
+ no longer runs on a milestone <= 83.
+ """
+ if self.branch == 'master':
+ self._RunNewUnitTest()
+ else:
+ match = re.search(r'release-R(.+)-.*', self.branch)
+ if not match:
+ raise UpdateConfigException(
+ 'Unable to determine milestone from %s' % self.branch)
+ milestone = int(match.group(1))
+ if milestone > 83:
+ self._RunNewUnitTest()
+ else:
+ self._RunLegacyUnitTest()
+
+ def _RunLegacyUnitTest(self):
+ """Run chromeos_config_unittest on top of the changes."""
+ logging.debug('Running chromeos_config_unittest')
+ test_path = path_util.ToChrootPath(
+ os.path.join(self.chromite_dir, self.config_dir,
+ 'chromeos_config_unittest'))
+
+ # Because of --update, this updates our generated files.
+ cmd = ['cros_sdk', '--', test_path, '--update']
+ cros_build_lib.run(cmd, cwd=os.path.dirname(self.chromite_dir))
+
+ def _RunNewUnitTest(self):
"""Run chromeos_config_unittest on top of the changes."""
logging.info('Updating generated configuration files.')
refresh_script_path = path_util.ToChrootPath(