From d5e8a048c87eac0361f14911a2d224bfb94884f0 Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Tue, 30 Oct 2018 13:37:20 -0600 Subject: Fix some problems found if no MS compiler at all A few tests blew up with exceptions (AttributeError, IndexError) if no compiler is installed on Windows - from where they are it could possibly happen on other platforms as well. Signed-off-by: Mats Wichmann --- src/CHANGES.txt | 1 + testing/framework/TestCmd.py | 5 ++++- testing/framework/TestSCons.py | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index ddc7e60..f26769d 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -165,6 +165,7 @@ RELEASE 3.1.0.alpha.yyyymmdd - NEW DATE WILL BE INSERTED HERE Three uses of variables not defined are changed. - Some script changes in trying to find scons engine - Update (pep8) configure-cache script, add a --show option. + - Fix for a couple of "what if tool not found" exceptions in framework. From Bernhard M. Wiedemann: - Update SCons' internal scons build logic to allow overriding build date diff --git a/testing/framework/TestCmd.py b/testing/framework/TestCmd.py index 96b8b5d..6699d88 100644 --- a/testing/framework/TestCmd.py +++ b/testing/framework/TestCmd.py @@ -1590,7 +1590,10 @@ class TestCmd(object): elif run < 0: run = len(self._stdout) + run run = run - 1 - return self._stdout[run] + try: + return self._stdout[run] + except IndexError: + return None def subdir(self, *subdirs): """Create new subdirectories under the temporary working diff --git a/testing/framework/TestSCons.py b/testing/framework/TestSCons.py index 68641f0..69d4bd5 100644 --- a/testing/framework/TestSCons.py +++ b/testing/framework/TestSCons.py @@ -310,7 +310,7 @@ class TestSCons(TestCommon): if v != prog: return None result = env.WhereIs(prog) - if norm and os.sep != '/': + if result and norm and os.sep != '/': result = result.replace(os.sep, '/') return result -- cgit v0.12 From 218cee62225eb816258a76063fc2c62cdbf42be5 Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Mon, 5 Nov 2018 11:41:05 -0700 Subject: For PR #3231, update some docstrings per review Signed-off-by: Mats Wichmann --- testing/framework/TestCmd.py | 17 ++++++++++++----- testing/framework/TestSCons.py | 23 ++++++++++++++++------- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/testing/framework/TestCmd.py b/testing/framework/TestCmd.py index 6699d88..cccbccb 100644 --- a/testing/framework/TestCmd.py +++ b/testing/framework/TestCmd.py @@ -1579,11 +1579,18 @@ class TestCmd(object): return self._stderr[run] def stdout(self, run=None): - """Returns the standard output from the specified run number. - If there is no specified run number, then returns the standard - output of the last run. If the run number is less than zero, - then returns the standard output from that many runs back from - the current run. + """ + Returns the stored standard output from a given run. + + Args: + run: run number to select. If run number is omitted, + return the standard output of the most recent run. + If negative, use as a relative offset, so that -2 + means the run two prior to the most recent. + + Returns: + selected stdout string or None if there are no + stored runs. """ if not run: run = len(self._stdout) diff --git a/testing/framework/TestSCons.py b/testing/framework/TestSCons.py index 69d4bd5..c3018f0 100644 --- a/testing/framework/TestSCons.py +++ b/testing/framework/TestSCons.py @@ -293,16 +293,25 @@ class TestSCons(TestCommon): def detect(self, var, prog=None, ENV=None, norm=None): """ - Detect a program named 'prog' by first checking the construction - variable named 'var' and finally searching the path used by - SCons. If either method fails to detect the program, then false - is returned, otherwise the full path to prog is returned. If - prog is None, then the value of the environment variable will be - used as prog. + Return the detected path to a tool program. + + Searches first the named construction variable, then + the SCons path. + + Args: + var: name of construction variable to check for tool name. + prog: tool program to check for. + ENV: if present, kwargs to initialize an environment that + will be created to perform the lookup. + norm: if true, normalize any returned path looked up in + the environment to use UNIX-style path separators. + + Returns: full path to the tool, or None. + """ env = self.Environment(ENV) if env: - v = env.subst('$'+var) + v = env.subst('$' + var) if not v: return None if prog is None: -- cgit v0.12