diff options
author | Lars Wirzenius <liw@liw.fi> | 2013-07-04 09:54:58 +0100 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2013-07-04 09:54:58 +0100 |
commit | d81b2d06aaab36bf53f89a8785eaaf635995be6f (patch) | |
tree | 50773ca5abcb1a976f91e97b59eb361fb3379969 | |
parent | 8ed4d0938be659cc1a618ee74a9882bdad83dd74 (diff) | |
download | cmdtest-d81b2d06aaab36bf53f89a8785eaaf635995be6f.tar.gz |
Run selected tests only
-rwxr-xr-x | yarn | 26 | ||||
-rwxr-xr-x | yarn.tests/selected-test.script | 18 |
2 files changed, 43 insertions, 1 deletions
@@ -45,6 +45,11 @@ class YarnRunner(cliapp.Application): ['shell-library', 's'], 'include a shell library for the IMPLEMENTS sections to use') + self.settings.string_list( + ['run', 'r'], + 'run only TEST (this option can be repeated)', + metavar='TEST') + def setup(self): self.ts = ttystatus.TerminalStatus(period=0.001) if not self.settings['quiet']: @@ -64,7 +69,7 @@ class YarnRunner(cliapp.Application): start_time = time.time() failed_scenarios = [] - for scenario in scenarios: + for scenario in self.select_scenarios(scenarios): if not self.run_scenario(scenario, shell_prelude): failed_scenarios.append(scenario) duration = time.time() - start_time @@ -137,6 +142,25 @@ class YarnRunner(cliapp.Application): return ''.join(libs) + def select_scenarios(self, scenarios): + + def normalise(s): + return ' '.join(s.lower().split()) + + def matches(a, b): + return normalise(a) == normalise(b) + + if self.settings['run']: + result = [] + for name in self.settings['run']: + for s in scenarios: + if matches(s.name, name) and s not in result: + result.append(s) + break + return result + + return scenarios + def run_scenario(self, scenario, shell_prelude): logging.info('Running scenario %s' % scenario.name) self.ts['scenario'] = scenario diff --git a/yarn.tests/selected-test.script b/yarn.tests/selected-test.script new file mode 100755 index 0000000..69c1679 --- /dev/null +++ b/yarn.tests/selected-test.script @@ -0,0 +1,18 @@ +#!/bin/sh + +set -eu + +cat << EOF > "$DATADIR/test.yarn" + SCENARIO bar test + THEN do bar + + SCENARIO foo test + THEN do foo + + IMPLEMENTS THEN do (.*) + touch "$DATADIR/\$MATCH_1" +EOF + +./yarn -q "$DATADIR/test.yarn" --run 'foo test' +test -e "$DATADIR/foo" +! test -e "$DATADIR/bar" |