diff --git a/reframe/utility/os_ext.py b/reframe/utility/os_ext.py index 92d12bad3e..5c9e761169 100644 --- a/reframe/utility/os_ext.py +++ b/reframe/utility/os_ext.py @@ -25,8 +25,8 @@ def run_command(cmd, check=False, timeout=None, shell=False): except subprocess.TimeoutExpired as e: os.killpg(proc.pid, signal.SIGKILL) raise SpawnedProcessTimeout(e.cmd, - proc.stdout, - proc.stderr, timeout) from None + proc.stdout.read(), + proc.stderr.read(), timeout) from None completed = subprocess.CompletedProcess(args=shlex.split(cmd), returncode=proc.returncode, diff --git a/unittests/test_utility.py b/unittests/test_utility.py index 4cc794439c..3e63942a91 100644 --- a/unittests/test_utility.py +++ b/unittests/test_utility.py @@ -26,9 +26,12 @@ def test_command_error(self): def test_command_timeout(self): try: os_ext.run_command('sleep 3', timeout=2) - self.fail('Expected timeout') except SpawnedProcessTimeout as e: self.assertEqual(e.timeout, 2) + # Try to get the string repr. of the exception: see bug #658 + s = str(e) + else: + self.fail('expected timeout') def test_command_async(self): from datetime import datetime