diff options
author | Mats Wichmann <mats@linux.com> | 2021-10-23 14:39:40 (GMT) |
---|---|---|
committer | Mats Wichmann <mats@linux.com> | 2021-10-23 14:50:08 (GMT) |
commit | bf92ddc050fc3807ba2b8ff6116528f656e3197f (patch) | |
tree | d3388a37417882543f69116dd9ffde20b753d5bc /test | |
parent | f6cefb239a24f4662b4b06307d1c9099583a130e (diff) | |
download | SCons-bf92ddc050fc3807ba2b8ff6116528f656e3197f.zip SCons-bf92ddc050fc3807ba2b8ff6116528f656e3197f.tar.gz SCons-bf92ddc050fc3807ba2b8ff6116528f656e3197f.tar.bz2 |
Make subst call a callable with sig set properly
If the substable element is a callable, only set for_signature
true if the mode is SUBST_SIG. Previously it was set even if
the mode was SUBST_RAW.
Fixes #4037
Signed-off-by: Mats Wichmann <mats@linux.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/textfile/fixture/SConstruct.issue-4037 | 18 | ||||
-rw-r--r-- | test/textfile/issue-3540.py | 6 | ||||
-rw-r--r-- | test/textfile/issue-3550.py | 11 | ||||
-rw-r--r-- | test/textfile/issue-4037.py | 52 | ||||
-rw-r--r-- | test/textfile/textfile.py | 1 |
5 files changed, 80 insertions, 8 deletions
diff --git a/test/textfile/fixture/SConstruct.issue-4037 b/test/textfile/fixture/SConstruct.issue-4037 new file mode 100644 index 0000000..d5c8f96 --- /dev/null +++ b/test/textfile/fixture/SConstruct.issue-4037 @@ -0,0 +1,18 @@ +env = Environment() + +def generator(source, target, env, for_signature): + if for_signature: + return "sig" + return "val" + +env['GENERATOR'] = generator + +env.Textfile( + target="target", + source=[ + "@generated@", + ], + SUBST_DICT={ + '@generated@' : '$GENERATOR', + }, +) diff --git a/test/textfile/issue-3540.py b/test/textfile/issue-3540.py index 44a185b..3e24362 100644 --- a/test/textfile/issue-3540.py +++ b/test/textfile/issue-3540.py @@ -1,6 +1,8 @@ #!/usr/bin/env python # -# __COPYRIGHT__ +# MIT License +# +# Copyright The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -20,9 +22,7 @@ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" """ Test for GH Issue 3540 diff --git a/test/textfile/issue-3550.py b/test/textfile/issue-3550.py index de82ee2..199d95d 100644 --- a/test/textfile/issue-3550.py +++ b/test/textfile/issue-3550.py @@ -1,6 +1,8 @@ #!/usr/bin/env python # -# __COPYRIGHT__ +# MIT License +# +# Copyright The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -20,14 +22,13 @@ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" """ Test for GH Issue 3550 - You can't pass a Windows path in a value to be interpolated, - because SCons will try to pass it through re.sub which rejects certain character sequences. +You can't pass a Windows path in a value to be interpolated, +because SCons will try to pass it through re.sub which rejects +certain character sequences. """ import TestSCons diff --git a/test/textfile/issue-4037.py b/test/textfile/issue-4037.py new file mode 100644 index 0000000..b18b6ef --- /dev/null +++ b/test/textfile/issue-4037.py @@ -0,0 +1,52 @@ +#!/usr/bin/env python +# +# MIT License +# +# Copyright The SCons Foundation +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +""" +Test for GH Issue 4037 + +The fix for #4031 created a code path where the subst function +used by textfile was called with SUBST_RAW, which, if the items to +subst was a callable, caused it to be called with for_signature=True. +This did not happen previously as the test was "!= SUBST_CMD", +and the mode coming in was indeed SUBST_CMD. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +match_mode = 'r' + +test.file_fixture('fixture/SConstruct.issue-4037', 'SConstruct') + +test.run(arguments='.') + +test.must_match( + 'target.txt', + "val", + mode=match_mode, +) + +test.pass_test() diff --git a/test/textfile/textfile.py b/test/textfile/textfile.py index 936eaf5..a2d005c 100644 --- a/test/textfile/textfile.py +++ b/test/textfile/textfile.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# # MIT License # # Copyright The SCons Foundation |