summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2013-07-04 09:56:14 +0100
committerLars Wirzenius <liw@liw.fi>2013-07-04 09:56:14 +0100
commit2aab9e3b752d94197ab24af876ee3ae857c3ede9 (patch)
tree1f13cb9acfa247a8e4062936bd253ab775015131
parent8ed4d0938be659cc1a618ee74a9882bdad83dd74 (diff)
parent75872df928343eec7c3dba179c88c4ac3cd67ae7 (diff)
downloadcmdtest-2aab9e3b752d94197ab24af876ee3ae857c3ede9.tar.gz
Merge branch 'liw/selected-tests'
-rw-r--r--NEWS6
-rwxr-xr-xyarn26
-rwxr-xr-xyarn.tests/selected-test.script18
3 files changed, 47 insertions, 3 deletions
diff --git a/NEWS b/NEWS
index aba468c..c948376 100644
--- a/NEWS
+++ b/NEWS
@@ -7,9 +7,11 @@ Version 0.X, released UNRELEASED
--------------------------------
* Yarn now warns if an input file has no code blocks.
-* There is no a `--shell-library` option for the user to use, which
+* There is no a yarn `--shell-library` option for the user to use, which
includes a shell library when running any IMPLEMENTS section.
-* FINALLY always worked, but has now been added to the manual page as well.
+* FINALLY always worked in yarn, but has now been added to the manual
+ page as well.
+* New yarn option `--run` allows running selected tests only.
Bug fixes:
diff --git a/yarn b/yarn
index 8d19b68..e3ed242 100755
--- a/yarn
+++ b/yarn
@@ -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"