summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2013-06-23 09:27:14 +0100
committerLars Wirzenius <liw@liw.fi>2013-06-23 09:27:14 +0100
commitc54bcf443bb1243d9cb14fef598b3901dd66f51e (patch)
tree91eae72a0b700fd632da5329e250a9afc461920e
parentbec45232f5775bc934a638e3095ac77f78176708 (diff)
downloadcmdtest-c54bcf443bb1243d9cb14fef598b3901dd66f51e.tar.gz
Add warning when an input file has no scenario code blocks
-rwxr-xr-xyarn4
-rwxr-xr-xyarn.tests/warn-if-empty.script10
2 files changed, 13 insertions, 1 deletions
diff --git a/yarn b/yarn
index d9b2b47..fdf81a0 100755
--- a/yarn
+++ b/yarn
@@ -68,7 +68,9 @@ class YarnRunner(cliapp.Application):
def parse_scenarios(self, filenames):
mdparser = yarnlib.MarkdownParser()
for filename in filenames:
- mdparser.parse_file(filename)
+ blocks = mdparser.parse_file(filename)
+ if not blocks:
+ logging.warning('No scenario code blocks in %s' % filename)
block_parser = yarnlib.BlockParser()
block_parser.parse_blocks(mdparser.blocks)
diff --git a/yarn.tests/warn-if-empty.script b/yarn.tests/warn-if-empty.script
new file mode 100755
index 0000000..7a5c028
--- /dev/null
+++ b/yarn.tests/warn-if-empty.script
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+set -eu
+
+touch "$DATADIR/empty.yarn"
+
+# The grep below will fail unless the string exists, thereby failing the
+# entire test.
+./yarn --log=/dev/stdout "$DATADIR/empty.yarn" |
+ grep 'No scenario code blocks' > /dev/null