Show More
@@ -582,14 +582,17 b' def outputcoverage(options):' | |||||
582 | class Test(object): |
|
582 | class Test(object): | |
583 | """Encapsulates a single, runnable test.""" |
|
583 | """Encapsulates a single, runnable test.""" | |
584 |
|
584 | |||
585 | def __init__(self, path, options): |
|
585 | def __init__(self, path, options, threadtmp): | |
586 | self._path = path |
|
586 | self._path = path | |
587 | self._options = options |
|
587 | self._options = options | |
588 |
|
588 | |||
589 | def run(self, testtmp, replacements, env): |
|
589 | self.testtmp = os.path.join(threadtmp, os.path.basename(path)) | |
590 | return self._run(testtmp, replacements, env) |
|
590 | os.mkdir(self.testtmp) | |
591 |
|
591 | |||
592 |
def |
|
592 | def run(self, replacements, env): | |
|
593 | return self._run(replacements, env) | |||
|
594 | ||||
|
595 | def _run(self, replacements, env): | |||
593 | raise NotImplemented('Subclasses must implement Test.run()') |
|
596 | raise NotImplemented('Subclasses must implement Test.run()') | |
594 |
|
597 | |||
595 | def pytest(test, wd, options, replacements, env): |
|
598 | def pytest(test, wd, options, replacements, env): | |
@@ -602,8 +605,9 b' def pytest(test, wd, options, replacemen' | |||||
602 |
|
605 | |||
603 | class PythonTest(Test): |
|
606 | class PythonTest(Test): | |
604 | """A Python-based test.""" |
|
607 | """A Python-based test.""" | |
605 |
def _run(self, |
|
608 | def _run(self, replacements, env): | |
606 |
return pytest(self._path, testtmp, self._options, replacements, |
|
609 | return pytest(self._path, self.testtmp, self._options, replacements, | |
|
610 | env) | |||
607 |
|
611 | |||
608 | needescape = re.compile(r'[\x00-\x08\x0b-\x1f\x7f-\xff]').search |
|
612 | needescape = re.compile(r'[\x00-\x08\x0b-\x1f\x7f-\xff]').search | |
609 | escapesub = re.compile(r'[\x00-\x08\x0b-\x1f\\\x7f-\xff]').sub |
|
613 | escapesub = re.compile(r'[\x00-\x08\x0b-\x1f\\\x7f-\xff]').sub | |
@@ -864,8 +868,9 b' def tsttest(test, wd, options, replaceme' | |||||
864 | class TTest(Test): |
|
868 | class TTest(Test): | |
865 | """A "t test" is a test backed by a .t file.""" |
|
869 | """A "t test" is a test backed by a .t file.""" | |
866 |
|
870 | |||
867 |
def _run(self, |
|
871 | def _run(self, replacements, env): | |
868 |
return tsttest(self._path, testtmp, self._options, replacements, |
|
872 | return tsttest(self._path, self.testtmp, self._options, replacements, | |
|
873 | env) | |||
869 |
|
874 | |||
870 | wifexited = getattr(os, "WIFEXITED", lambda x: False) |
|
875 | wifexited = getattr(os, "WIFEXITED", lambda x: False) | |
871 | def run(cmd, wd, options, replacements, env): |
|
876 | def run(cmd, wd, options, replacements, env): | |
@@ -989,13 +994,11 b' def runone(options, test, count):' | |||||
989 | if os.path.exists(err): |
|
994 | if os.path.exists(err): | |
990 | os.remove(err) # Remove any previous output files |
|
995 | os.remove(err) # Remove any previous output files | |
991 |
|
996 | |||
992 | t = runner(testpath, options) |
|
|||
993 |
|
||||
994 | # Make a tmp subdirectory to work in |
|
997 | # Make a tmp subdirectory to work in | |
995 | threadtmp = os.path.join(HGTMP, "child%d" % count) |
|
998 | threadtmp = os.path.join(HGTMP, "child%d" % count) | |
996 | testtmp = os.path.join(threadtmp, os.path.basename(test)) |
|
|||
997 | os.mkdir(threadtmp) |
|
999 | os.mkdir(threadtmp) | |
998 | os.mkdir(testtmp) |
|
1000 | ||
|
1001 | t = runner(testpath, options, threadtmp) | |||
999 |
|
1002 | |||
1000 | port = options.port + count * 3 |
|
1003 | port = options.port + count * 3 | |
1001 | replacements = [ |
|
1004 | replacements = [ | |
@@ -1009,16 +1012,16 b' def runone(options, test, count):' | |||||
1009 | c in '/\\' and r'[/\\]' or |
|
1012 | c in '/\\' and r'[/\\]' or | |
1010 | c.isdigit() and c or |
|
1013 | c.isdigit() and c or | |
1011 | '\\' + c |
|
1014 | '\\' + c | |
1012 | for c in testtmp), '$TESTTMP')) |
|
1015 | for c in t.testtmp), '$TESTTMP')) | |
1013 | else: |
|
1016 | else: | |
1014 | replacements.append((re.escape(testtmp), '$TESTTMP')) |
|
1017 | replacements.append((re.escape(t.testtmp), '$TESTTMP')) | |
1015 |
|
1018 | |||
1016 | env = createenv(options, testtmp, threadtmp, port) |
|
1019 | env = createenv(options, t.testtmp, threadtmp, port) | |
1017 | createhgrc(env['HGRCPATH'], options) |
|
1020 | createhgrc(env['HGRCPATH'], options) | |
1018 |
|
1021 | |||
1019 | starttime = time.time() |
|
1022 | starttime = time.time() | |
1020 | try: |
|
1023 | try: | |
1021 |
ret, out = t.run( |
|
1024 | ret, out = t.run(replacements, env) | |
1022 | except KeyboardInterrupt: |
|
1025 | except KeyboardInterrupt: | |
1023 | endtime = time.time() |
|
1026 | endtime = time.time() | |
1024 | log('INTERRUPTED: %s (after %d seconds)' % (test, endtime - starttime)) |
|
1027 | log('INTERRUPTED: %s (after %d seconds)' % (test, endtime - starttime)) |
General Comments 0
You need to be logged in to leave comments.
Login now