summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <lars.wirzenius@tilaajavastuu.fi>2015-02-10 10:23:17 +0200
committerLars Wirzenius <liw@liw.fi>2015-02-10 10:30:51 +0200
commit19e090549b933c31aeb057e59825a8c279e26e99 (patch)
treefe32c33dbaca33a143ffe2de01a132ef792481c4
parentacd3d6316ef5831be1a9663a267b485767ada418 (diff)
downloadcmdtest-19e090549b933c31aeb057e59825a8c279e26e99.tar.gz
Implement continuation lines in yarn
-rw-r--r--simple.scenario3
-rw-r--r--yarnlib/block_parser.py8
-rw-r--r--yarnlib/block_parser_tests.py8
3 files changed, 18 insertions, 1 deletions
diff --git a/simple.scenario b/simple.scenario
index 8061e47..a244d88 100644
--- a/simple.scenario
+++ b/simple.scenario
@@ -9,7 +9,8 @@ the scenario test runner itself.
The following is the actual test in this scenario:
GIVEN a clean slate
- WHEN nothing happens
+ WHEN nothing
+ ... happens
THEN everything is OK
AND not all is well
FINALLY cleanup
diff --git a/yarnlib/block_parser.py b/yarnlib/block_parser.py
index 64dc990..db99b31 100644
--- a/yarnlib/block_parser.py
+++ b/yarnlib/block_parser.py
@@ -42,6 +42,7 @@ class BlockParser(object):
'THEN': self.parse_then,
'FINALLY': self.parse_finally,
'AND': self.parse_and,
+ '...': self.parse_continuation,
'IMPLEMENTS': self.parse_implementing,
}
@@ -113,6 +114,13 @@ class BlockParser(object):
assert step.what in self.line_parsers
return self.line_parsers[step.what](line, blocks)
+ def parse_continuation(self, line, blocks):
+ scenario = self.scenarios[-1]
+ step = scenario.steps[-1]
+ text = '%s %s' % (step.text, line)
+ del scenario.steps[-1]
+ return self.line_parsers[step.what](text, blocks)
+
def parse_implementing(self, line, blocks):
words = line.split()
if len(words) < 2:
diff --git a/yarnlib/block_parser_tests.py b/yarnlib/block_parser_tests.py
index 78754b5..689a197 100644
--- a/yarnlib/block_parser_tests.py
+++ b/yarnlib/block_parser_tests.py
@@ -54,6 +54,14 @@ class BlockParserTests(unittest.TestCase):
self.assertEqual(scenario.steps[5].what, 'FINALLY')
self.assertEqual(scenario.steps[5].text, 'yeehaa')
+ def test_handles_continuation_line(self):
+ self.parser.parse_blocks(['SCENARIO foo', 'GIVEN foo', '... and bar'])
+ scenario = self.parser.scenarios[0]
+ self.assertEqual(len(self.parser.scenarios), 1)
+ self.assertEqual(scenario.name, 'foo')
+ self.assertEqual(scenario.steps[0].what, 'GIVEN')
+ self.assertEqual(scenario.steps[0].text, 'foo and bar')
+
def test_normalises_whitespace(self):
self.parser.parse_blocks(['SCENARIO foo bar '])
self.assertEqual(self.parser.scenarios[0].name, 'foo bar')