diff options
-rwxr-xr-x | yarn | 36 | ||||
-rw-r--r-- | yarn.tests/simple.exit | 1 | ||||
-rw-r--r-- | yarn.tests/simple.stderr | 7 |
3 files changed, 21 insertions, 23 deletions
@@ -19,16 +19,12 @@ import cliapp import logging -import markdown import os import re import shutil -import StringIO -import sys import tempfile import time import ttystatus -from markdown.treeprocessors import Treeprocessor import yarnlib @@ -42,11 +38,7 @@ class StoryTestRunner(cliapp.Application): 'step %Index(step,steps): %String(step_name)') def process_args(self, args): - blocks = [] - for filename in args: - blocks.extend(self.parse_story_test_code_blocks(filename)) - - stories, implementations = self.create_objects_from_code_blocks(blocks) + stories, implementations = self.parse_stories(args) self.connect_implementations(stories, implementations) self.ts['stories'] = stories @@ -58,6 +50,7 @@ class StoryTestRunner(cliapp.Application): for story in stories: if not self.run_story(story): failed_stories.append(story) + duration = time.time() - start_time self.ts.clear() self.ts.finish() @@ -66,21 +59,18 @@ class StoryTestRunner(cliapp.Application): raise cliapp.AppException( 'Test suite FAILED in %s stories' % len(failed_stories)) - duration = time.time() - start_time print ('Story test suite PASS, with %d stories, in %.1f seconds' % (len(stories), duration)) - def parse_story_test_code_blocks(self, filename): - logging.info('Parsing story test file %s' % filename) - ext = ParseStoryTestBlocks() - f = StringIO.StringIO() - markdown.markdownFromFile(filename, output=f, extensions=[ext]) - return ext.blocks + def parse_stories(self, filenames): + mdparser = yarnlib.MarkdownParser() + for filename in filenames: + mdparser.parse_file(filename) - def create_objects_from_code_blocks(self, blocks): - cp = CodeBlockParser() - cp.parse(blocks) - return cp.stories, cp.implementations + block_parser = yarnlib.BlockParser() + block_parser.parse_blocks(mdparser.blocks) + + return block_parser.stories, block_parser.implementations def connect_implementations(self, stories, implementations): for story in stories: @@ -93,15 +83,15 @@ class StoryTestRunner(cliapp.Application): re.match('(%s)$' % i.regexp, step.text, re.I)] if len(matching) == 0: - raise StoryTestSyntaxError( - 'Error: Story %s, step "%s %s" has no matching ' + raise cliapp.AppException( + 'Story %s, step "%s %s" has no matching ' 'implementation' % (story.name, step.what, step.text)) if len(matching) > 1: s = '\n'.join( 'IMPLEMENTS %s %s' % (i.what, i.regexp) for i in matching) - raise StoryTestSyntaxError( + raise cliapp.AppException( 'Story "%s", step "%s %s" has more than one ' 'matching implementations:\n%s' % (story.name, step.what, step.text, s)) diff --git a/yarn.tests/simple.exit b/yarn.tests/simple.exit new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/yarn.tests/simple.exit @@ -0,0 +1 @@ +1 diff --git a/yarn.tests/simple.stderr b/yarn.tests/simple.stderr new file mode 100644 index 0000000..db4fde4 --- /dev/null +++ b/yarn.tests/simple.stderr @@ -0,0 +1,7 @@ +ERROR: In story "a simple story" +step "THEN not all is well" failed, +with exit code 1: +Standard output from shell command: +Standard error from shell command: + +ERROR: Test suite FAILED in 1 stories |