summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <lars.wirzenius@codethink.co.uk>2012-01-20 18:19:21 +0000
committerLars Wirzenius <lars.wirzenius@codethink.co.uk>2012-01-20 18:19:21 +0000
commit1a62be25fbffd09d1cf1797c4a65e376f37a2156 (patch)
treeb663986d1afc2a0029a3de3752d1fcd1ae478288
parent1bec9bee0c3105430a51ced2771e130066019c95 (diff)
downloadcmdtest-1a62be25fbffd09d1cf1797c4a65e376f37a2156.tar.gz
Fix cmdtest -t foo so that it still runs the setup/setup_once/teardown/teardown_once scripts
-rwxr-xr-xcmdtest2
-rw-r--r--cmdtestlib.py5
-rwxr-xr-xecho-tests/hello.setup3
-rwxr-xr-xecho-tests/setup_once4
4 files changed, 12 insertions, 2 deletions
diff --git a/cmdtest b/cmdtest
index d2c682e..8c6e4a3 100755
--- a/cmdtest
+++ b/cmdtest
@@ -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"
+