[PATCH] tests: add --keep-tmp to run-tests.py to debug test environment

Peter Arrenbrecht peter.arrenbrecht at gmail.com
Wed Mar 5 01:21:15 CST 2008


# HG changeset patch
# User Peter Arrenbrecht <peter.arrenbrecht at gmail.com>
# Date 1204700405 -3600
# Node ID 834b4431d05e35428326d3643655e112901c62b8
# Parent  e2b3c326c6850deebc6229c2c67e666adfcd7e64
tests: add --keep-tmp to run-tests.py to debug test environment

When set, you can find the working dir of the test run as a
uniquely named subdirectory of --tmpdir so you can inspect
it.

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -38,6 +38,8 @@ parser.add_option("-i", "--interactive",
     help="prompt to accept changed output")
 parser.add_option("-j", "--jobs", type="int",
     help="number of jobs to run in parallel")
+parser.add_option("--keep-tmpdir", action="store_true",
+    help="keep temporary directory after running tests (best used with --tmpdir)")
 parser.add_option("-R", "--restart", action="store_true",
     help="restart at last error")
 parser.add_option("-p", "--port", type="int",
@@ -133,9 +135,10 @@ def check_required_tools():
             print "WARNING: Did not find prerequisite tool: "+p
 
 def cleanup_exit():
-    if verbose:
-        print "# Cleaning up HGTMP", HGTMP
-    shutil.rmtree(HGTMP, True)
+    if not options.keep_tmpdir:
+        if verbose:
+            print "# Cleaning up HGTMP", HGTMP
+        shutil.rmtree(HGTMP, True)
 
 def use_correct_python():
     # some tests run python interpreter. they must use same
@@ -398,7 +401,8 @@ def run_one(test, skips):
         pass
 
     os.chdir(TESTDIR)
-    shutil.rmtree(tmpd, True)
+    if not options.keep_tmpdir:
+	    shutil.rmtree(tmpd, True)
     if skipped:
         return None
     return ret == 0


More information about the Mercurial-devel mailing list