summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2013-08-25 13:39:20 +0100
committerLars Wirzenius <liw@liw.fi>2013-08-25 13:39:20 +0100
commitce2e4e11192adcfe9862a8ab4cd18dc9e6a7f339 (patch)
tree265e9d917eafbe8c6782e292cb25633507800a5b
parenta3bfd4de13e415c3c8267762311340579967cbbb (diff)
parent736c408ac2b8768150867b89f4a497edcffd2edd (diff)
downloadcmdtest-ce2e4e11192adcfe9862a8ab4cd18dc9e6a7f339.tar.gz
Merge branch 'liw/check-for-scenario-names'
-rw-r--r--NEWS4
-rwxr-xr-xyarn13
-rw-r--r--yarn.tests/duplicate-scenario-names.exit1
-rwxr-xr-xyarn.tests/duplicate-scenario-names.script18
-rw-r--r--yarn.tests/duplicate-scenario-names.stderr3
5 files changed, 39 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index 92c1e37..2682b85 100644
--- a/NEWS
+++ b/NEWS
@@ -14,9 +14,13 @@ Version 0.10, released UNRELEASED
* A new option, `--timings`, has been added to yarn to report how long
each scenario and each step took.
+Bug fixes:
+
* Yarn now complains if a scenario has no THEN steps. Suggested by
Richard Maw.
+* Yarn now checks for duplicate scenario names.
+
Version 0.9, released 2013-07-23
--------------------------------
diff --git a/yarn b/yarn
index 3bb26e8..c13681b 100755
--- a/yarn
+++ b/yarn
@@ -18,6 +18,7 @@
import cliapp
+import collections
import logging
import os
import re
@@ -108,6 +109,7 @@ class YarnRunner(cliapp.Application):
'step %Index(step,steps): %String(step_name)')
scenarios, implementations = self.parse_scenarios(args)
+ self.check_for_duplicate_scenario_names(scenarios)
self.check_for_thens(scenarios)
self.connect_implementations(scenarios, implementations)
shell_prelude = self.load_shell_libraries()
@@ -158,6 +160,17 @@ class YarnRunner(cliapp.Application):
return block_parser.scenarios, block_parser.implementations
+ def check_for_duplicate_scenario_names(self, scenarios):
+ counts = collections.Counter()
+ for s in scenarios:
+ counts[s.name] += 1
+
+ duplicates = [name for name in counts if counts[name] > 1]
+ if duplicates:
+ duplist = ''.join(' %s\n' % name for name in duplicates)
+ raise cliapp.AppException(
+ 'There are scenarios with duplicate names:\n%s' % duplist)
+
def check_for_thens(self, scenarios):
no_thens = []
for scenario in scenarios:
diff --git a/yarn.tests/duplicate-scenario-names.exit b/yarn.tests/duplicate-scenario-names.exit
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/yarn.tests/duplicate-scenario-names.exit
@@ -0,0 +1 @@
+1
diff --git a/yarn.tests/duplicate-scenario-names.script b/yarn.tests/duplicate-scenario-names.script
new file mode 100755
index 0000000..770f00a
--- /dev/null
+++ b/yarn.tests/duplicate-scenario-names.script
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+set -eu
+
+
+cat <<EOF > "$DATADIR/test.yarn"
+ SCENARIO foo
+ THEN nop
+
+ SCENARIO foo
+ THEN nop
+
+ IMPLEMENTS THEN nop
+ true
+EOF
+
+./run-yarn "$DATADIR/test.yarn"
+
diff --git a/yarn.tests/duplicate-scenario-names.stderr b/yarn.tests/duplicate-scenario-names.stderr
new file mode 100644
index 0000000..d3fbc95
--- /dev/null
+++ b/yarn.tests/duplicate-scenario-names.stderr
@@ -0,0 +1,3 @@
+ERROR: There are scenarios with duplicate names:
+ foo
+