From 94543c137c01f836547467bc711969407cb76ba3 Mon Sep 17 00:00:00 2001 From: djh <1810493+djh82@users.noreply.github.com> Date: Mon, 22 Mar 2021 17:36:51 +0000 Subject: fix: allows IMPLICIT_COMMAND_DEPENDENCIES to have false-like values supplied --- CHANGES.txt | 3 +++ SCons/Action.py | 4 ++-- SCons/ActionTests.py | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 03d563dab..3cf6b75d9 100755 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -18,6 +18,9 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER creating the symlinks (and adding version string to ) dlls. It sets SHLIBNOVERSIONSYMLINKS, IMPLIBNOVERSIONSYMLINKS and LDMODULENOVERSIONSYMLINKS to True. + From David H: + - Fix Issue #3906 - `IMPLICIT_COMMAND_DEPENDENCIES` is not disabled when 'false-like values' are supplied. + From Daniel Moody: - Update CacheDir to use uuid for tmpfile uniqueness instead of pid. This fixes cases for shared cache where two systems write to the same diff --git a/SCons/Action.py b/SCons/Action.py index efdf94492..c5d3ea947 100644 --- a/SCons/Action.py +++ b/SCons/Action.py @@ -968,7 +968,7 @@ class CommandAction(_ActionAction): if is_String(icd) and icd[:1] == '$': icd = env.subst(icd) - if not icd or str(icd).lower in ('0', 'none', 'false', 'no', 'off'): + if not icd or str(icd).lower() in ('0', 'none', 'false', 'no', 'off'): return [] try: @@ -976,7 +976,7 @@ class CommandAction(_ActionAction): except ValueError: icd_int = None - if (icd_int and icd_int > 1) or icd == 'all': + if (icd_int and icd_int > 1) or str(icd).lower() == 'all': # An integer value greater than 1 specifies the number of entries # to scan. "all" means to scan all. return self._get_implicit_deps_heavyweight(target, source, env, executor, icd_int) diff --git a/SCons/ActionTests.py b/SCons/ActionTests.py index dff7e0c9d..dd816bba7 100644 --- a/SCons/ActionTests.py +++ b/SCons/ActionTests.py @@ -1371,6 +1371,43 @@ class CommandActionTestCase(unittest.TestCase): c = a.get_contents(target=t, source=s, env=env) assert c == b"s4 s5", c + def test_get_implicit_deps(self): + """Test getting the implicit dependencies of a command Action.""" + class SpecialEnvironment(Environment): + def WhereIs(self, prog): + return prog + + class fs: + def File(name): + return name + + env = SpecialEnvironment() + a = SCons.Action.CommandAction([_python_, exit_py]) + self.assertEqual(a.get_implicit_deps(target=[], source=[], env=env), [_python_]) + + for false_like_value in [False, 0, None, "None", "False", "0", "NONE", "FALSE", "off", "OFF", "NO", "no"]: + env = SpecialEnvironment(IMPLICIT_COMMAND_DEPENDENCIES=false_like_value) + a = SCons.Action.CommandAction([_python_, exit_py]) + self.assertEqual(a.get_implicit_deps(target=[], source=[], env=env), []) + + env = SpecialEnvironment(IMPLICIT_COMMAND_DEPENDENCIES="$SUBST_VALUE", SUBST_VALUE=false_like_value) + a = SCons.Action.CommandAction([_python_, exit_py]) + self.assertEqual(a.get_implicit_deps(target=[], source=[], env=env), []) + + for true_like_value in [True, 1, "True", "TRUE", "1"]: + env = SpecialEnvironment(IMPLICIT_COMMAND_DEPENDENCIES=true_like_value) + a = SCons.Action.CommandAction([_python_, exit_py]) + self.assertEqual(a.get_implicit_deps(target=[], source=[], env=env), [_python_]) + + env = SpecialEnvironment(IMPLICIT_COMMAND_DEPENDENCIES="$SUBST_VALUE", SUBST_VALUE=true_like_value) + a = SCons.Action.CommandAction([_python_, exit_py]) + self.assertEqual(a.get_implicit_deps(target=[], source=[], env=env), [_python_]) + + for all_like_Value in ["all", "ALL", 2, "2"]: + env = SpecialEnvironment(IMPLICIT_COMMAND_DEPENDENCIES=all_like_Value) + a = SCons.Action.CommandAction([_python_, exit_py]) + self.assertEqual(a.get_implicit_deps(target=[], source=[], env=env), [_python_, exit_py]) + class CommandGeneratorActionTestCase(unittest.TestCase): -- cgit v1.2.1