summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2013-08-25 13:54:49 +0100
committerLars Wirzenius <liw@liw.fi>2013-08-25 13:54:49 +0100
commit7cba7b30e615e627984047b00cdd0de0b201efb5 (patch)
treee1defd838871bfc02be411270b7209b82c99ccd1
parentba82e75356b37ff7e248b984ca8484c9cd6d6141 (diff)
downloadcmdtest-7cba7b30e615e627984047b00cdd0de0b201efb5.tar.gz
Check there are scenarios
-rw-r--r--NEWS3
-rwxr-xr-xyarn6
-rw-r--r--yarn.tests/no-scenarios.exit1
-rwxr-xr-xyarn.tests/no-scenarios.script9
-rw-r--r--yarn.tests/no-scenarios.stderr1
5 files changed, 20 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index 67d870f..a57a186 100644
--- a/NEWS
+++ b/NEWS
@@ -21,6 +21,9 @@ Bug fixes:
* Yarn now complains if a scenario has no THEN steps. Suggested by
Richard Maw.
+* Yarn now gives an error if there are no scenarios. Suggested by
+ Daniel Silverstone and others.
+
* Yarn now checks for duplicate scenario names.
Version 0.9, released 2013-07-23
diff --git a/yarn b/yarn
index 3e9be0d..a84fcd4 100755
--- a/yarn
+++ b/yarn
@@ -109,6 +109,7 @@ class YarnRunner(cliapp.Application):
'step %Index(step,steps): %String(step_name)')
scenarios, implementations = self.parse_scenarios(args)
+ self.check_there_are_scenarios(scenarios)
self.check_for_duplicate_scenario_names(scenarios)
self.check_for_thens(scenarios)
self.connect_implementations(scenarios, implementations)
@@ -160,6 +161,11 @@ class YarnRunner(cliapp.Application):
return block_parser.scenarios, block_parser.implementations
+ def check_there_are_scenarios(self, scenarios):
+ if not scenarios:
+ raise cliapp.AppException(
+ 'There are no scenarios; must have at least one.')
+
def check_for_duplicate_scenario_names(self, scenarios):
counts = collections.Counter()
for s in scenarios:
diff --git a/yarn.tests/no-scenarios.exit b/yarn.tests/no-scenarios.exit
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/yarn.tests/no-scenarios.exit
@@ -0,0 +1 @@
+1
diff --git a/yarn.tests/no-scenarios.script b/yarn.tests/no-scenarios.script
new file mode 100755
index 0000000..ffd8e96
--- /dev/null
+++ b/yarn.tests/no-scenarios.script
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+set -eu
+
+
+cat <<EOF > "$DATADIR/test.yarn"
+EOF
+
+./run-yarn "$DATADIR/test.yarn"
diff --git a/yarn.tests/no-scenarios.stderr b/yarn.tests/no-scenarios.stderr
new file mode 100644
index 0000000..66311c1
--- /dev/null
+++ b/yarn.tests/no-scenarios.stderr
@@ -0,0 +1 @@
+ERROR: There are no scenarios; must have at least one.