From df8b81f38ccecac15f05e2ffaa5faa164554e5d6 Mon Sep 17 00:00:00 2001 From: Shawn Dawson Date: Fri, 23 May 2025 07:44:45 -0700 Subject: [PATCH] Update opens used for readlines. Update opens with errors='ignore' in attempt to stop the python coding in ATS from dying when it reads output generated by applications which are not utf-8 valid. This can happen when applications print garbage output -- but when this happens the python in ATS breaks and the testing breaks. Try to simply ignore such garbage output. --- ats/machines.py | 2 +- ats/reportutils.py | 4 ++-- ats/tests.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ats/machines.py b/ats/machines.py index 7e1fed3..750e2e7 100644 --- a/ats/machines.py +++ b/ats/machines.py @@ -500,7 +500,7 @@ def log_prepend(self, test, outhandle): if hasattr(test, 'rs_filename'): if os.path.isfile(test.rs_filename): - myfile = open(test.rs_filename, mode='r') + myfile = open(test.rs_filename, mode='r', errors=ignore) all_of_it = myfile.read() myfile.close() print("%sjsrun_rs =\n%s" % (magic, all_of_it), file=test.outhandle) diff --git a/ats/reportutils.py b/ats/reportutils.py index d4f117e..8f74710 100644 --- a/ats/reportutils.py +++ b/ats/reportutils.py @@ -127,7 +127,7 @@ def writeFailedCodeTestCase(f, test, err_path): msg = "" err_files = glob.glob(os.path.join(err_path, '*' + str(test.serialNumber) + '*.log.err')) if len(err_files) > 0: - with open(err_files[0], 'r') as logferr: + with open(err_files[0], 'r', errors='ignore') as logferr: # not readlines() - there are standard xml escapes to fix, we don't want to iterate over # the whole message. rawmsg = logferr.read() @@ -137,7 +137,7 @@ def writeFailedCodeTestCase(f, test, err_path): log_files = glob.glob(os.path.join(err_path, '*' + str(test.serialNumber) + '*.log')) if len(log_files) > 0: - with open(log_files[0], 'r') as logf: + with open(log_files[0], 'r', errors='ignore') as logf: rawmsg = logf.read() msg += "***** ats log file: *****\n running from clone code \n" msg += cleanErrorMessage(rawmsg) diff --git a/ats/tests.py b/ats/tests.py index 83b14b7..3656bee 100644 --- a/ats/tests.py +++ b/ats/tests.py @@ -631,7 +631,7 @@ def recordOutput (self, groupFailure): if self.testStdout != 'terminal': try: - f = open(self.outname, 'r') + f = open(self.outname, 'r', errors='ignore') except IOError as e: self.notes = ['Missing output file.'] log('Missing output file', self.outname, e)