By default, ensure that Chrome is deployed when copying.
Sometimes I've pointed deploy_chrome at the wrong directory and it didn't
notice. This is bad. We should add some checks.
- By default, we enforce that files built by the "chrome" build target are
present.
- With --strict, we enforce that all files are present (including optional
files).
- With --sloppy, we enforce that just one file copied.
Also clean up the Rsync output a bit and checksum files before copying to
avoid unnecessary copies and add unit tests.
BUG=none
TEST=Unit tests. Run with unexpected input.
Change-Id: Ie8f655be6e8181a71827587485c9678807b834a9
Reviewed-on: https://gerrit.chromium.org/gerrit/44430
Commit-Queue: David James <davidjames@chromium.org>
Reviewed-by: David James <davidjames@chromium.org>
Tested-by: David James <davidjames@chromium.org>
diff --git a/scripts/deploy_chrome_unittest.py b/scripts/deploy_chrome_unittest.py
index 01b9469..741cda6 100755
--- a/scripts/deploy_chrome_unittest.py
+++ b/scripts/deploy_chrome_unittest.py
@@ -223,14 +223,29 @@
osutils, 'SourceEnvironment', autospec=True,
return_value={'STRIP': 'x86_64-cros-linux-gnu-strip'})
- def testEmptyDeploySuccess(self):
- """User-mode staging - stage whatever we can find."""
+ def testSingleFileDeployFailure(self):
+ """Default staging enforces that mandatory files are copied"""
options, _ = _ParseCommandLine(self.common_flags)
- deploy_chrome._PrepareStagingDir(
+ osutils.Touch(os.path.join(self.build_dir, 'chrome'), makedirs=True)
+ self.assertRaises(
+ chrome_util.MissingPathError, deploy_chrome._PrepareStagingDir,
options, self.tempdir, self.staging_dir)
+ def testSloppyDeployFailure(self):
+ """Sloppy staging enforces that at least one file is copied."""
+ options, _ = _ParseCommandLine(self.common_flags + ['--sloppy'])
+ self.assertRaises(
+ chrome_util.MissingPathError, deploy_chrome._PrepareStagingDir,
+ options, self.tempdir, self.staging_dir)
+
+ def testSloppyDeploySuccess(self):
+ """Sloppy staging - stage one file."""
+ options, _ = _ParseCommandLine(self.common_flags + ['--sloppy'])
+ osutils.Touch(os.path.join(self.build_dir, 'chrome'), makedirs=True)
+ deploy_chrome._PrepareStagingDir(options, self.tempdir, self.staging_dir)
+
def testEmptyDeployStrict(self):
- """ebuild-mode staging - stage only things we want."""
+ """Strict staging fails when there are no files."""
options, _ = _ParseCommandLine(
self.common_flags + ['--gyp-defines', 'chromeos=1', '--strict'])
chrome_util.MissingPathError(deploy_chrome._PrepareStagingDir,