Patchwork [2,of,5] run-tests: place the .t shell script next to $TESTTMP and with a useful name

login
register
mail settings
Submitter Mads Kiilerich
Date Oct. 3, 2013, 12:57 p.m.
Message ID <d66fc34a3b435d57492f.1380805020@mk-desktop>
Download mbox | patch
Permalink /patch/2719/
State Accepted
Commit 6e74632170d3206d096362601bcbb9e9021a56ed
Headers show

Comments

Mads Kiilerich - Oct. 3, 2013, 12:57 p.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1380804647 -7200
#      Thu Oct 03 14:50:47 2013 +0200
# Node ID d66fc34a3b435d57492f65c8cb1f8065e4b7d6b3
# Parent  77fa0218c265bd0c43ad113da9fba6d4a30240f5
run-tests: place the .t shell script next to $TESTTMP and with a useful name

--keep can thus keep it around - very convenient for debugging.

Patch

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -762,21 +762,19 @@ 
     addsalt(n + 1, False)
 
     # Write out the script and execute it
-    fd, name = tempfile.mkstemp(suffix='hg-tst')
-    try:
-        for l in script:
-            os.write(fd, l)
-        os.close(fd)
+    name = wd + '.sh'
+    f = open(name, 'w')
+    for l in script:
+        f.write(l)
+    f.close()
 
-        cmd = '%s "%s"' % (options.shell, name)
-        vlog("# Running", cmd)
-        exitcode, output = run(cmd, wd, options, replacements, env)
-        # do not merge output if skipped, return hghave message instead
-        # similarly, with --debug, output is None
-        if exitcode == SKIPPED_STATUS or output is None:
-            return exitcode, output
-    finally:
-        os.remove(name)
+    cmd = '%s "%s"' % (options.shell, name)
+    vlog("# Running", cmd)
+    exitcode, output = run(cmd, wd, options, replacements, env)
+    # do not merge output if skipped, return hghave message instead
+    # similarly, with --debug, output is None
+    if exitcode == SKIPPED_STATUS or output is None:
+        return exitcode, output
 
     # Merge the script output back into a unified test