diff options
author | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2012-01-20 18:19:21 +0000 |
---|---|---|
committer | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2012-01-20 18:19:21 +0000 |
commit | 1a62be25fbffd09d1cf1797c4a65e376f37a2156 (patch) | |
tree | b663986d1afc2a0029a3de3752d1fcd1ae478288 | |
parent | 1bec9bee0c3105430a51ced2771e130066019c95 (diff) | |
download | cmdtest-1a62be25fbffd09d1cf1797c4a65e376f37a2156.tar.gz |
Fix cmdtest -t foo so that it still runs the setup/setup_once/teardown/teardown_once scripts
-rwxr-xr-x | cmdtest | 2 | ||||
-rw-r--r-- | cmdtestlib.py | 5 | ||||
-rwxr-xr-x | echo-tests/hello.setup | 3 | ||||
-rwxr-xr-x | echo-tests/setup_once | 4 |
4 files changed, 12 insertions, 2 deletions
@@ -107,6 +107,8 @@ class CommandTester(cliapp.Application): shutil.rmtree(self.tempdir) def run_script(self, test_name, script_name): + logging.debug('run_script: test_name=%s script_name=%s' % + (test_name, script_name)) if script_name: self.runcmd([script_name], env=self.add_to_env(test_name)) diff --git a/cmdtestlib.py b/cmdtestlib.py index a42b459..a064cbc 100644 --- a/cmdtestlib.py +++ b/cmdtestlib.py @@ -46,8 +46,9 @@ class TestDir(object): script_names = ['setup_once', 'setup', 'teardown', 'teardown_once'] for name in script_names: - if name in filenames: - setattr(self, name, os.path.join(dirname, name)) + full_path = os.path.join(dirname, name) + if os.path.exists(full_path): + setattr(self, name, full_path) prefixes = self.find_prefixes(filenames) for prefix in prefixes: diff --git a/echo-tests/hello.setup b/echo-tests/hello.setup new file mode 100755 index 0000000..55c29a9 --- /dev/null +++ b/echo-tests/hello.setup @@ -0,0 +1,3 @@ +#!/bin/sh + +echo "hello.setup runs" diff --git a/echo-tests/setup_once b/echo-tests/setup_once new file mode 100755 index 0000000..19c5bba --- /dev/null +++ b/echo-tests/setup_once @@ -0,0 +1,4 @@ +#!/bin/sh + +echo "setup-once runs" + |