From 03dbdfc91995b4b9bd3360eafa0dead73a7019d3 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sat, 15 Feb 2020 20:36:39 -0800 Subject: Fix Issue #2904 - add useful error message when more than one Configure() contexts are opened --- src/engine/SCons/SConf.py | 3 +- test/Configure/fixture/SConstruct.issue-2906 | 5 ++ ...ssue-2906-useful-duplicate-configure-message.py | 57 ++++++++++++++++++++++ 3 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 test/Configure/fixture/SConstruct.issue-2906 create mode 100644 test/Configure/issue-2906-useful-duplicate-configure-message.py diff --git a/src/engine/SCons/SConf.py b/src/engine/SCons/SConf.py index 50a1329..a5e443e 100644 --- a/src/engine/SCons/SConf.py +++ b/src/engine/SCons/SConf.py @@ -430,7 +430,8 @@ class SConfBase(object): SConfFS = SCons.Node.FS.default_fs or \ SCons.Node.FS.FS(env.fs.pathTop) if sconf_global is not None: - raise SCons.Errors.UserError + raise SCons.Errors.UserError("""User Called Configure() when another Configure() exists. + Please call .Finish() before creating and second Configure() context""") if log_file is not None: log_file = SConfFS.File(env.subst(log_file)) diff --git a/test/Configure/fixture/SConstruct.issue-2906 b/test/Configure/fixture/SConstruct.issue-2906 new file mode 100644 index 0000000..7763653 --- /dev/null +++ b/test/Configure/fixture/SConstruct.issue-2906 @@ -0,0 +1,5 @@ +env = Environment() +conf1 = Configure(env) +env2 = Environment() +# Error right here. You can't have two configure contexts in flight at the same time. +conf2 = Configure(env2) \ No newline at end of file diff --git a/test/Configure/issue-2906-useful-duplicate-configure-message.py b/test/Configure/issue-2906-useful-duplicate-configure-message.py new file mode 100644 index 0000000..716cb33 --- /dev/null +++ b/test/Configure/issue-2906-useful-duplicate-configure-message.py @@ -0,0 +1,57 @@ +#!/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__" + +""" +Verify useful error message when you create a second Configure context without +finalizing the previous one via conf.Finish() +This addresses Issue 2906: +https://github.com/SCons/scons/issues/2906 +""" + +import TestSCons + +test = TestSCons.TestSCons() +test.verbose_set(1) + +test.file_fixture('./fixture/SConstruct.issue-2906', 'SConstruct') + +test_SConstruct_path = test.workpath('SConstruct') + +expected_stdout = "scons: Reading SConscript files ...\n" + +expected_stderr = """ +scons: *** User Called Configure() when another Configure() exists. + Please call .Finish() before creating and second Configure() context +File "%s", line 5, in \n"""%test_SConstruct_path +test.run(stderr=expected_stderr, stdout=expected_stdout, status=2) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: -- cgit v0.12 From 6363a46016bf9d834db3e1ab92b7303c070105ee Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sat, 15 Feb 2020 20:38:18 -0800 Subject: Update CHANGES.txt --- src/CHANGES.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index b3a7422..8806179 100755 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -21,6 +21,8 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - 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(). + - Fix Github Issue #2904 - Provide useful error message when more than one Configure Contexts are opened. + Only one open is allowed. You must call conf.Finish() to complete the currently open one before creating another From Jeremy Elson: - Updated design doc to use the correct syntax for Depends() -- cgit v0.12 From 283a1d3b52f3755733aa592eac99fab54feadd5b Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 16 Feb 2020 14:25:12 -0800 Subject: Updated error message per sugguestion by mwichmann --- src/engine/SCons/SConf.py | 2 +- test/Configure/issue-2906-useful-duplicate-configure-message.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/SCons/SConf.py b/src/engine/SCons/SConf.py index a5e443e..685fa3e 100644 --- a/src/engine/SCons/SConf.py +++ b/src/engine/SCons/SConf.py @@ -430,7 +430,7 @@ class SConfBase(object): SConfFS = SCons.Node.FS.default_fs or \ SCons.Node.FS.FS(env.fs.pathTop) if sconf_global is not None: - raise SCons.Errors.UserError("""User Called Configure() when another Configure() exists. + raise SCons.Errors.UserError("""Configure() called while another Configure() exists. Please call .Finish() before creating and second Configure() context""") if log_file is not None: diff --git a/test/Configure/issue-2906-useful-duplicate-configure-message.py b/test/Configure/issue-2906-useful-duplicate-configure-message.py index 716cb33..c980bd3 100644 --- a/test/Configure/issue-2906-useful-duplicate-configure-message.py +++ b/test/Configure/issue-2906-useful-duplicate-configure-message.py @@ -43,7 +43,7 @@ test_SConstruct_path = test.workpath('SConstruct') expected_stdout = "scons: Reading SConscript files ...\n" expected_stderr = """ -scons: *** User Called Configure() when another Configure() exists. +scons: *** Configure() called while another Configure() exists. Please call .Finish() before creating and second Configure() context File "%s", line 5, in \n"""%test_SConstruct_path test.run(stderr=expected_stderr, stdout=expected_stdout, status=2) -- cgit v0.12