From 47cb6c10306d89172ce6aafa09a450e85f4a8f8d Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Mon, 19 Oct 2015 21:50:03 +0300 Subject: [PATCH] More robust output decoding. Closes #289. --- meson_test.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/meson_test.py b/meson_test.py index 9353b1841..8061215f9 100755 --- a/meson_test.py +++ b/meson_test.py @@ -38,6 +38,12 @@ class TestRun(): self.stde = stde self.cmd = cmd +def decode(stream): + try: + return stream.decode('utf-8') + except UnicodeDecodeError: + return stream.decode('iso-8859-1', errors='ignore') + def write_log(logfile, test_name, result_str, result): logfile.write(result_str + '\n\n') logfile.write('--- command ---\n') @@ -108,8 +114,8 @@ def run_single_test(wrap, test): (stdo, stde) = p.communicate() endtime = time.time() duration = endtime - starttime - stdo = stdo.decode() - stde = stde.decode() + stdo = decode(stdo) + stde = decode(stde) if timed_out: res = 'TIMEOUT' tests_failed = True