From 0aa4f05a5f5252565092e05b86f117a1bf8df7b3 Mon Sep 17 00:00:00 2001 From: Jason Ish Date: Tue, 4 Aug 2020 15:07:27 -0600 Subject: [PATCH] runner: debug-failed fixups Don't dump a file that looks like binary. This is determined by trying to utf-8 decode a file. --- run.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/run.py b/run.py index b06a9c6d5..f35e634be 100755 --- a/run.py +++ b/run.py @@ -939,9 +939,17 @@ def main(): print("- Test %s:" % os.path.basename(dirpath)) for r, d, f in os.walk(dirpath+"/output"): for fname in f: - print(" - %s" % fname) - with open(dirpath + "/output/" + fname, "r") as fcontents: - print(fcontents.read()) + path = os.path.join(r, fname) + print(" - %s" % path) + try: + with open(path, "r") as fcontents: + try: + buf = fcontents.read().decode() + print(buf) + except: + print(" - [Not dumping file that won't utf-8 decode]") + except Exception as err: + print("Failed to open %s: %s" % (path, str(err))) if failed > 0: return 1 -- 2.47.2