chrome_chromeos_lkgm: Remove any existing chrome checkout
This iteration removes the chrome_src checkout and always runs
'git clone'. This will add < 10 minutes to the total run time
and ensure that previous incorrect implementations are not
affecting the script.
It also outputs a warning instead of failing for any
LKGMNotCommitted exception.
BUG=chromium:732579
TEST=chrome_chromeos_lkgm_unittest
Change-Id: I2e799a820207ea04f5c25bd00d2c8805e6502f26
Reviewed-on: https://chromium-review.googlesource.com/759151
Tested-by: Steven Bennetts <stevenjb@chromium.org>
Trybot-Ready: Steven Bennetts <stevenjb@chromium.org>
Reviewed-by: Don Garrett <dgarrett@chromium.org>
diff --git a/scripts/chrome_chromeos_lkgm_unittest.py b/scripts/chrome_chromeos_lkgm_unittest.py
index 0c4f6bb..f41517c 100644
--- a/scripts/chrome_chromeos_lkgm_unittest.py
+++ b/scripts/chrome_chromeos_lkgm_unittest.py
@@ -29,6 +29,7 @@
self.committer = chrome_chromeos_lkgm.ChromeLGTMCommitter(
self.tempdir, '1001.0.0', False, 'user@test.org')
self.lkgm_file = os.path.join(self.tempdir, constants.PATH_TO_CHROME_LKGM)
+ self.old_lkgm = None
self.pass_status = builder_status_lib.BuilderStatus(
constants.BUILDER_STATUS_PASSED, None)
self.fail_status = builder_status_lib.BuilderStatus(
@@ -41,14 +42,18 @@
BaseChromeLGTMCommitterTest):
"""Test cros_chromeos_lkgm.Committer."""
+ def _createOldLkgm(self, items): # pylint: disable=unused-argument
+ # Write out an old lkgm file as if we got it from a git fetch.
+ osutils.SafeMakedirs(os.path.dirname(self.lkgm_file))
+ osutils.WriteFile(self.lkgm_file, self.old_lkgm)
+
def testCheckoutChromeLKGM(self):
"Tests that we can read/obtain the old LKGM from mocked out git."
- # Write out an old lkgm file as if we got it from a git fetch.
- old_lkgm = '1234.0.0'
- osutils.SafeMakedirs(os.path.dirname(self.lkgm_file))
- osutils.WriteFile(self.lkgm_file, old_lkgm)
+ self.old_lkgm = '1234.0.0'
+ self.rc.AddCmdResult(partial_mock.In('clone'), returncode=0,
+ side_effect=self._createOldLkgm)
self.committer.CheckoutChromeLKGM()
- self.assertTrue(self.committer._old_lkgm, old_lkgm)
+ self.assertTrue(self.committer._old_lkgm, self.old_lkgm)
def testCommitNewLKGM(self):
"""Tests that we can commit a new LKGM file."""
@@ -85,14 +90,14 @@
def testOlderLKGMFails(self):
"""Tests that trying to update to an older lkgm version fails."""
- old_lkgm = '1002.0.0'
- osutils.SafeMakedirs(os.path.dirname(self.lkgm_file))
- osutils.WriteFile(self.lkgm_file, old_lkgm)
+ self.old_lkgm = '1002.0.0'
+ self.rc.AddCmdResult(partial_mock.In('clone'), returncode=0,
+ side_effect=self._createOldLkgm)
self.committer = chrome_chromeos_lkgm.ChromeLGTMCommitter(
self.tempdir, '1001.0.0', False, 'user@test.org')
self.committer.CheckoutChromeLKGM()
- self.assertTrue(self.committer._old_lkgm, old_lkgm)
+ self.assertTrue(self.committer._old_lkgm, self.old_lkgm)
self.PatchObject(tree_status, 'IsTreeOpen', return_value=True)
self.assertRaises(chrome_chromeos_lkgm.LKGMNotValid,
@@ -100,11 +105,11 @@
def testVersionWithChromeBranch(self):
"""Tests passing a version with a chrome branch strips the branch."""
- old_lkgm = '1002.0.0'
- osutils.SafeMakedirs(os.path.dirname(self.lkgm_file))
- osutils.WriteFile(self.lkgm_file, old_lkgm)
+ self.old_lkgm = '1002.0.0'
+ self.rc.AddCmdResult(partial_mock.In('clone'), returncode=0,
+ side_effect=self._createOldLkgm)
self.committer.CheckoutChromeLKGM()
- self.assertTrue(self.committer._old_lkgm, old_lkgm)
+ self.assertTrue(self.committer._old_lkgm, self.old_lkgm)
self.committer = chrome_chromeos_lkgm.ChromeLGTMCommitter(
self.tempdir, '1003.0.0-rc2', False, 'user@test.org')