summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2013-08-19 18:53:54 +0100
committerLars Wirzenius <liw@liw.fi>2013-08-19 18:53:54 +0100
commita3bfd4de13e415c3c8267762311340579967cbbb (patch)
tree834cc989d7a225bd34f0b1060921d4d97490924d
parent3ca820dce1960509a29688f170538cb4ca5ac577 (diff)
downloadcmdtest-a3bfd4de13e415c3c8267762311340579967cbbb.tar.gz
Complain if a scenario has no THENs
-rw-r--r--NEWS3
-rwxr-xr-xyarn15
-rw-r--r--yarn.tests/no-then.exit1
-rwxr-xr-xyarn.tests/no-then.script14
-rw-r--r--yarn.tests/no-then.stderr3
5 files changed, 36 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index 35bbc38..92c1e37 100644
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,9 @@ Version 0.10, released UNRELEASED
* A new option, `--timings`, has been added to yarn to report how long
each scenario and each step took.
+* Yarn now complains if a scenario has no THEN steps. Suggested by
+ Richard Maw.
+
Version 0.9, released 2013-07-23
--------------------------------
diff --git a/yarn b/yarn
index ce0b9cb..3bb26e8 100755
--- a/yarn
+++ b/yarn
@@ -108,6 +108,7 @@ class YarnRunner(cliapp.Application):
'step %Index(step,steps): %String(step_name)')
scenarios, implementations = self.parse_scenarios(args)
+ self.check_for_thens(scenarios)
self.connect_implementations(scenarios, implementations)
shell_prelude = self.load_shell_libraries()
@@ -157,6 +158,20 @@ class YarnRunner(cliapp.Application):
return block_parser.scenarios, block_parser.implementations
+ def check_for_thens(self, scenarios):
+ no_thens = []
+ for scenario in scenarios:
+ for step in scenario.steps:
+ if step.what == 'THEN':
+ break
+ else:
+ no_thens.append(scenario)
+
+ if no_thens:
+ raise cliapp.AppException(
+ 'Some scenarios have no THENs:\n%s' %
+ ''.join(' "%s"\n' % s.name for s in scenarios))
+
def connect_implementations(self, scenarios, implementations):
for scenario in scenarios:
for step in scenario.steps:
diff --git a/yarn.tests/no-then.exit b/yarn.tests/no-then.exit
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/yarn.tests/no-then.exit
@@ -0,0 +1 @@
+1
diff --git a/yarn.tests/no-then.script b/yarn.tests/no-then.script
new file mode 100755
index 0000000..491853f
--- /dev/null
+++ b/yarn.tests/no-then.script
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+set -eu
+
+
+cat <<EOF > "$DATADIR/1.yarn"
+ SCENARIO foo
+ WHEN doing ok
+
+ IMPLEMENTS WHEN doing ok
+ true
+EOF
+
+./run-yarn "$DATADIR/1.yarn"
diff --git a/yarn.tests/no-then.stderr b/yarn.tests/no-then.stderr
new file mode 100644
index 0000000..b018036
--- /dev/null
+++ b/yarn.tests/no-then.stderr
@@ -0,0 +1,3 @@
+ERROR: Some scenarios have no THENs:
+ "foo"
+