summaryrefslogtreecommitdiffstats
path: root/testing
diff options
context:
space:
mode:
authorMats Wichmann <mats@linux.com>2022-04-05 18:29:32 (GMT)
committerMats Wichmann <mats@linux.com>2022-04-05 18:29:32 (GMT)
commitf0f5657f3214bf50f56cf076c9ecbe37c1fd0d75 (patch)
tree95d11da9cdf402136b10447c88e622ed7a2c1222 /testing
parent4b8a75d285cad857f491d4aca45a9eeab077a62f (diff)
downloadSCons-f0f5657f3214bf50f56cf076c9ecbe37c1fd0d75.zip
SCons-f0f5657f3214bf50f56cf076c9ecbe37c1fd0d75.tar.gz
SCons-f0f5657f3214bf50f56cf076c9ecbe37c1fd0d75.tar.bz2
test framework: fix exception on timeout
If the framework wait_for() method actually times out, it tries to return stdout and stderr by calling the framework methods of those names. The stdout() method was protected against the message not having been captured (as is the case on timeout). Updated the stderr() method to use the same technique. Signed-off-by: Mats Wichmann <mats@linux.com>
Diffstat (limited to 'testing')
-rw-r--r--testing/framework/TestCmd.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/testing/framework/TestCmd.py b/testing/framework/TestCmd.py
index 79b16f5..5759121 100644
--- a/testing/framework/TestCmd.py
+++ b/testing/framework/TestCmd.py
@@ -311,6 +311,7 @@ import time
import traceback
from collections import UserList, UserString
from subprocess import PIPE, STDOUT
+from typing import Optional
IS_WINDOWS = sys.platform == 'win32'
IS_MACOS = sys.platform == 'darwin'
@@ -1641,7 +1642,7 @@ class TestCmd:
"""
time.sleep(seconds)
- def stderr(self, run=None):
+ def stderr(self, run=None) -> Optional[str]:
"""Returns the error output from the specified run number.
If there is no specified run number, then returns the error
@@ -1653,10 +1654,13 @@ class TestCmd:
run = len(self._stderr)
elif run < 0:
run = len(self._stderr) + run
- run = run - 1
- return self._stderr[run]
+ run -= 1
+ try:
+ return self._stderr[run]
+ except IndexError:
+ return None
- def stdout(self, run=None):
+ def stdout(self, run=None) -> Optional[str]:
"""Returns the stored standard output from a given run.
Args:
@@ -1673,7 +1677,7 @@ class TestCmd:
run = len(self._stdout)
elif run < 0:
run = len(self._stdout) + run
- run = run - 1
+ run -= 1
try:
return self._stdout[run]
except IndexError: