summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <lars.wirzenius@codethink.co.uk>2013-04-12 13:15:39 +0000
committerLars Wirzenius <lars.wirzenius@codethink.co.uk>2013-04-12 13:15:39 +0000
commite7e90384da00a8197c5e0363a5a4005754a790eb (patch)
tree5e15b4065ca1a39b9baa7d83868ff1b431f4a0d5
parent967735355fe57b0dbd5b2c744945c8b4ee26a511 (diff)
parent7c5487a695ab8353e9e98116a7165722cdd9f61e (diff)
downloadmorph-e7e90384da00a8197c5e0363a5a4005754a790eb.tar.gz
Merge remote-tracking branch 'origin/baserock/richardholland/empty-stratum-error'
Reviewed-by: Lars Wirzenius
-rw-r--r--morphlib/builder2.py8
-rw-r--r--tests.build/empty-stratum.exit1
-rwxr-xr-xtests.build/empty-stratum.script38
-rw-r--r--tests.build/empty-stratum.stderr1
4 files changed, 47 insertions, 1 deletions
diff --git a/morphlib/builder2.py b/morphlib/builder2.py
index f8f4ea88..7ded281e 100644
--- a/morphlib/builder2.py
+++ b/morphlib/builder2.py
@@ -471,7 +471,7 @@ class StratumBuilder(BuilderBase):
constituents = [d for d in self.artifact.dependencies
if self.is_constituent(d)]
if len(constituents) == 0:
- logging.warning('Stratum %s is empty' % self.artifact.name)
+ raise EmptyStratumError(self.artifact.name)
# the only reason the StratumBuilder has to download chunks is to
# check for overlap now that strata are lists of chunks
@@ -854,3 +854,9 @@ class DiskImageBuilder(SystemKindBuilder): # pragma: no cover
filename=image_name, chatty=True)
with self.build_watch('undo-device-mapper'):
morphlib.fsutils.undo_device_mapping(self.app.runcmd, image_name)
+
+class EmptyStratumError(cliapp.AppException):
+
+ def __init__(self, stratum_name): # pragma: no cover
+ cliapp.AppException.__init__(self,
+ "Stratum %s is empty (has no dependencies)" % stratum_name)
diff --git a/tests.build/empty-stratum.exit b/tests.build/empty-stratum.exit
new file mode 100644
index 00000000..d00491fd
--- /dev/null
+++ b/tests.build/empty-stratum.exit
@@ -0,0 +1 @@
+1
diff --git a/tests.build/empty-stratum.script b/tests.build/empty-stratum.script
new file mode 100755
index 00000000..6856b2bd
--- /dev/null
+++ b/tests.build/empty-stratum.script
@@ -0,0 +1,38 @@
+#!/bin/sh
+#
+# Copyright (C) 2013 Codethink Limited
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+set -eu
+
+morphsrepo="$DATADIR/morphs-repo"
+cd "$morphsrepo"
+
+git checkout --quiet -b empty-stratum
+
+# Create empty stratum to test S4585
+cat <<EOF > hello-stratum.morph
+{
+ "name": "hello-stratum",
+ "kind": "stratum"
+}
+EOF
+sed -i 's/master/empty-stratum/' hello-system.morph
+git add hello-stratum.morph hello-system.morph
+
+git commit --quiet -m "add empty stratum"
+
+"$SRCDIR/scripts/test-morph" build-morphology \
+ test:morphs-repo empty-stratum hello-system
diff --git a/tests.build/empty-stratum.stderr b/tests.build/empty-stratum.stderr
new file mode 100644
index 00000000..d8c9bf28
--- /dev/null
+++ b/tests.build/empty-stratum.stderr
@@ -0,0 +1 @@
+ERROR: Stratum hello-stratum is empty (has no dependencies)