summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2013-06-24 07:28:09 +0100
committerLars Wirzenius <liw@liw.fi>2013-06-24 07:28:09 +0100
commit4ce58c929fca65fa4911284b42591fe96f1b5fcb (patch)
tree39eb3b259906824d9cb54c3840c7ad95c332b88c
parentf19995c71815be55e57fd3425a999da49471756d (diff)
parent9ec5b1094362c445766e904a9b2180bed24100b4 (diff)
downloadcmdtest-4ce58c929fca65fa4911284b42591fe96f1b5fcb.tar.gz
Merge branch 'liw/yarn-no-act'
-rwxr-xr-xyarn29
-rwxr-xr-xyarn.tests/no-act.script22
2 files changed, 44 insertions, 7 deletions
diff --git a/yarn b/yarn
index fdf81a0..66f9bb7 100755
--- a/yarn
+++ b/yarn
@@ -32,12 +32,22 @@ import yarnlib
class YarnRunner(cliapp.Application):
+ def add_settings(self):
+ self.settings.boolean(
+ ['no-act', 'dry-run', 'pretend', 'n'],
+ 'do not actually run any tests, merely print what would be run')
+
+ self.settings.boolean(
+ ['quiet', 'q'],
+ 'be quiet, avoid progress reporting, only show errors')
+
def setup(self):
self.ts = ttystatus.TerminalStatus(period=0.001)
- self.ts.format(
- '%ElapsedTime() %Index(scenario,scenarios): '
- '%String(scenario_name): '
- 'step %Index(step,steps): %String(step_name)')
+ if not self.settings['quiet']:
+ self.ts.format(
+ '%ElapsedTime() %Index(scenario,scenarios): '
+ '%String(scenario_name): '
+ 'step %Index(step,steps): %String(step_name)')
def process_args(self, args):
scenarios, implementations = self.parse_scenarios(args)
@@ -61,9 +71,11 @@ class YarnRunner(cliapp.Application):
raise cliapp.AppException(
'Test suite FAILED in %s scenarios' % len(failed_scenarios))
- print (
- 'Scenario test suite PASS, with %d scenarios, in %.1f seconds' %
- (len(scenarios), duration))
+ if not self.settings['quiet']:
+ print (
+ 'Scenario test suite PASS, with %d scenarios, '
+ 'in %.1f seconds' %
+ (len(scenarios), duration))
def parse_scenarios(self, filenames):
mdparser = yarnlib.MarkdownParser()
@@ -110,6 +122,9 @@ class YarnRunner(cliapp.Application):
self.ts['scenario_name'] = scenario.name
self.ts['steps'] = scenario.steps
+ if self.settings['no-act']:
+ return True
+
datadir = tempfile.mkdtemp()
cleanup = [s for s in scenario.steps if s.what == 'FINALLY']
diff --git a/yarn.tests/no-act.script b/yarn.tests/no-act.script
new file mode 100755
index 0000000..983f115
--- /dev/null
+++ b/yarn.tests/no-act.script
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+set -eu
+
+# Create a scenario that will fail.
+cat <<EOF > "$DATADIR/fail.yarn"
+ SCENARIO this will fail
+ GIVEN badness
+ WHEN bad things happen
+ THEN more badness
+
+ IMPLEMENTS GIVEN badness
+ false
+
+ IMPLEMENTS WHEN bad things happen
+ false
+
+ IMPLEMENTS THEN more badness
+ false
+EOF
+
+./yarn -q -n "$DATADIR/fail.yarn"