[cig-commits] r13560 - cs/cigma/trunk/tests/system
luis at geodynamics.org
luis at geodynamics.org
Tue Dec 9 18:14:21 PST 2008
Author: luis
Date: 2008-12-09 18:14:21 -0800 (Tue, 09 Dec 2008)
New Revision: 13560
Modified:
cs/cigma/trunk/tests/system/runner.py
Log:
Changed runner to only consider executable files
Modified: cs/cigma/trunk/tests/system/runner.py
===================================================================
--- cs/cigma/trunk/tests/system/runner.py 2008-12-10 02:14:19 UTC (rev 13559)
+++ cs/cigma/trunk/tests/system/runner.py 2008-12-10 02:14:21 UTC (rev 13560)
@@ -6,36 +6,43 @@
import sys, os
from os.path import abspath, dirname, splitext, join
- root = dirname(abspath(__file__))
- #print os.listdir(root)
-
- err = 0
stream = sys.stdout
+ stream.write('\n')
+ # Available shells and their file extensions
bash = '/bin/bash'
python = os.environ.get('PYTHON', 'python')
+ shells = {'.sh': bash, '.py': python}
+ # Determine which test files to consider running
+ root = dirname(abspath(__file__))
tests = [ t for t in os.listdir(root) if t != 'runner.py' ]
tests.sort()
- stream.write('\n')
-
+
+ # Now, actually run the tests
for t in tests:
+ # obtain extension and full path to the test file
base, ext = splitext(t)
test = join(root, t)
- # run test
- if ext in ('.sh', '.py'):
- stream.write('Running system test %s: ' % base)
+
+ # determine shell from test extension
+ shell = shells.get(ext)
+ if not shell:
+ continue
+
+ # check that the test is executable
+ if not os.access(test, os.X_OK):
+ stream.write('Skipped %s\n' % t)
stream.flush()
- if test.endswith('.sh'):
- err = 0
- #err = os.system('%s %s' % (bash, test))
- elif test.endswith('.py'):
- err = 0
- #err = os.system('%s %s' % (python, test))
- else:
continue
- # report result
+
+ # run the test using given shell
+ stream.write('Running system test %s: ' % base)
+ stream.flush()
+ err = os.system('%s %s' % (shell, test))
+
+ # report result, and skip out if we reach an error
if err == 0:
stream.write('OK\n')
else:
More information about the CIG-COMMITS
mailing list