equal
deleted
inserted
replaced
2060 # we make sure they're all bytestrings |
2060 # we make sure they're all bytestrings |
2061 args = [_bytespath(a) for a in args] |
2061 args = [_bytespath(a) for a in args] |
2062 self.options = options |
2062 self.options = options |
2063 |
2063 |
2064 self._checktools() |
2064 self._checktools() |
2065 tests = self.findtests(args) |
2065 testdescs = self.findtests(args) |
2066 if options.profile_runner: |
2066 if options.profile_runner: |
2067 import statprof |
2067 import statprof |
2068 statprof.start() |
2068 statprof.start() |
2069 result = self._run(tests) |
2069 result = self._run(testdescs) |
2070 if options.profile_runner: |
2070 if options.profile_runner: |
2071 statprof.stop() |
2071 statprof.stop() |
2072 statprof.display() |
2072 statprof.display() |
2073 return result |
2073 return result |
2074 |
2074 |
2075 finally: |
2075 finally: |
2076 os.umask(oldmask) |
2076 os.umask(oldmask) |
2077 |
2077 |
2078 def _run(self, tests): |
2078 def _run(self, testdescs): |
2079 if self.options.random: |
2079 if self.options.random: |
2080 random.shuffle(tests) |
2080 random.shuffle(testdescs) |
2081 else: |
2081 else: |
2082 # keywords for slow tests |
2082 # keywords for slow tests |
2083 slow = {b'svn': 10, |
2083 slow = {b'svn': 10, |
2084 b'cvs': 10, |
2084 b'cvs': 10, |
2085 b'hghave': 10, |
2085 b'hghave': 10, |
2111 val *= mul |
2111 val *= mul |
2112 if f.endswith(b'.py'): |
2112 if f.endswith(b'.py'): |
2113 val /= 10.0 |
2113 val /= 10.0 |
2114 perf[f] = val / 1000.0 |
2114 perf[f] = val / 1000.0 |
2115 return perf[f] |
2115 return perf[f] |
2116 tests.sort(key=sortkey) |
2116 testdescs.sort(key=sortkey) |
2117 |
2117 |
2118 self._testdir = osenvironb[b'TESTDIR'] = getattr( |
2118 self._testdir = osenvironb[b'TESTDIR'] = getattr( |
2119 os, 'getcwdb', os.getcwd)() |
2119 os, 'getcwdb', os.getcwd)() |
2120 |
2120 |
2121 if 'PYTHONHASHSEED' not in os.environ: |
2121 if 'PYTHONHASHSEED' not in os.environ: |
2241 vlog("# Using HGTMP", self._hgtmp) |
2241 vlog("# Using HGTMP", self._hgtmp) |
2242 vlog("# Using PATH", os.environ["PATH"]) |
2242 vlog("# Using PATH", os.environ["PATH"]) |
2243 vlog("# Using", IMPL_PATH, osenvironb[IMPL_PATH]) |
2243 vlog("# Using", IMPL_PATH, osenvironb[IMPL_PATH]) |
2244 |
2244 |
2245 try: |
2245 try: |
2246 return self._runtests(tests) or 0 |
2246 return self._runtests(testdescs) or 0 |
2247 finally: |
2247 finally: |
2248 time.sleep(.1) |
2248 time.sleep(.1) |
2249 self._cleanup() |
2249 self._cleanup() |
2250 |
2250 |
2251 def findtests(self, args): |
2251 def findtests(self, args): |
2265 |
2265 |
2266 return [{'path': t} for t in args |
2266 return [{'path': t} for t in args |
2267 if os.path.basename(t).startswith(b'test-') |
2267 if os.path.basename(t).startswith(b'test-') |
2268 and (t.endswith(b'.py') or t.endswith(b'.t'))] |
2268 and (t.endswith(b'.py') or t.endswith(b'.t'))] |
2269 |
2269 |
2270 def _runtests(self, tests): |
2270 def _runtests(self, testdescs): |
2271 def _reloadtest(test, i): |
2271 def _reloadtest(test, i): |
2272 # convert a test back to its description dict |
2272 # convert a test back to its description dict |
2273 desc = {'path': test.path} |
2273 desc = {'path': test.path} |
2274 return self._gettest(desc, i) |
2274 return self._gettest(desc, i) |
2275 |
2275 |
2282 if self.options.chg: |
2282 if self.options.chg: |
2283 assert self._installdir |
2283 assert self._installdir |
2284 self._installchg() |
2284 self._installchg() |
2285 |
2285 |
2286 if self.options.restart: |
2286 if self.options.restart: |
2287 orig = list(tests) |
2287 orig = list(testdescs) |
2288 while tests: |
2288 while testdescs: |
2289 if os.path.exists(tests[0]['path'] + ".err"): |
2289 if os.path.exists(testdescs[0]['path'] + ".err"): |
2290 break |
2290 break |
2291 tests.pop(0) |
2291 testdescs.pop(0) |
2292 if not tests: |
2292 if not testdescs: |
2293 print("running all tests") |
2293 print("running all tests") |
2294 tests = orig |
2294 testdescs = orig |
2295 |
2295 |
2296 tests = [self._gettest(t, i) for i, t in enumerate(tests)] |
2296 tests = [self._gettest(d, i) for i, d in enumerate(testdescs)] |
2297 |
2297 |
2298 failed = False |
2298 failed = False |
2299 warned = False |
2299 warned = False |
2300 kws = self.options.keywords |
2300 kws = self.options.keywords |
2301 if kws is not None and PYTHON3: |
2301 if kws is not None and PYTHON3: |
2349 if allfree: |
2349 if allfree: |
2350 break |
2350 break |
2351 self._ports[count] = port |
2351 self._ports[count] = port |
2352 return port |
2352 return port |
2353 |
2353 |
2354 def _gettest(self, test, count): |
2354 def _gettest(self, testdesc, count): |
2355 """Obtain a Test by looking at its filename. |
2355 """Obtain a Test by looking at its filename. |
2356 |
2356 |
2357 Returns a Test instance. The Test may not be runnable if it doesn't |
2357 Returns a Test instance. The Test may not be runnable if it doesn't |
2358 map to a known type. |
2358 map to a known type. |
2359 """ |
2359 """ |
2360 path = test['path'] |
2360 path = testdesc['path'] |
2361 lctest = path.lower() |
2361 lctest = path.lower() |
2362 testcls = Test |
2362 testcls = Test |
2363 |
2363 |
2364 for ext, cls in self.TESTTYPES: |
2364 for ext, cls in self.TESTTYPES: |
2365 if lctest.endswith(ext): |
2365 if lctest.endswith(ext): |