diff options
author | Lars Wirzenius <liw@liw.fi> | 2013-06-24 07:26:11 +0100 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2013-06-24 07:26:11 +0100 |
commit | 9ec5b1094362c445766e904a9b2180bed24100b4 (patch) | |
tree | 39eb3b259906824d9cb54c3840c7ad95c332b88c | |
parent | f19995c71815be55e57fd3425a999da49471756d (diff) | |
download | cmdtest-9ec5b1094362c445766e904a9b2180bed24100b4.tar.gz |
Add -n and -q options
-rwxr-xr-x | yarn | 29 | ||||
-rwxr-xr-x | yarn.tests/no-act.script | 22 |
2 files changed, 44 insertions, 7 deletions
@@ -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" |