Issue #25220, libregrtest: more verbose output for -jN

When the -jN command line option is used, display tests running since at least
30 seconds every minute.
This commit is contained in:
Victor Stinner 2015-09-30 03:05:43 +02:00
parent b40843546b
commit 17f9716676
1 changed files with 28 additions and 11 deletions

View File

@ -1,11 +1,11 @@
import json
import os
import queue
import sys
import time
import traceback
import types
import unittest
from queue import Queue
from test import support
try:
import threading
@ -21,6 +21,9 @@ from test.libregrtest.setup import setup_tests
# the test is running in background
PROGRESS_MIN_TIME = 30.0 # seconds
# Display the running tests if nothing happened last N seconds
PROGRESS_UPDATE = 60.0 # seconds
def run_test_in_subprocess(testname, ns):
"""Run the given test in a subprocess with --slaveargs.
@ -145,18 +148,39 @@ class MultiprocessThread(threading.Thread):
def run_tests_multiprocess(regrtest):
output = Queue()
output = queue.Queue()
pending = MultiprocessIterator(regrtest.tests)
workers = [MultiprocessThread(pending, output, regrtest.ns)
for i in range(regrtest.ns.use_mp)]
for worker in workers:
worker.start()
def get_running(workers):
running = []
for worker in workers:
current_test = worker.current_test
if not current_test:
continue
dt = time.monotonic() - worker.start_time
if dt >= PROGRESS_MIN_TIME:
running.append('%s (%.0f sec)' % (current_test, dt))
return running
finished = 0
test_index = 1
timeout = max(PROGRESS_UPDATE, PROGRESS_MIN_TIME)
try:
while finished < regrtest.ns.use_mp:
test, stdout, stderr, result = output.get()
try:
item = output.get(timeout=PROGRESS_UPDATE)
except queue.Empty:
running = get_running(workers)
if running:
print('running: %s' % ', '.join(running))
continue
test, stdout, stderr, result = item
if test is None:
finished += 1
continue
@ -168,14 +192,7 @@ def run_tests_multiprocess(regrtest):
if (ok not in (CHILD_ERROR, INTERRUPTED)
and test_time >= PROGRESS_MIN_TIME):
text += ' (%.0f sec)' % test_time
running = []
for worker in workers:
current_test = worker.current_test
if not current_test:
continue
dt = time.monotonic() - worker.start_time
if dt >= PROGRESS_MIN_TIME:
running.append('%s (%.0f sec)' % (current_test, dt))
running = get_running(workers)
if running:
text += ' -- running: %s' % ', '.join(running)
regrtest.display_progress(test_index, text)