From c187c71f9a1dc867bf68e6837232975499146375 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Tue, 11 Feb 2020 10:10:40 -0800 Subject: Move testfile.py to testfile/ and have it use file_fixture() for SConstructs --- src/engine/SCons/Tool/textfile.py | 1 + test/textfile.py | 174 ------------------------------------- test/textfile/fixture/SConstruct | 20 +++++ test/textfile/fixture/SConstruct.2 | 24 +++++ test/textfile/textfile.py | 133 ++++++++++++++++++++++++++++ 5 files changed, 178 insertions(+), 174 deletions(-) delete mode 100644 test/textfile.py create mode 100644 test/textfile/fixture/SConstruct create mode 100644 test/textfile/fixture/SConstruct.2 create mode 100644 test/textfile/textfile.py diff --git a/src/engine/SCons/Tool/textfile.py b/src/engine/SCons/Tool/textfile.py index 48a2904..7ec9c78 100644 --- a/src/engine/SCons/Tool/textfile.py +++ b/src/engine/SCons/Tool/textfile.py @@ -71,6 +71,7 @@ def _do_subst(node, subs): contents = node.get_text_contents() if subs: for (k, val) in subs: + # contents = contents.replace(k, val) contents = re.sub(k, val, contents) if 'b' in TEXTFILE_FILE_WRITE_MODE: diff --git a/test/textfile.py b/test/textfile.py deleted file mode 100644 index 1d5b3c7..0000000 --- a/test/textfile.py +++ /dev/null @@ -1,174 +0,0 @@ -#!/usr/bin/env python -# -# __COPYRIGHT__ -# -# 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. -# - -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" - -import TestSCons - -import os - -test = TestSCons.TestSCons() - -foo1 = test.workpath('foo1.txt') -#foo2 = test.workpath('foo2.txt') -#foo1a = test.workpath('foo1a.txt') -#foo2a = test.workpath('foo2a.txt') - -match_mode = 'r' - -test.write('SConstruct', """ -env = Environment(tools=['textfile']) -data0 = ['Goethe', 'Schiller'] -data = ['lalala', 42, data0, 'tanteratei'] - -env.Textfile('foo1', data) -env.Textfile('foo2', data, LINESEPARATOR='|*') -env.Textfile('foo1a.txt', data + ['']) -env.Textfile('foo2a.txt', data + [''], LINESEPARATOR='|*') - -# recreate the list with the data wrapped in Value() -data0 = list(map(Value, data0)) -data = list(map(Value, data)) -data[2] = data0 - -env.Substfile('bar1', data) -env.Substfile('bar2', data, LINESEPARATOR='|*') -data.append(Value('')) -env.Substfile('bar1a.txt', data) -env.Substfile('bar2a.txt', data, LINESEPARATOR='|*') -""", mode='w') - -test.run(arguments='.') - -linesep = '\n' - -textparts = ['lalala', '42', - 'Goethe', 'Schiller', - 'tanteratei'] -foo1Text = linesep.join(textparts) -foo2Text = '|*'.join(textparts) -foo1aText = foo1Text + linesep -foo2aText = foo2Text + '|*' - -test.up_to_date(arguments='.') - -files = list(map(test.workpath, ( - 'foo1.txt', 'foo2.txt', 'foo1a.txt', 'foo2a.txt', - 'bar1', 'bar2', 'bar1a.txt', 'bar2a.txt', -))) - - -def check_times(): - """ - make sure the files didn't get rewritten, because nothing changed: - """ - before = list(map(os.path.getmtime, files)) - # introduce a small delay, to make the test valid - test.sleep() - # should still be up-to-date - test.up_to_date(arguments='.') - after = list(map(os.path.getmtime, files)) - test.fail_test(before != after) - - -# make sure that the file content is as expected -test.must_match('foo1.txt', foo1Text, mode=match_mode) -test.must_match('bar1', foo1Text, mode=match_mode) -test.must_match('foo2.txt', foo2Text, mode=match_mode) -test.must_match('bar2', foo2Text, mode=match_mode) -test.must_match('foo1a.txt', foo1aText, mode=match_mode) -test.must_match('bar1a.txt', foo1aText, mode=match_mode) -test.must_match('foo2a.txt', foo2aText, mode=match_mode) -test.must_match('bar2a.txt', foo2aText, mode=match_mode) -check_times() - -# write the contents and make sure the files -# didn't get rewritten, because nothing changed: -test.write('foo1.txt', foo1Text) -test.write('bar1', foo1Text) -test.write('foo2.txt', foo2Text) -test.write('bar2', foo2Text) -test.write('foo1a.txt', foo1aText) -test.write('bar1a.txt', foo1aText) -test.write('foo2a.txt', foo2aText) -test.write('bar2a.txt', foo2aText) -check_times() - -# now that textfile is part of default tool list, run one testcase -# without adding it explicitly as a tool to make sure. -test.write('SConstruct', """ -textlist = ['This line has no substitutions', - 'This line has @subst@ substitutions', - 'This line has %subst% substitutions', - ] - -sub1 = { '@subst@' : 'most' } -sub2 = { '%subst%' : 'many' } -sub3 = { '@subst@' : 'most' , '%subst%' : 'many' } - -env = Environment() - -t = env.Textfile('text', textlist) -# no substitutions -s = env.Substfile('sub1', t) -# one substitution -s = env.Substfile('sub2', s, SUBST_DICT = sub1) -# the other substution -s = env.Substfile('sub3', s, SUBST_DICT = sub2) -# the reverse direction -s = env.Substfile('sub4', t, SUBST_DICT = sub2) -s = env.Substfile('sub5', s, SUBST_DICT = sub1) -# both -s = env.Substfile('sub6', t, SUBST_DICT = sub3) -""", mode='w') - -test.run(arguments='.') - -line1 = 'This line has no substitutions' -line2a = 'This line has @subst@ substitutions' -line2b = 'This line has most substitutions' -line3a = 'This line has %subst% substitutions' -line3b = 'This line has many substitutions' - - -def matchem(match_file, lines): - """ - Join all the lines with correct line separator, - then compare - """ - lines = linesep.join(lines) - test.must_match(match_file, lines, mode=match_mode, message="Expected:\n%s\n"%lines) - - -matchem('text.txt', [line1, line2a, line3a]) -matchem('sub1', [line1, line2a, line3a]) -matchem('sub2', [line1, line2b, line3a]) -matchem('sub3', [line1, line2b, line3b]) -matchem('sub4', [line1, line2a, line3b]) -matchem('sub5', [line1, line2b, line3b]) -matchem('sub6', [line1, line2b, line3b]) - -test.up_to_date(arguments='.') - -test.pass_test() diff --git a/test/textfile/fixture/SConstruct b/test/textfile/fixture/SConstruct new file mode 100644 index 0000000..df64106 --- /dev/null +++ b/test/textfile/fixture/SConstruct @@ -0,0 +1,20 @@ + +env = Environment(tools=['textfile']) +data0 = ['Goethe', 'Schiller'] +data = ['lalala', 42, data0, 'tanteratei'] + +env.Textfile('foo1', data) +env.Textfile('foo2', data, LINESEPARATOR='|*') +env.Textfile('foo1a.txt', data + ['']) +env.Textfile('foo2a.txt', data + [''], LINESEPARATOR='|*') + +# recreate the list with the data wrapped in Value() +data0 = list(map(Value, data0)) +data = list(map(Value, data)) +data[2] = data0 + +env.Substfile('bar1', data) +env.Substfile('bar2', data, LINESEPARATOR='|*') +data.append(Value('')) +env.Substfile('bar1a.txt', data) +env.Substfile('bar2a.txt', data, LINESEPARATOR='|*') diff --git a/test/textfile/fixture/SConstruct.2 b/test/textfile/fixture/SConstruct.2 new file mode 100644 index 0000000..32fd767 --- /dev/null +++ b/test/textfile/fixture/SConstruct.2 @@ -0,0 +1,24 @@ + +textlist = ['This line has no substitutions', + 'This line has @subst@ substitutions', + 'This line has %subst% substitutions', + ] + +sub1 = { '@subst@' : 'most' } +sub2 = { '%subst%' : 'many' } +sub3 = { '@subst@' : 'most' , '%subst%' : 'many' } + +env = Environment() + +t = env.Textfile('text', textlist) +# no substitutions +s = env.Substfile('sub1', t) +# one substitution +s = env.Substfile('sub2', s, SUBST_DICT = sub1) +# the other substution +s = env.Substfile('sub3', s, SUBST_DICT = sub2) +# the reverse direction +s = env.Substfile('sub4', t, SUBST_DICT = sub2) +s = env.Substfile('sub5', s, SUBST_DICT = sub1) +# both +s = env.Substfile('sub6', t, SUBST_DICT = sub3) diff --git a/test/textfile/textfile.py b/test/textfile/textfile.py new file mode 100644 index 0000000..7b542e0 --- /dev/null +++ b/test/textfile/textfile.py @@ -0,0 +1,133 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# 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. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +import TestSCons + +import os + +test = TestSCons.TestSCons() + +test.verbose_set(1) + +foo1 = test.workpath('foo1.txt') +#foo2 = test.workpath('foo2.txt') +#foo1a = test.workpath('foo1a.txt') +#foo2a = test.workpath('foo2a.txt') + +match_mode = 'r' + +test.file_fixture('fixture/SConstruct','SConstruct') + +test.run(arguments='.') + +linesep = '\n' + +textparts = ['lalala', '42', + 'Goethe', 'Schiller', + 'tanteratei'] +foo1Text = linesep.join(textparts) +foo2Text = '|*'.join(textparts) +foo1aText = foo1Text + linesep +foo2aText = foo2Text + '|*' + +test.up_to_date(arguments='.') + +files = list(map(test.workpath, ( + 'foo1.txt', 'foo2.txt', 'foo1a.txt', 'foo2a.txt', + 'bar1', 'bar2', 'bar1a.txt', 'bar2a.txt', +))) + + +def check_times(): + """ + make sure the files didn't get rewritten, because nothing changed: + """ + before = list(map(os.path.getmtime, files)) + # introduce a small delay, to make the test valid + test.sleep() + # should still be up-to-date + test.up_to_date(arguments='.') + after = list(map(os.path.getmtime, files)) + test.fail_test(before != after) + + +# make sure that the file content is as expected +test.must_match('foo1.txt', foo1Text, mode=match_mode) +test.must_match('bar1', foo1Text, mode=match_mode) +test.must_match('foo2.txt', foo2Text, mode=match_mode) +test.must_match('bar2', foo2Text, mode=match_mode) +test.must_match('foo1a.txt', foo1aText, mode=match_mode) +test.must_match('bar1a.txt', foo1aText, mode=match_mode) +test.must_match('foo2a.txt', foo2aText, mode=match_mode) +test.must_match('bar2a.txt', foo2aText, mode=match_mode) +check_times() + +# write the contents and make sure the files +# didn't get rewritten, because nothing changed: +test.write('foo1.txt', foo1Text) +test.write('bar1', foo1Text) +test.write('foo2.txt', foo2Text) +test.write('bar2', foo2Text) +test.write('foo1a.txt', foo1aText) +test.write('bar1a.txt', foo1aText) +test.write('foo2a.txt', foo2aText) +test.write('bar2a.txt', foo2aText) +check_times() + +# now that textfile is part of default tool list, run one testcase +# without adding it explicitly as a tool to make sure. +test.file_fixture('fixture/SConstruct.2','SConstruct.2') + + +test.run(options='-f SConstruct.2', arguments='.') + +line1 = 'This line has no substitutions' +line2a = 'This line has @subst@ substitutions' +line2b = 'This line has most substitutions' +line3a = 'This line has %subst% substitutions' +line3b = 'This line has many substitutions' + + +def matchem(match_file, lines): + """ + Join all the lines with correct line separator, + then compare + """ + lines = linesep.join(lines) + test.must_match(match_file, lines, mode=match_mode, message="Expected:\n%s\n"%lines) + + +matchem('text.txt', [line1, line2a, line3a]) +matchem('sub1', [line1, line2a, line3a]) +matchem('sub2', [line1, line2b, line3a]) +matchem('sub3', [line1, line2b, line3b]) +matchem('sub4', [line1, line2a, line3b]) +matchem('sub5', [line1, line2b, line3b]) +matchem('sub6', [line1, line2b, line3b]) + +test.up_to_date(options='-f SConstruct.2', arguments='.') + +test.pass_test() -- cgit v0.12 From 89c21459719a5069b0e804cfc7241f02455f4c90 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Tue, 11 Feb 2020 11:05:28 -0800 Subject: Add tests for issue 3550 --- test/textfile/fixture/SConstruct | 4 ++- test/textfile/fixture/SConstruct.2 | 21 ++++++------- test/textfile/fixture/SConstruct.issue-3550 | 12 ++++++++ test/textfile/fixture/foo-3550.in | 1 + test/textfile/issue-3550.py | 46 +++++++++++++++++++++++++++++ test/textfile/textfile.py | 33 ++++++++++----------- 6 files changed, 88 insertions(+), 29 deletions(-) create mode 100644 test/textfile/fixture/SConstruct.issue-3550 create mode 100644 test/textfile/fixture/foo-3550.in create mode 100644 test/textfile/issue-3550.py diff --git a/test/textfile/fixture/SConstruct b/test/textfile/fixture/SConstruct index df64106..8cfe909 100644 --- a/test/textfile/fixture/SConstruct +++ b/test/textfile/fixture/SConstruct @@ -1,7 +1,9 @@ +DefaultEnvironment(tools=[]) + env = Environment(tools=['textfile']) data0 = ['Goethe', 'Schiller'] -data = ['lalala', 42, data0, 'tanteratei'] +data = ['lalala', 42, data0, 'tanteratei'] env.Textfile('foo1', data) env.Textfile('foo2', data, LINESEPARATOR='|*') diff --git a/test/textfile/fixture/SConstruct.2 b/test/textfile/fixture/SConstruct.2 index 32fd767..b7e63a1 100644 --- a/test/textfile/fixture/SConstruct.2 +++ b/test/textfile/fixture/SConstruct.2 @@ -1,24 +1,25 @@ +DefaultEnvironment(tools=[]) textlist = ['This line has no substitutions', 'This line has @subst@ substitutions', 'This line has %subst% substitutions', - ] + ] -sub1 = { '@subst@' : 'most' } -sub2 = { '%subst%' : 'many' } -sub3 = { '@subst@' : 'most' , '%subst%' : 'many' } +sub1 = {'@subst@': 'most'} +sub2 = {'%subst%': 'many'} +sub3 = {'@subst@': 'most', '%subst%': 'many'} -env = Environment() +env = Environment(tools=['textfile']) t = env.Textfile('text', textlist) # no substitutions s = env.Substfile('sub1', t) # one substitution -s = env.Substfile('sub2', s, SUBST_DICT = sub1) +s = env.Substfile('sub2', s, SUBST_DICT=sub1) # the other substution -s = env.Substfile('sub3', s, SUBST_DICT = sub2) +s = env.Substfile('sub3', s, SUBST_DICT=sub2) # the reverse direction -s = env.Substfile('sub4', t, SUBST_DICT = sub2) -s = env.Substfile('sub5', s, SUBST_DICT = sub1) +s = env.Substfile('sub4', t, SUBST_DICT=sub2) +s = env.Substfile('sub5', s, SUBST_DICT=sub1) # both -s = env.Substfile('sub6', t, SUBST_DICT = sub3) +s = env.Substfile('sub6', t, SUBST_DICT=sub3) diff --git a/test/textfile/fixture/SConstruct.issue-3550 b/test/textfile/fixture/SConstruct.issue-3550 new file mode 100644 index 0000000..8502717 --- /dev/null +++ b/test/textfile/fixture/SConstruct.issue-3550 @@ -0,0 +1,12 @@ +DefaultEnvironment(tools=[]) +env = Environment(tools=['textfile']) + +env['FOO_PATH'] = r'Z:\mongo\build\install\bin' + +foo = env.Substfile( + target="foo", + source="foo-3550.in", + SUBST_DICT={ + "@foo_path@": "$FOO_PATH", + } +) diff --git a/test/textfile/fixture/foo-3550.in b/test/textfile/fixture/foo-3550.in new file mode 100644 index 0000000..c806a04 --- /dev/null +++ b/test/textfile/fixture/foo-3550.in @@ -0,0 +1 @@ +foo_path: @foo_path@ diff --git a/test/textfile/issue-3550.py b/test/textfile/issue-3550.py new file mode 100644 index 0000000..3c9425a --- /dev/null +++ b/test/textfile/issue-3550.py @@ -0,0 +1,46 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# 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. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +import TestSCons + +import os + +test = TestSCons.TestSCons() + +test.verbose_set(1) + +match_mode = 'r' + +test.file_fixture('fixture/SConstruct.issue-3550', 'SConstruct') +test.file_fixture('fixture/foo-3550.in', 'foo-3550.in') + +test.run(arguments='.') + +test.must_match('foo', + r'''foo_path: Z:\mongo\build\install\bin +''', mode=match_mode) + +test.pass_test() diff --git a/test/textfile/textfile.py b/test/textfile/textfile.py index 7b542e0..0f2e18e 100644 --- a/test/textfile/textfile.py +++ b/test/textfile/textfile.py @@ -30,16 +30,14 @@ import os test = TestSCons.TestSCons() -test.verbose_set(1) - foo1 = test.workpath('foo1.txt') -#foo2 = test.workpath('foo2.txt') -#foo1a = test.workpath('foo1a.txt') -#foo2a = test.workpath('foo2a.txt') +# foo2 = test.workpath('foo2.txt') +# foo1a = test.workpath('foo1a.txt') +# foo2a = test.workpath('foo2a.txt') match_mode = 'r' -test.file_fixture('fixture/SConstruct','SConstruct') +test.file_fixture('fixture/SConstruct', 'SConstruct') test.run(arguments='.') @@ -57,7 +55,7 @@ test.up_to_date(arguments='.') files = list(map(test.workpath, ( 'foo1.txt', 'foo2.txt', 'foo1a.txt', 'foo2a.txt', - 'bar1', 'bar2', 'bar1a.txt', 'bar2a.txt', + 'bar1', 'bar2', 'bar1a.txt', 'bar2a.txt', ))) @@ -75,10 +73,10 @@ def check_times(): # make sure that the file content is as expected -test.must_match('foo1.txt', foo1Text, mode=match_mode) -test.must_match('bar1', foo1Text, mode=match_mode) -test.must_match('foo2.txt', foo2Text, mode=match_mode) -test.must_match('bar2', foo2Text, mode=match_mode) +test.must_match('foo1.txt', foo1Text, mode=match_mode) +test.must_match('bar1', foo1Text, mode=match_mode) +test.must_match('foo2.txt', foo2Text, mode=match_mode) +test.must_match('bar2', foo2Text, mode=match_mode) test.must_match('foo1a.txt', foo1aText, mode=match_mode) test.must_match('bar1a.txt', foo1aText, mode=match_mode) test.must_match('foo2a.txt', foo2aText, mode=match_mode) @@ -87,10 +85,10 @@ check_times() # write the contents and make sure the files # didn't get rewritten, because nothing changed: -test.write('foo1.txt', foo1Text) -test.write('bar1', foo1Text) -test.write('foo2.txt', foo2Text) -test.write('bar2', foo2Text) +test.write('foo1.txt', foo1Text) +test.write('bar1', foo1Text) +test.write('foo2.txt', foo2Text) +test.write('bar2', foo2Text) test.write('foo1a.txt', foo1aText) test.write('bar1a.txt', foo1aText) test.write('foo2a.txt', foo2aText) @@ -99,8 +97,7 @@ check_times() # now that textfile is part of default tool list, run one testcase # without adding it explicitly as a tool to make sure. -test.file_fixture('fixture/SConstruct.2','SConstruct.2') - +test.file_fixture('fixture/SConstruct.2', 'SConstruct.2') test.run(options='-f SConstruct.2', arguments='.') @@ -117,7 +114,7 @@ def matchem(match_file, lines): then compare """ lines = linesep.join(lines) - test.must_match(match_file, lines, mode=match_mode, message="Expected:\n%s\n"%lines) + test.must_match(match_file, lines, mode=match_mode, message="Expected:\n%s\n" % lines) matchem('text.txt', [line1, line2a, line3a]) -- cgit v0.12 From c40509ba4e1b466dd03f8984e8169448c6cfa20a Mon Sep 17 00:00:00 2001 From: William Deegan Date: Tue, 11 Feb 2020 11:06:33 -0800 Subject: Fix issue #3550 - Substfile() can fail/crash when using windows paths as \'s are interpreted instead of simply used to replace text. Switch to using str.replace() --- src/engine/SCons/Tool/textfile.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/engine/SCons/Tool/textfile.py b/src/engine/SCons/Tool/textfile.py index 7ec9c78..c233658 100644 --- a/src/engine/SCons/Tool/textfile.py +++ b/src/engine/SCons/Tool/textfile.py @@ -71,8 +71,7 @@ def _do_subst(node, subs): contents = node.get_text_contents() if subs: for (k, val) in subs: - # contents = contents.replace(k, val) - contents = re.sub(k, val, contents) + contents = contents.replace(k, val) if 'b' in TEXTFILE_FILE_WRITE_MODE: try: -- cgit v0.12 From 7d80f0ca5f9e752118141bd9c7de9350cd6b8597 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Tue, 11 Feb 2020 11:08:56 -0800 Subject: [ci skip] Update CHANGES.txt --- src/CHANGES.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 407a83b..b1cc831 100755 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -18,6 +18,9 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER is a reasonable default and also aligns with changes in Appveyor's VS2019 image. - Drop support for Python 2.7. SCons will be Python 3.5+ going forward. - Change SCons.Node.ValueWithMemo to consider any name passed when memoizing Value() nodes + - Fix Github Issue #3550 - When using Substfile() with a value like Z:\mongo\build\install\bin + the implementation using re.sub() would end up interpreting the string and finding regex escape + characters where it should have been simply replacing existing text. Switched to use string.replace(). From Jeremy Elson: - Updated design doc to use the correct syntax for Depends() -- cgit v0.12 From 74ac8dce11d14c2e33932b11ff88404f45ad3b08 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Tue, 11 Feb 2020 11:15:36 -0800 Subject: Resolve sider complaint --- test/textfile/issue-3550.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/textfile/issue-3550.py b/test/textfile/issue-3550.py index 3c9425a..60430ed 100644 --- a/test/textfile/issue-3550.py +++ b/test/textfile/issue-3550.py @@ -26,8 +26,6 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -import os - test = TestSCons.TestSCons() test.verbose_set(1) -- cgit v0.12