Show More
@@ -62,9 +62,9 b' import Queue as queue' | |||
|
62 | 62 | processlock = threading.Lock() |
|
63 | 63 | |
|
64 | 64 | closefds = os.name == 'posix' |
|
65 | def Popen4(cmd, wd, timeout): | |
|
65 | def Popen4(cmd, wd, timeout, env=None): | |
|
66 | 66 | processlock.acquire() |
|
67 | p = subprocess.Popen(cmd, shell=True, bufsize=-1, cwd=wd, | |
|
67 | p = subprocess.Popen(cmd, shell=True, bufsize=-1, cwd=wd, env=env, | |
|
68 | 68 | close_fds=closefds, |
|
69 | 69 | stdin=subprocess.PIPE, stdout=subprocess.PIPE, |
|
70 | 70 | stderr=subprocess.STDOUT) |
@@ -549,13 +549,13 b' def outputcoverage(options):' | |||
|
549 | 549 | os.mkdir(adir) |
|
550 | 550 | covrun('-i', '-a', '"--directory=%s"' % adir, '"--omit=%s"' % omit) |
|
551 | 551 | |
|
552 | def pytest(test, wd, options, replacements): | |
|
552 | def pytest(test, wd, options, replacements, env): | |
|
553 | 553 | py3kswitch = options.py3k_warnings and ' -3' or '' |
|
554 | 554 | cmd = '%s%s "%s"' % (PYTHON, py3kswitch, test) |
|
555 | 555 | vlog("# Running", cmd) |
|
556 | 556 | if os.name == 'nt': |
|
557 | 557 | replacements.append((r'\r\n', '\n')) |
|
558 | return run(cmd, wd, options, replacements) | |
|
558 | return run(cmd, wd, options, replacements, env) | |
|
559 | 559 | |
|
560 | 560 | needescape = re.compile(r'[\x00-\x08\x0b-\x1f\x7f-\xff]').search |
|
561 | 561 | escapesub = re.compile(r'[\x00-\x08\x0b-\x1f\\\x7f-\xff]').sub |
@@ -615,7 +615,7 b' def linematch(el, l):' | |||
|
615 | 615 | return True |
|
616 | 616 | return False |
|
617 | 617 | |
|
618 | def tsttest(test, wd, options, replacements): | |
|
618 | def tsttest(test, wd, options, replacements, env): | |
|
619 | 619 | # We generate a shell script which outputs unique markers to line |
|
620 | 620 | # up script results with our source. These markers include input |
|
621 | 621 | # line number and the last return code |
@@ -741,7 +741,7 b' def tsttest(test, wd, options, replaceme' | |||
|
741 | 741 | |
|
742 | 742 | cmd = '%s "%s"' % (options.shell, name) |
|
743 | 743 | vlog("# Running", cmd) |
|
744 | exitcode, output = run(cmd, wd, options, replacements) | |
|
744 | exitcode, output = run(cmd, wd, options, replacements, env) | |
|
745 | 745 | # do not merge output if skipped, return hghave message instead |
|
746 | 746 | # similarly, with --debug, output is None |
|
747 | 747 | if exitcode == SKIPPED_STATUS or output is None: |
@@ -791,16 +791,16 b' def tsttest(test, wd, options, replaceme' | |||
|
791 | 791 | return exitcode, postout |
|
792 | 792 | |
|
793 | 793 | wifexited = getattr(os, "WIFEXITED", lambda x: False) |
|
794 | def run(cmd, wd, options, replacements): | |
|
794 | def run(cmd, wd, options, replacements, env): | |
|
795 | 795 | """Run command in a sub-process, capturing the output (stdout and stderr). |
|
796 | 796 | Return a tuple (exitcode, output). output is None in debug mode.""" |
|
797 | 797 | # TODO: Use subprocess.Popen if we're running on Python 2.4 |
|
798 | 798 | if options.debug: |
|
799 | proc = subprocess.Popen(cmd, shell=True, cwd=wd) | |
|
799 | proc = subprocess.Popen(cmd, shell=True, cwd=wd, env=env) | |
|
800 | 800 | ret = proc.wait() |
|
801 | 801 | return (ret, None) |
|
802 | 802 | |
|
803 | proc = Popen4(cmd, wd, options.timeout) | |
|
803 | proc = Popen4(cmd, wd, options.timeout, env) | |
|
804 | 804 | def cleanup(): |
|
805 | 805 | terminate(proc) |
|
806 | 806 | ret = proc.wait() |
@@ -930,9 +930,11 b' def runone(options, test):' | |||
|
930 | 930 | else: |
|
931 | 931 | replacements.append((re.escape(testtmp), '$TESTTMP')) |
|
932 | 932 | |
|
933 | env = os.environ.copy() | |
|
934 | ||
|
933 | 935 | if options.time: |
|
934 | 936 | starttime = time.time() |
|
935 | ret, out = runner(testpath, testtmp, options, replacements) | |
|
937 | ret, out = runner(testpath, testtmp, options, replacements, env) | |
|
936 | 938 | if options.time: |
|
937 | 939 | endtime = time.time() |
|
938 | 940 | times.append((test, endtime - starttime)) |
General Comments 0
You need to be logged in to leave comments.
Login now