summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README19
-rwxr-xr-xcmdtest12
-rw-r--r--cmdtestlib.py2
-rw-r--r--cmdtestlib_tests.py6
-rwxr-xr-xecho-tests/hello.script2
-rwxr-xr-xsort-tests/empty.script2
-rw-r--r--sort-tests/single-line.script3
7 files changed, 13 insertions, 33 deletions
diff --git a/README b/README
index 200c322..0383b27 100644
--- a/README
+++ b/README
@@ -12,10 +12,7 @@ standard output.
Each test case consists of:
-* a set of command line arguments, not including the command name (`foo.args`)
- - each argument is on its own line
-* alternatively, a script to run the command, in case that's easier
- (`foo.script`)
+* a script to run the test (`foo.script`)
* the file fed to standard input (`foo.stdin`)
* the expected output to the standard output (`foo.stdout`)
* the expected output to the standard error (`foo.stderr`)
@@ -38,8 +35,7 @@ or several such directories, and it does the following:
* for each test case (unique prefix `foo`):
- execute `setup`
- execute `foo.setup`
- - execute the command, giving it command line arguments from
- `foo.args`, or by running `foo.script`,
+ - execute the command, by running `foo.script`,
and redirecting standard input to come from `foo.stdin`
- capture standard output and error and exit codes
- execute `foo.teardown`
@@ -54,18 +50,7 @@ error files is missing, it is treated as if it were empty. If the
exit code file is missing, it is treated as if it specified an exit
code of zero.
-The actual command is given to `cmdtest` separately. This allows
-testing various implementations of the same command, for example
-various checksum utilities, or different versions of the same command.
-If `foo.args` would hardcode the command name, this would be hard
-to achieve.
-
The shell scripts may use the following environment variables:
* `DATADIR`: a temporary directory where files may be created by the test
-* `COMMAND`: the command to be run; it is an absolute pathname
-
-In addition, the `foo.args` files can use Pythonic string expansion:
-
-* `%(datadir)s` for the same value as `$DATADIR`
diff --git a/cmdtest b/cmdtest
index fc362ef..e40c7b7 100755
--- a/cmdtest
+++ b/cmdtest
@@ -44,17 +44,12 @@ class CommandTester(cliapp.Application):
def add_settings(self):
self.settings.string(['command', 'c'],
- 'test COMMAND (executable name/path; $PATH is '
- 'not searched, so give absolute path when '
- 'necessary)',
- metavar='COMMAND',
- default=None)
+ 'ignored for backwards compatibility')
self.settings.string_list(['test', 't'],
'run only TEST (can be given many times)',
metavar='TEST')
def process_args(self, dirnames):
- self.settings.require('command')
self.setup_ttystatus()
td = self.load_tests(dirnames)
@@ -122,7 +117,6 @@ class CommandTester(cliapp.Application):
env = dict(os.environ)
env['SRCDIR'] = os.getcwd()
env['DATADIR'] = self.datadir
- env['COMMAND'] = os.path.abspath(self.settings['command'])
return env
def run_test(self, test):
@@ -133,9 +127,7 @@ class CommandTester(cliapp.Application):
if test.script:
argv = [test.script]
else:
- argv = [self.settings['command']]
- if test.args:
- argv.extend(self.expand(self.lines(test.args)))
+ raise cliapp.AppException('Must have a .script file for test')
stdout_name = test.path_prefix + '.stdout-actual'
stderr_name = test.path_prefix + '.stderr-actual'
diff --git a/cmdtestlib.py b/cmdtestlib.py
index 29f7132..9d84e70 100644
--- a/cmdtestlib.py
+++ b/cmdtestlib.py
@@ -31,7 +31,7 @@ class TestDir(object):
'''Contain information about a directory of test cases.'''
- per_test_suffixes = ('args', 'script', 'stdin', 'stdout', 'stderr',
+ per_test_suffixes = ('script', 'stdin', 'stdout', 'stderr',
'exit', 'setup', 'teardown')
def __init__(self):
diff --git a/cmdtestlib_tests.py b/cmdtestlib_tests.py
index 90318b6..a49cdad 100644
--- a/cmdtestlib_tests.py
+++ b/cmdtestlib_tests.py
@@ -42,11 +42,11 @@ class TestDirTests(unittest.TestCase):
def test_finds_tests(self):
td = TestDir()
- td.scan('tests', filenames=['foo.args'])
+ td.scan('tests', filenames=['foo.script'])
self.assertEqual(len(td.tests), 1)
test = td.tests[0]
self.assertEqual(test.name, 'foo')
- self.assertEqual(test.args, 'tests/foo.args')
+ self.assertEqual(test.script, 'tests/foo.script')
self.assertEqual(test.stdin, None)
def test_finds_no_prefixes_when_there_are_none(self):
@@ -59,6 +59,6 @@ class TestDirTests(unittest.TestCase):
def test_finds_two_prefixes(self):
td = TestDir()
- self.assertEqual(td.find_prefixes(['setup', 'foo.setup', 'bar.args']),
+ self.assertEqual(td.find_prefixes(['setup', 'foo.setup', 'bar.script']),
['bar', 'foo'])
diff --git a/echo-tests/hello.script b/echo-tests/hello.script
index ecb8481..9b24f76 100755
--- a/echo-tests/hello.script
+++ b/echo-tests/hello.script
@@ -1,2 +1,2 @@
#!/bin/sh
-$COMMAND hello, world
+echo hello, world
diff --git a/sort-tests/empty.script b/sort-tests/empty.script
index 7b51379..fcd5074 100755
--- a/sort-tests/empty.script
+++ b/sort-tests/empty.script
@@ -1,3 +1,3 @@
#!/bin/sh
set -e
-$COMMAND "$@"
+sort "$@"
diff --git a/sort-tests/single-line.script b/sort-tests/single-line.script
new file mode 100644
index 0000000..fcd5074
--- /dev/null
+++ b/sort-tests/single-line.script
@@ -0,0 +1,3 @@
+#!/bin/sh
+set -e
+sort "$@"