summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
authorSteve Fung <stevefung@chromium.org>2015-06-05 02:35:16 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-06-07 19:12:37 +0000
commit180a95a0b6cb2cdadf7885ea2c6fa4420bfbb0c2 (patch)
tree203601100e9b2a7e75e5bd38e9fed729f47b028a /cli
parent63e8b411bb5a6809eddd2d4453d1dc2779d05515 (diff)
downloadchromite-180a95a0b6cb2cdadf7885ea2c6fa4420bfbb0c2.tar.gz
image: Friendly error message for an invalid buildTypeId
Output a friendlier error message when a blueprint contains an invalid buildTypeId. BUG=brillo:1192 TEST=manually tested blueprint with an invalid buildTypeId. TEST=`./cros_image_unittest` passes Change-Id: Ic06dfb6047ec1f8752eb0c2779f8191d686bdb97 Reviewed-on: https://chromium-review.googlesource.com/275385 Tested-by: Steve Fung <stevefung@chromium.org> Reviewed-by: Bertrand Simonnet <bsimonnet@chromium.org> Commit-Queue: Steve Fung <stevefung@chromium.org> Trybot-Ready: Steve Fung <stevefung@chromium.org>
Diffstat (limited to 'cli')
-rw-r--r--cli/cros/cros_image.py35
-rw-r--r--cli/cros/cros_image_unittest.py6
2 files changed, 25 insertions, 16 deletions
diff --git a/cli/cros/cros_image.py b/cli/cros/cros_image.py
index 9c065af81..6bad534be 100644
--- a/cli/cros/cros_image.py
+++ b/cli/cros/cros_image.py
@@ -10,6 +10,7 @@ from chromite.cli import command
from chromite.lib import blueprint_lib
from chromite.lib import brick_lib
from chromite.lib import commandline
+from chromite.lib import cros_build_lib
from chromite.lib import image_lib
@@ -87,16 +88,24 @@ class ImageCommand(command.CliCommand):
elif self.options.board:
board = self.options.board
- image_lib.BuildImage(
- board,
- adjust_part=self.options.adjust_part,
- app_id=app_id,
- boot_args=self.options.boot_args,
- enable_bootcache=self.options.enable_bootcache,
- enable_rootfs_verification=self.options.enable_rootfs_verification,
- output_root=self.options.output_root,
- disk_layout=self.options.disk_layout,
- enable_serial=self.options.enable_serial,
- kernel_log_level=self.options.kernel_log_level,
- packages=packages,
- image_types=self.options.image_types)
+ try:
+ image_lib.BuildImage(
+ board,
+ adjust_part=self.options.adjust_part,
+ app_id=app_id,
+ boot_args=self.options.boot_args,
+ enable_bootcache=self.options.enable_bootcache,
+ enable_rootfs_verification=self.options.enable_rootfs_verification,
+ output_root=self.options.output_root,
+ disk_layout=self.options.disk_layout,
+ enable_serial=self.options.enable_serial,
+ kernel_log_level=self.options.kernel_log_level,
+ packages=packages,
+ image_types=self.options.image_types)
+ except image_lib.AppIdError:
+ cros_build_lib.Die('Invalid field \'%s\' in blueprint %s: %s. It should '
+ 'be a UUID in the canonical {8-4-4-4-12} format, e.g. '
+ '{01234567-89AB-CDEF-0123-456789ABCDEF}.' %
+ (blueprint_lib.APP_ID_FIELD,
+ self.options.blueprint,
+ app_id))
diff --git a/cli/cros/cros_image_unittest.py b/cli/cros/cros_image_unittest.py
index 05222672a..dfa942bb1 100644
--- a/cli/cros/cros_image_unittest.py
+++ b/cli/cros/cros_image_unittest.py
@@ -32,7 +32,8 @@ class MockImageCommand(command_unittest.MockCommand):
return super(MockImageCommand, self).Run(inst)
-class ImageCommandTest(cros_test_lib.WorkspaceTestCase):
+class ImageCommandTest(cros_test_lib.WorkspaceTestCase,
+ cros_test_lib.OutputTestCase):
"""Test class for our ImageCommand class."""
def SetupCommandMock(self, cmd_args):
@@ -102,8 +103,7 @@ class ImageCommandTest(cros_test_lib.WorkspaceTestCase):
args = ['--blueprint=//foo.json']
self.SetupCommandMock(args)
- with self.assertRaises(image_lib.AppIdError):
- self.cmd_mock.inst.Run()
+ self.AssertFuncSystemExitNonZero(self.cmd_mock.inst.Run)
def testOutputRootInWorkspace(self):
"""Tests running the image command with an output root in the workspace."""