diff options
author | Lars Wirzenius <liw@liw.fi> | 2011-08-22 17:20:03 +0100 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2011-08-22 17:20:03 +0100 |
commit | 81fab08682f9f442027021551403636943a0fa28 (patch) | |
tree | f30fc2926a65f8a2d30c17490d3ec725dbe8c7b6 | |
parent | 3440a71bc3a9193c6ce48f30c58055b74c7c3e1c (diff) | |
download | cmdtest-81fab08682f9f442027021551403636943a0fa28.tar.gz |
Run foo.script instead of using foo.args, when script exists.
-rwxr-xr-x | cmdtest | 10 | ||||
-rw-r--r-- | cmdtest.py | 6 | ||||
-rwxr-xr-x | sort-tests/empty.script | 3 |
3 files changed, 13 insertions, 6 deletions
@@ -101,6 +101,7 @@ class CommandTester(cliapp.Application): def add_to_env(self): env = dict(os.environ) env['DATADIR'] = self.datadir + env['COMMAND'] = self.settings['command'] return env def run_test(self, test): @@ -108,9 +109,12 @@ class CommandTester(cliapp.Application): self.run_script(test.setup) - argv = [self.settings['command']] - if test.args: - argv.extend(self.expand(self.lines(test.args))) + if test.script: + argv = [test.script] + else: + argv = [self.settings['command']] + if test.args: + argv.extend(self.expand(self.lines(test.args))) stdin = self.cat(test.stdin or '/dev/null') exit, out, err = self.runcmd_unchecked(argv, @@ -30,8 +30,8 @@ class TestDir(object): '''Contain information about a directory of test cases.''' - per_test_suffixes = ('args', 'stdin', 'stdout', 'stderr', 'exit', - 'setup', 'teardown') + per_test_suffixes = ('args', 'script', 'stdin', 'stdout', 'stderr', + 'exit', 'setup', 'teardown') def __init__(self): self.setup = None @@ -41,7 +41,7 @@ class TestDir(object): self.teardown_once = None def scan(self, dirname, filenames=None): - filenames = filenames or os.listdir(dirname) + filenames = os.listdir(dirname) if filenames is None else filenames script_names = ['setup_once', 'setup', 'teardown', 'teardown_once'] for name in script_names: diff --git a/sort-tests/empty.script b/sort-tests/empty.script new file mode 100755 index 0000000..fcd5074 --- /dev/null +++ b/sort-tests/empty.script @@ -0,0 +1,3 @@ +#!/bin/sh +set -e +sort "$@" |