File Lib/test/libregrtest/main.py changed (mode: 100644) (index de1f4f9505..2cfbdd12b2) |
... |
... |
class Regrtest: |
120 |
120 |
def display_progress(self, test_index, test): |
def display_progress(self, test_index, test): |
121 |
121 |
if self.ns.quiet: |
if self.ns.quiet: |
122 |
122 |
return |
return |
|
123 |
|
|
|
124 |
|
# "[ 51/405/1] test_tcl passed" |
|
125 |
|
line = f"{test_index:{self.test_count_width}}{self.test_count}" |
123 |
126 |
if self.bad and not self.ns.pgo: |
if self.bad and not self.ns.pgo: |
124 |
|
fmt = "{time} [{test_index:{count_width}}{test_count}/{nbad}] {test_name}" |
|
125 |
|
else: |
|
126 |
|
fmt = "{time} [{test_index:{count_width}}{test_count}] {test_name}" |
|
|
127 |
|
line = f"{line}/{len(self.bad)}" |
|
128 |
|
line = f"[{line}] {test}" |
|
129 |
|
|
|
130 |
|
# add the system load prefix: "load avg: 1.80 " |
|
131 |
|
if hasattr(os, 'getloadavg'): |
|
132 |
|
load_avg_1min = os.getloadavg()[0] |
|
133 |
|
line = f"load avg: {load_avg_1min:.2f} {line}" |
|
134 |
|
|
|
135 |
|
# add the timestamp prefix: "0:01:05 " |
127 |
136 |
test_time = time.monotonic() - self.start_time |
test_time = time.monotonic() - self.start_time |
128 |
137 |
test_time = datetime.timedelta(seconds=int(test_time)) |
test_time = datetime.timedelta(seconds=int(test_time)) |
129 |
|
line = fmt.format(count_width=self.test_count_width, |
|
130 |
|
test_index=test_index, |
|
131 |
|
test_count=self.test_count, |
|
132 |
|
nbad=len(self.bad), |
|
133 |
|
test_name=test, |
|
134 |
|
time=test_time) |
|
|
138 |
|
line = f"{test_time} {line}" |
135 |
139 |
print(line, flush=True) |
print(line, flush=True) |
136 |
140 |
|
|
137 |
141 |
def parse_args(self, kwargs): |
def parse_args(self, kwargs): |
|
... |
... |
class Regrtest: |
376 |
380 |
if self.bad: |
if self.bad: |
377 |
381 |
return |
return |
378 |
382 |
|
|
|
383 |
|
def display_header(self): |
|
384 |
|
# Print basic platform information |
|
385 |
|
print("==", platform.python_implementation(), *sys.version.split()) |
|
386 |
|
print("==", platform.platform(aliased=True), |
|
387 |
|
"%s-endian" % sys.byteorder) |
|
388 |
|
print("== hash algorithm:", sys.hash_info.algorithm, |
|
389 |
|
"64bit" if sys.maxsize > 2**32 else "32bit") |
|
390 |
|
print("== cwd:", os.getcwd()) |
|
391 |
|
cpu_count = os.cpu_count() |
|
392 |
|
if cpu_count: |
|
393 |
|
print("== CPU count:", cpu_count) |
|
394 |
|
print("== encodings: locale=%s, FS=%s" |
|
395 |
|
% (locale.getpreferredencoding(False), |
|
396 |
|
sys.getfilesystemencoding())) |
|
397 |
|
print("Testing with flags:", sys.flags) |
|
398 |
|
|
379 |
399 |
def run_tests(self): |
def run_tests(self): |
380 |
400 |
# For a partial run, we do not need to clutter the output. |
# For a partial run, we do not need to clutter the output. |
381 |
|
if (self.ns.verbose |
|
382 |
|
or self.ns.header |
|
383 |
|
or not (self.ns.pgo or self.ns.quiet or self.ns.single |
|
384 |
|
or self.tests or self.ns.args)): |
|
385 |
|
# Print basic platform information |
|
386 |
|
print("==", platform.python_implementation(), *sys.version.split()) |
|
387 |
|
print("== ", platform.platform(aliased=True), |
|
388 |
|
"%s-endian" % sys.byteorder) |
|
389 |
|
print("== ", "hash algorithm:", sys.hash_info.algorithm, |
|
390 |
|
"64bit" if sys.maxsize > 2**32 else "32bit") |
|
391 |
|
print("== cwd:", os.getcwd()) |
|
392 |
|
print("== encodings: locale=%s, FS=%s" |
|
393 |
|
% (locale.getpreferredencoding(False), |
|
394 |
|
sys.getfilesystemencoding())) |
|
395 |
|
print("Testing with flags:", sys.flags) |
|
|
401 |
|
if (self.ns.header |
|
402 |
|
or not(self.ns.pgo or self.ns.quiet or self.ns.single |
|
403 |
|
or self.tests or self.ns.args)): |
|
404 |
|
self.display_header() |
396 |
405 |
|
|
397 |
406 |
if self.ns.randomize: |
if self.ns.randomize: |
398 |
407 |
print("Using random seed", self.ns.random_seed) |
print("Using random seed", self.ns.random_seed) |
File Lib/test/test_regrtest.py changed (mode: 100644) (index 0bd62985d9..d3492604cb) |
... |
... |
class ParseArgsTestCase(unittest.TestCase): |
118 |
118 |
ns = libregrtest._parse_args(['--header']) |
ns = libregrtest._parse_args(['--header']) |
119 |
119 |
self.assertTrue(ns.header) |
self.assertTrue(ns.header) |
120 |
120 |
|
|
|
121 |
|
ns = libregrtest._parse_args(['--verbose']) |
|
122 |
|
self.assertTrue(ns.header) |
|
123 |
|
|
121 |
124 |
def test_randomize(self): |
def test_randomize(self): |
122 |
125 |
for opt in '-r', '--randomize': |
for opt in '-r', '--randomize': |
123 |
126 |
with self.subTest(opt=opt): |
with self.subTest(opt=opt): |
|
... |
... |
class BaseTestCase(unittest.TestCase): |
354 |
357 |
self.assertRegex(output, regex) |
self.assertRegex(output, regex) |
355 |
358 |
|
|
356 |
359 |
def parse_executed_tests(self, output): |
def parse_executed_tests(self, output): |
357 |
|
regex = (r'^[0-9]+:[0-9]+:[0-9]+ \[ *[0-9]+(?:/ *[0-9]+)*\] (%s)' |
|
|
360 |
|
regex = (r'^[0-9]+:[0-9]+:[0-9]+ (?:load avg: [0-9]+\.[0-9]{2} )?\[ *[0-9]+(?:/ *[0-9]+)*\] (%s)' |
358 |
361 |
% self.TESTNAME_REGEX) |
% self.TESTNAME_REGEX) |
359 |
362 |
parser = re.finditer(regex, output, re.MULTILINE) |
parser = re.finditer(regex, output, re.MULTILINE) |
360 |
363 |
return list(match.group(1) for match in parser) |
return list(match.group(1) for match in parser) |