mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
regrtest: add time to output
Timestamps should help to debug slow buildbots, and timeout and hang on buildbots.
This commit is contained in:
parent
10b73e1748
commit
24f949e10c
2 changed files with 19 additions and 6 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
import datetime
|
||||||
import faulthandler
|
import faulthandler
|
||||||
import os
|
import os
|
||||||
import platform
|
import platform
|
||||||
|
@ -7,6 +8,7 @@ import sys
|
||||||
import sysconfig
|
import sysconfig
|
||||||
import tempfile
|
import tempfile
|
||||||
import textwrap
|
import textwrap
|
||||||
|
import time
|
||||||
from test.libregrtest.cmdline import _parse_args
|
from test.libregrtest.cmdline import _parse_args
|
||||||
from test.libregrtest.runtest import (
|
from test.libregrtest.runtest import (
|
||||||
findtests, runtest,
|
findtests, runtest,
|
||||||
|
@ -79,6 +81,7 @@ class Regrtest:
|
||||||
self.found_garbage = []
|
self.found_garbage = []
|
||||||
|
|
||||||
# used to display the progress bar "[ 3/100]"
|
# used to display the progress bar "[ 3/100]"
|
||||||
|
self.start_time = time.monotonic()
|
||||||
self.test_count = ''
|
self.test_count = ''
|
||||||
self.test_count_width = 1
|
self.test_count_width = 1
|
||||||
|
|
||||||
|
@ -102,16 +105,24 @@ class Regrtest:
|
||||||
self.skipped.append(test)
|
self.skipped.append(test)
|
||||||
self.resource_denieds.append(test)
|
self.resource_denieds.append(test)
|
||||||
|
|
||||||
|
def time_delta(self):
|
||||||
|
seconds = time.monotonic() - self.start_time
|
||||||
|
return datetime.timedelta(seconds=int(seconds))
|
||||||
|
|
||||||
def display_progress(self, test_index, test):
|
def display_progress(self, test_index, test):
|
||||||
if self.ns.quiet:
|
if self.ns.quiet:
|
||||||
return
|
return
|
||||||
if self.bad and not self.ns.pgo:
|
if self.bad and not self.ns.pgo:
|
||||||
fmt = "[{1:{0}}{2}/{3}] {4}"
|
fmt = "{time} [{test_index:{count_width}}{test_count}/{nbad}] {test_name}"
|
||||||
else:
|
else:
|
||||||
fmt = "[{1:{0}}{2}] {4}"
|
fmt = "{time} [{test_index:{count_width}}{test_count}] {test_name}"
|
||||||
print(fmt.format(self.test_count_width, test_index,
|
line = fmt.format(count_width=self.test_count_width,
|
||||||
self.test_count, len(self.bad), test),
|
test_index=test_index,
|
||||||
flush=True)
|
test_count=self.test_count,
|
||||||
|
nbad=len(self.bad),
|
||||||
|
test_name=test,
|
||||||
|
time=self.time_delta())
|
||||||
|
print(line, flush=True)
|
||||||
|
|
||||||
def parse_args(self, kwargs):
|
def parse_args(self, kwargs):
|
||||||
ns = _parse_args(sys.argv[1:], **kwargs)
|
ns = _parse_args(sys.argv[1:], **kwargs)
|
||||||
|
@ -368,6 +379,8 @@ class Regrtest:
|
||||||
r.write_results(show_missing=True, summary=True,
|
r.write_results(show_missing=True, summary=True,
|
||||||
coverdir=self.ns.coverdir)
|
coverdir=self.ns.coverdir)
|
||||||
|
|
||||||
|
print("Total duration: %s" % self.time_delta())
|
||||||
|
|
||||||
if self.ns.runleaks:
|
if self.ns.runleaks:
|
||||||
os.system("leaks %d" % os.getpid())
|
os.system("leaks %d" % os.getpid())
|
||||||
|
|
||||||
|
|
|
@ -351,7 +351,7 @@ class BaseTestCase(unittest.TestCase):
|
||||||
self.assertRegex(output, regex)
|
self.assertRegex(output, regex)
|
||||||
|
|
||||||
def parse_executed_tests(self, output):
|
def parse_executed_tests(self, output):
|
||||||
regex = r'^\[ *[0-9]+(?:/ *[0-9]+)?\] (%s)$' % self.TESTNAME_REGEX
|
regex = r'^[0-9]+:[0-9]+:[0-9]+ \[ *[0-9]+(?:/ *[0-9]+)?\] (%s)$' % self.TESTNAME_REGEX
|
||||||
parser = re.finditer(regex, output, re.MULTILINE)
|
parser = re.finditer(regex, output, re.MULTILINE)
|
||||||
return list(match.group(1) for match in parser)
|
return list(match.group(1) for match in parser)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue