Skip to content
Snippets Groups Projects
Commit 236058a6 authored by kiilerix's avatar kiilerix
Browse files

tests: replace test tmp directory with $TESTTMP in test output

This reduces the number of patterns that must be adjusted when writing tests.
parent eb09e3c9
No related branches found
No related tags found
No related merge requests found
......@@ -443,7 +443,7 @@
def alarmed(signum, frame):
raise Timeout
def pytest(test, options):
def pytest(test, options, replacements):
py3kswitch = options.py3k_warnings and ' -3' or ''
cmd = '%s%s "%s"' % (PYTHON, py3kswitch, test)
vlog("# Running", cmd)
......@@ -447,5 +447,5 @@
py3kswitch = options.py3k_warnings and ' -3' or ''
cmd = '%s%s "%s"' % (PYTHON, py3kswitch, test)
vlog("# Running", cmd)
return run(cmd, options)
return run(cmd, options, replacements)
......@@ -451,4 +451,4 @@
def shtest(test, options):
def shtest(test, options, replacements):
cmd = '"%s"' % test
vlog("# Running", cmd)
......@@ -453,4 +453,4 @@
cmd = '"%s"' % test
vlog("# Running", cmd)
return run(cmd, options)
return run(cmd, options, replacements)
......@@ -456,6 +456,6 @@
def battest(test, options):
def battest(test, options, replacements):
# To reliably get the error code from batch files on WinXP,
# the "cmd /c call" prefix is needed. Grrr
cmd = 'cmd /c call "%s"' % testpath
vlog("# Running", cmd)
......@@ -458,6 +458,6 @@
# To reliably get the error code from batch files on WinXP,
# the "cmd /c call" prefix is needed. Grrr
cmd = 'cmd /c call "%s"' % testpath
vlog("# Running", cmd)
return run(cmd, options)
return run(cmd, options, replacements)
......@@ -463,5 +463,5 @@
def tsttest(test, options):
def tsttest(test, options, replacements):
t = open(test)
out = []
script = []
......@@ -500,7 +500,7 @@
cmd = '/bin/sh "%s"' % name
vlog("# Running", cmd)
exitcode, output = run(cmd, options)
exitcode, output = run(cmd, options, replacements)
# do not merge output if skipped, return hghave message instead
if exitcode == SKIPPED_STATUS:
return exitcode, output
......@@ -565,7 +565,7 @@
return exitcode, postout
def run(cmd, options):
def run(cmd, options, replacements):
"""Run command in a sub-process, capturing the output (stdout and stderr).
Return a tuple (exitcode, output). output is None in debug mode."""
# TODO: Use subprocess.Popen if we're running on Python 2.4
......@@ -608,6 +608,8 @@
cleanup()
raise
for s, r in replacements:
output = output.replace(s, r)
return ret, splitnewlines(output)
def runone(options, test, skips, fails):
......@@ -682,10 +684,10 @@
runner = shtest
# Make a tmp subdirectory to work in
tmpd = os.path.join(HGTMP, test)
os.mkdir(tmpd)
os.chdir(tmpd)
testtmp = os.environ["TESTTMP"] = os.path.join(HGTMP, test)
os.mkdir(testtmp)
os.chdir(testtmp)
if options.timeout > 0:
signal.alarm(options.timeout)
......@@ -688,8 +690,8 @@
if options.timeout > 0:
signal.alarm(options.timeout)
ret, out = runner(testpath, options)
ret, out = runner(testpath, options, [(testtmp, '$TESTTMP')])
vlog("# Ret was:", ret)
if options.timeout > 0:
......@@ -755,7 +757,7 @@
os.chdir(TESTDIR)
if not options.keep_tmpdir:
shutil.rmtree(tmpd, True)
shutil.rmtree(testtmp, True)
if skipped:
return None
return ret == 0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment