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