summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Deegan <bill@baddogconsulting.com>2023-02-10 17:41:38 -0800
committerWilliam Deegan <bill@baddogconsulting.com>2023-02-10 17:41:38 -0800
commite37f8b71a89adebae1592edca7c5371d50322e42 (patch)
treecf2c3246794304d4b0b4625a48ee486b9a136254
parent0f7b5fbae63e3486255b2b9951373075d55a9a58 (diff)
downloadscons-git-e37f8b71a89adebae1592edca7c5371d50322e42.tar.gz
Added DefaultEnvironment(tools=[]) to fixtures for CPPDEFINES. Added negative test for non-two-tuple. Minor wording change
-rw-r--r--SCons/Defaults.py4
-rw-r--r--SCons/DefaultsTests.py10
-rw-r--r--test/CPPDEFINES/fixture/SConstruct-Append2
-rw-r--r--test/CPPDEFINES/fixture/SConstruct-Prepend1
4 files changed, 15 insertions, 2 deletions
diff --git a/SCons/Defaults.py b/SCons/Defaults.py
index ea7e9308f..72af1bd98 100644
--- a/SCons/Defaults.py
+++ b/SCons/Defaults.py
@@ -530,7 +530,7 @@ def processDefines(defs) -> List[str]:
if len(define) > 2:
raise SCons.Errors.UserError(
f"Invalid tuple in CPPDEFINES: {define!r}, "
- "must be a two-tuple"
+ "must be a tuple with only two elements"
)
name, *value = define
if value and value[0] is not None:
@@ -556,7 +556,7 @@ def processDefines(defs) -> List[str]:
if len(defs) > 2:
raise SCons.Errors.UserError(
f"Invalid tuple in CPPDEFINES: {defs!r}, "
- "must be a two-tuple"
+ "must be a tuple with only two elements"
)
name, *value = defs
if value and value[0] is not None:
diff --git a/SCons/DefaultsTests.py b/SCons/DefaultsTests.py
index c9a666311..66e219a89 100644
--- a/SCons/DefaultsTests.py
+++ b/SCons/DefaultsTests.py
@@ -28,6 +28,7 @@ import collections
import TestCmd
from SCons.Defaults import mkdir_func, _defines, processDefines
+from SCons.Errors import UserError
class DummyEnvironment(collections.UserDict):
@@ -144,6 +145,15 @@ class DefaultsTestCase(unittest.TestCase):
rv = processDefines(['foo', ('name', 'val'), ['name2', 'val2']])
self.assertEqual(rv, ['foo', 'name=val', 'name2=val2'])
+ with self.subTest():
+ # invalid tuple
+ try:
+ rv = processDefines([('name', 'val', 'bad')])
+ except UserError as e:
+ pass
+ else:
+ self.fail("Invalid tuple should throw SCons.Errors.UserError")
+
if __name__ == "__main__":
unittest.main()
diff --git a/test/CPPDEFINES/fixture/SConstruct-Append b/test/CPPDEFINES/fixture/SConstruct-Append
index 62d7352d4..1149fc33b 100644
--- a/test/CPPDEFINES/fixture/SConstruct-Append
+++ b/test/CPPDEFINES/fixture/SConstruct-Append
@@ -1,3 +1,5 @@
+DefaultEnvironment(tools=[])
+
# Special cases:
# https://github.com/SCons/scons/issues/1738
env_1738_2 = Environment(CPPDEFPREFIX='-D')
diff --git a/test/CPPDEFINES/fixture/SConstruct-Prepend b/test/CPPDEFINES/fixture/SConstruct-Prepend
index 4234de260..67d637cd4 100644
--- a/test/CPPDEFINES/fixture/SConstruct-Prepend
+++ b/test/CPPDEFINES/fixture/SConstruct-Prepend
@@ -1,3 +1,4 @@
+DefaultEnvironment(tools=[])
# Special cases:
# https://github.com/SCons/scons/issues/1738
env_1738_2 = Environment(CPPDEFPREFIX='-D')