mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 04:46:13 +00:00
launcher: Clean up outpout
Make our stdout output simpler to follow by: - Not printing the tests we launch (it is not really useful in the end) - Using `\r` when printing the passed tests - Not reprinting all the test in a now useless summary
This commit is contained in:
parent
3f66772fa1
commit
2b40c6c306
3 changed files with 40 additions and 33 deletions
|
@ -109,6 +109,8 @@ class Test(Loggable):
|
||||||
self.optional = False
|
self.optional = False
|
||||||
self.is_parallel = is_parallel
|
self.is_parallel = is_parallel
|
||||||
self.generator = None
|
self.generator = None
|
||||||
|
# String representation of the test number in the testsuite
|
||||||
|
self.number = ""
|
||||||
|
|
||||||
self.clean()
|
self.clean()
|
||||||
|
|
||||||
|
@ -134,7 +136,10 @@ class Test(Loggable):
|
||||||
" You can reproduce with: %s\n" \
|
" You can reproduce with: %s\n" \
|
||||||
% (self.message, self.get_command_repr())
|
% (self.message, self.get_command_repr())
|
||||||
|
|
||||||
string += self.get_logfile_repr()
|
if not self.options.redirect_logs and \
|
||||||
|
self.result == Result.PASSED or \
|
||||||
|
not self.options.dump_on_failure:
|
||||||
|
string += self.get_logfile_repr()
|
||||||
|
|
||||||
return string
|
return string
|
||||||
|
|
||||||
|
@ -240,13 +245,13 @@ class Test(Loggable):
|
||||||
|
|
||||||
def set_result(self, result, message="", error=""):
|
def set_result(self, result, message="", error=""):
|
||||||
self.debug("Setting result: %s (message: %s, error: %s)" % (result,
|
self.debug("Setting result: %s (message: %s, error: %s)" % (result,
|
||||||
message, error))
|
message, error))
|
||||||
|
|
||||||
if result is Result.TIMEOUT:
|
if result is Result.TIMEOUT:
|
||||||
if self.options.debug is True:
|
if self.options.debug is True:
|
||||||
if self.options.gdb:
|
if self.options.gdb:
|
||||||
printc("Timeout, you should process <ctrl>c to get into gdb",
|
printc("Timeout, you should process <ctrl>c to get into gdb",
|
||||||
Colors.FAIL)
|
Colors.FAIL)
|
||||||
# and wait here until gdb exits
|
# and wait here until gdb exits
|
||||||
self.process.communicate()
|
self.process.communicate()
|
||||||
else:
|
else:
|
||||||
|
@ -434,7 +439,7 @@ class Test(Loggable):
|
||||||
logfiles.insert(0, self.logfile)
|
logfiles.insert(0, self.logfile)
|
||||||
|
|
||||||
for log in logfiles:
|
for log in logfiles:
|
||||||
message += "\n - %s" % log
|
message += " - %s\n" % log
|
||||||
|
|
||||||
return message
|
return message
|
||||||
|
|
||||||
|
@ -465,21 +470,18 @@ class Test(Loggable):
|
||||||
if self.options.valgrind:
|
if self.options.valgrind:
|
||||||
self.command = self.use_valgrind(self.command, self.proc_env)
|
self.command = self.use_valgrind(self.command, self.proc_env)
|
||||||
|
|
||||||
message = "Launching: %s%s\n" \
|
|
||||||
" Command: %s\n" % (Colors.ENDC, self.classname,
|
|
||||||
self.get_command_repr())
|
|
||||||
|
|
||||||
if not self.options.redirect_logs:
|
if not self.options.redirect_logs:
|
||||||
message += self.get_logfile_repr()
|
|
||||||
|
|
||||||
self.out.write("=================\n"
|
self.out.write("=================\n"
|
||||||
"Test name: %s\n"
|
"Test name: %s\n"
|
||||||
"Command: '%s'\n"
|
"Command: '%s'\n"
|
||||||
"=================\n\n"
|
"=================\n\n"
|
||||||
% (self.classname, ' '.join(self.command)))
|
% (self.classname, ' '.join(self.command)))
|
||||||
self.out.flush()
|
self.out.flush()
|
||||||
|
else:
|
||||||
printc(message, Colors.OKBLUE)
|
message = "Launching: %s%s\n" \
|
||||||
|
" Command: %s\n" % (Colors.ENDC, self.classname,
|
||||||
|
self.get_command_repr())
|
||||||
|
printc(message, Colors.OKBLUE)
|
||||||
|
|
||||||
self.thread = threading.Thread(target=self.thread_wrapper)
|
self.thread = threading.Thread(target=self.thread_wrapper)
|
||||||
self.thread.start()
|
self.thread.start()
|
||||||
|
@ -506,13 +508,15 @@ class Test(Loggable):
|
||||||
self.thread.join()
|
self.thread.join()
|
||||||
self.time_taken = time.time() - self._starting_time
|
self.time_taken = time.time() - self._starting_time
|
||||||
|
|
||||||
message = "%s: %s%s\n" % (self.classname, self.result,
|
if self.result != Result.PASSED:
|
||||||
" (" + self.message + ")" if self.message else "")
|
message = str(self)
|
||||||
if not self.options.redirect_logs:
|
end = "\n"
|
||||||
message += self.get_logfile_repr()
|
else:
|
||||||
|
message = "%s %s: %s%s" % (self.number, self.classname, self.result,
|
||||||
printc(message, color=utils.get_color_for_result(self.result))
|
" (" + self.message + ")" if self.message else "")
|
||||||
|
end = "\r"
|
||||||
|
|
||||||
|
printc(message, color=utils.get_color_for_result(self.result), end=end)
|
||||||
self.close_logfile()
|
self.close_logfile()
|
||||||
|
|
||||||
if self.options.dump_on_failure:
|
if self.options.dump_on_failure:
|
||||||
|
@ -1548,12 +1552,13 @@ class _TestsLauncher(Loggable):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def print_test_num(self, test):
|
def get_test_num(self, test):
|
||||||
cur_test_num = self.tests.index(test) + 1
|
cur_test_num = self.tests.index(test) + 1
|
||||||
sys.stdout.write("[%d / %d] " % (cur_test_num, self.total_num_tests))
|
return "[%d / %d] " % (cur_test_num, self.total_num_tests)
|
||||||
|
|
||||||
def server_wrapper(self, ready):
|
def server_wrapper(self, ready):
|
||||||
self.server = GstValidateTCPServer(('localhost', 0), GstValidateListener)
|
self.server = GstValidateTCPServer(
|
||||||
|
('localhost', 0), GstValidateListener)
|
||||||
self.server.socket.settimeout(None)
|
self.server.socket.settimeout(None)
|
||||||
self.server.launcher = self
|
self.server.launcher = self
|
||||||
self.serverport = self.server.socket.getsockname()[1]
|
self.serverport = self.server.socket.getsockname()[1]
|
||||||
|
@ -1608,7 +1613,6 @@ class _TestsLauncher(Loggable):
|
||||||
except IndexError:
|
except IndexError:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
self.print_test_num(test)
|
|
||||||
test.test_start(self.queue)
|
test.test_start(self.queue)
|
||||||
|
|
||||||
self.jobs.append(test)
|
self.jobs.append(test)
|
||||||
|
@ -1653,7 +1657,7 @@ class _TestsLauncher(Loggable):
|
||||||
while jobs_running != 0:
|
while jobs_running != 0:
|
||||||
test = self.tests_wait()
|
test = self.tests_wait()
|
||||||
jobs_running -= 1
|
jobs_running -= 1
|
||||||
self.print_test_num(test)
|
test.number = self.get_test_num(test)
|
||||||
res = test.test_end()
|
res = test.test_end()
|
||||||
self.reporter.after_test(test)
|
self.reporter.after_test(test)
|
||||||
if res != Result.PASSED and (self.options.forever or
|
if res != Result.PASSED and (self.options.forever or
|
||||||
|
|
|
@ -95,14 +95,6 @@ class Reporter(Loggable):
|
||||||
self.add_results(test)
|
self.add_results(test)
|
||||||
|
|
||||||
def final_report(self):
|
def final_report(self):
|
||||||
print("\n")
|
|
||||||
printc("Final Report:", title=True)
|
|
||||||
sortedresults = sorted(self.results, key=lambda test: test.classname)
|
|
||||||
for test in sorted(sortedresults, key=lambda test: test.result):
|
|
||||||
printc(test)
|
|
||||||
if test.result != Result.PASSED:
|
|
||||||
print("\n")
|
|
||||||
|
|
||||||
print("\n")
|
print("\n")
|
||||||
lenstat = (len("Statistics") + 1)
|
lenstat = (len("Statistics") + 1)
|
||||||
printc("Statistics:\n%s" % (lenstat * "-"), Colors.OKBLUE)
|
printc("Statistics:\n%s" % (lenstat * "-"), Colors.OKBLUE)
|
||||||
|
|
|
@ -145,7 +145,8 @@ def get_color_for_result(result):
|
||||||
return color
|
return color
|
||||||
|
|
||||||
|
|
||||||
def printc(message, color="", title=False, title_char=''):
|
last_cariage_return_len = 0
|
||||||
|
def printc(message, color="", title=False, title_char='', end="\n"):
|
||||||
if title or title_char:
|
if title or title_char:
|
||||||
length = 0
|
length = 0
|
||||||
for l in message.split("\n"):
|
for l in message.split("\n"):
|
||||||
|
@ -162,7 +163,17 @@ def printc(message, color="", title=False, title_char=''):
|
||||||
if hasattr(message, "result") and color == '':
|
if hasattr(message, "result") and color == '':
|
||||||
color = get_color_for_result(message.result)
|
color = get_color_for_result(message.result)
|
||||||
|
|
||||||
sys.stdout.write(color + str(message) + Colors.ENDC + "\n")
|
if not sys.stdout.isatty():
|
||||||
|
end = "\n"
|
||||||
|
|
||||||
|
global last_carriage_return_len
|
||||||
|
if end == "\r":
|
||||||
|
message += ' ' * max(0, last_carriage_return_len - len(message))
|
||||||
|
last_carriage_return_len = len(message)
|
||||||
|
else:
|
||||||
|
last_carriage_return_len = 0
|
||||||
|
|
||||||
|
sys.stdout.write(color + str(message) + Colors.ENDC + end)
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue