From f9577854fb2ad4d1c1541d9179cb631726f40646 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Sun, 26 Feb 2017 01:11:19 +0100 Subject: [PATCH] simplify the way tesh deals with sorted diffs --- tools/tesh/tesh.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/tools/tesh/tesh.py b/tools/tesh/tesh.py index c5159cae1e..f452d68c7e 100755 --- a/tools/tesh/tesh.py +++ b/tools/tesh/tesh.py @@ -329,7 +329,7 @@ class Cmd(object): while len(stdouta) > 0 and stdouta[-1] == "": del stdouta[-1] stdouta = self.remove_ignored_lines(stdouta) - stdcpy = self.output_pipe_stdout[:] + stdcpy = stdouta[:] # Mimic the "sort" bash command, which is case unsensitive. if self.sort == 0: @@ -342,18 +342,21 @@ class Cmd(object): diff = list(difflib.unified_diff(self.output_pipe_stdout, stdouta,lineterm="",fromfile='expected', tofile='obtained')) if len(diff) > 0: print("Output of <"+cmdName+"> mismatch:") - difflen = 0; - for line in diff: - if difflen<250: - print(line) - difflen += 1 - if difflen > 100: - print("(diff truncated after 250 lines)") - if self.sort >= 0: + if self.sort >= 0: # If sorted, truncate the diff output and show the unsorted version + difflen = 0; + for line in diff: + if difflen<250: + print(line) + difflen += 1 + if difflen > 100: + print("(diff truncated after 250 lines)") print("Unsorted observed output:\n") for line in stdcpy: print(line) - + else: # If not sorted, just display the diff + for line in diff: + print(line) + print("Test suite `"+FileReader().filename+"': NOK (<"+cmdName+"> output mismatch)") if lock is not None: lock.release() if TeshState().keep: -- 2.20.1