Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Silbe <sascha@silbe.org>2009-11-06 19:18:22 (GMT)
committer Sascha Silbe <sascha@silbe.org>2009-11-06 19:18:22 (GMT)
commita417b8c3119a30d05918886e254f0454bc5fe845 (patch)
tree76c73c6a19ceab498d9e717148661703adeef6bf
parentb83d3b2bfaa078da8d222e100745eefe015d3da4 (diff)
add option "-k" / "--keep" to keep temporary files for inspection
-rwxr-xr-xtests/runalltests.py38
1 files changed, 26 insertions, 12 deletions
diff --git a/tests/runalltests.py b/tests/runalltests.py
index 93383bc..20c92cb 100755
--- a/tests/runalltests.py
+++ b/tests/runalltests.py
@@ -10,6 +10,7 @@ ones to run:
import doctest
import errno
import logging
+from optparse import OptionParser
import os
import os.path
import shutil
@@ -101,18 +102,19 @@ def wait_children():
raise
-def cleanup(home):
+def cleanup(home, keep_files):
"""Clean up test environment.
Kills all children and removes home directory.
"""
os.kill(0, signal.SIGTERM)
wait_children()
- # dbus-daemon spawns off a new process group and does not wait for
- # children on exit, so DBus services are still busy shutting down
- # even after wait_children() returns.
- # We need to cope with them deleting files behind our back.
- shutil.rmtree(home, ignore_errors=True)
+ if not keep_files:
+ # dbus-daemon spawns off a new process group and does not wait for
+ # children on exit, so DBus services are still busy shutting down
+ # even after wait_children() returns.
+ # We need to cope with them deleting files behind our back.
+ shutil.rmtree(home, ignore_errors=True)
class TestSuiteWrapper(unittest.TestCase):
@@ -258,21 +260,33 @@ def run_tests(tests):
return 10
+def _parse_options():
+ """Parse command line arguments."""
+ parser = OptionParser()
+ parser.add_option('-k', '--keep', dest='keep',
+ action='store_true', default=False,
+ help='Keep temporary files')
+ parser.add_option('', '--stage2', dest='stage2',
+ action='store_true', default=False,
+ help='For internal use only')
+ return parser.parse_args()
+
+
def main(my_name, arguments):
- if "--have-dbus" not in arguments:
+ options, tests = _parse_options()
+ if not options.stage2:
environment = setup()
try:
pipe = subprocess.Popen(['dbus-launch', '--exit-with-session',
- os.path.abspath(my_name), '--have-dbus']+arguments,
+ os.path.abspath(my_name), '--stage2']+arguments,
cwd=environment['HOME'], env=environment)
return pipe.wait()
finally:
- cleanup(environment['HOME'])
+ cleanup(environment['HOME'], options.keep)
- else:
- return run_tests(arguments[1:])
+ return run_tests(tests)
-if __name__ == "__main__":
+if __name__ == '__main__':
sys.exit(main(sys.argv[0], sys.argv[1:]))