From 25c910740370a3620ff13be26c1ed8cff3b72c0c Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Fri, 6 Jul 2018 12:20:13 -0600 Subject: Start supporting newer java versions Signed-off-by: Mats Wichmann --- src/engine/SCons/Tool/JavaCommon.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/SCons/Tool/JavaCommon.py b/src/engine/SCons/Tool/JavaCommon.py index dfb9e33..a253db0 100644 --- a/src/engine/SCons/Tool/JavaCommon.py +++ b/src/engine/SCons/Tool/JavaCommon.py @@ -65,7 +65,7 @@ if java_parsing: def __init__(self, version=default_java_version): if not version in ('1.1', '1.2', '1.3','1.4', '1.5', '1.6', '1.7', - '1.8', '5', '6'): + '1.8', '5', '6', '9', '10'): msg = "Java version %s not supported" % version raise NotImplementedError(msg) @@ -171,7 +171,7 @@ if java_parsing: if self.version in ('1.1', '1.2', '1.3', '1.4'): clazz = self.listClasses[0] self.listOutputs.append('%s$%d' % (clazz, self.nextAnon)) - elif self.version in ('1.5', '1.6', '1.7', '1.8', '5', '6'): + elif self.version in ('1.5', '1.6', '1.7', '1.8', '5', '6', '9', '10'): self.stackAnonClassBrackets.append(self.brackets) className = [] className.extend(self.listClasses) -- cgit v0.12 From 59c79865ef866cb76b7f772a18b58fa6e95d4e5d Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Wed, 18 Jul 2018 10:51:41 -0600 Subject: Update java version support Although the newer versions are marketed as simple versions, scons will see them as dotted versions: 9.0, 10.0. Add some comments to this in test code - the RMI test skip ought to work as long as they stay dotted versions (since 10.0 >= 1.8); that code does run the test for a simple version like '6'. Signed-off-by: Mats Wichmann --- src/CHANGES.txt | 1 + src/engine/SCons/Tool/JavaCommon.py | 4 ++-- test/Java/RMIC.py | 4 ++++ test/Repository/RMIC.py | 4 ++++ 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 703bebb..1f0036b 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -93,6 +93,7 @@ RELEASE 3.1.0.alpha.yyyymmdd - NEW DATE WILL BE INSERTED HERE This changes SCons to better comply with normal Python installation practices. From Mats Wichmann: + - Recognize new java 9, 10 (as 9.0 and 10.0) - Updated manpage scons.xml to fix a nested list problem - Updated doc terminiology: use prepend instead of append as appropriate - xml validity fixes from SConstruct.py change diff --git a/src/engine/SCons/Tool/JavaCommon.py b/src/engine/SCons/Tool/JavaCommon.py index a253db0..5f54605 100644 --- a/src/engine/SCons/Tool/JavaCommon.py +++ b/src/engine/SCons/Tool/JavaCommon.py @@ -65,7 +65,7 @@ if java_parsing: def __init__(self, version=default_java_version): if not version in ('1.1', '1.2', '1.3','1.4', '1.5', '1.6', '1.7', - '1.8', '5', '6', '9', '10'): + '1.8', '5', '6', '9.0', '10.0'): msg = "Java version %s not supported" % version raise NotImplementedError(msg) @@ -171,7 +171,7 @@ if java_parsing: if self.version in ('1.1', '1.2', '1.3', '1.4'): clazz = self.listClasses[0] self.listOutputs.append('%s$%d' % (clazz, self.nextAnon)) - elif self.version in ('1.5', '1.6', '1.7', '1.8', '5', '6', '9', '10'): + elif self.version in ('1.5', '1.6', '1.7', '1.8', '5', '6', '9.0', '10.0'): self.stackAnonClassBrackets.append(self.brackets) className = [] className.extend(self.listClasses) diff --git a/test/Java/RMIC.py b/test/Java/RMIC.py index b29a466..19e799e 100644 --- a/test/Java/RMIC.py +++ b/test/Java/RMIC.py @@ -108,6 +108,10 @@ if java_version.count('.') == 1: # If it's 1.8 or higher, we skip the further RMIC test # because we'll get warnings about the deprecated API... # it's just not state-of-the-art anymore. +# Recent java versions (9 and greater) are back to being +# marketed as a simple version, but java_where_javac() will +# still return a dotted version, like 10.0. If this changes, +# will need to rework this rule. # Note, how we allow simple version strings like "5" and # "6" to successfully pass this test. if curver < (1, 8): diff --git a/test/Repository/RMIC.py b/test/Repository/RMIC.py index e08c716..433890f 100644 --- a/test/Repository/RMIC.py +++ b/test/Repository/RMIC.py @@ -51,6 +51,10 @@ if java_version.count('.') == 1: # If it's 1.8 or higher, we skip the further RMIC test # because we'll get warnings about the deprecated API... # it's just not state-of-the-art anymore. +# Recent java versions (9 and greater) are back to being +# marketed as a simple version, but java_where_javac() will +# still return a dotted version, like 10.0. If this changes, +# will need to rework this rule. # Note, how we allow simple version strings like "5" and # "6" to successfully pass this test. if curver >= (1, 8): -- cgit v0.12 From 9ec0b9861951cc72de39c742c1162a84696ce91f Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Sat, 21 Jul 2018 11:55:31 -0600 Subject: Add ability for SConscript to fail on missing script SConscript call now takes an optional must_exist flag, which defaults to False for compatiility with current behavior. If True, an exception is raised if the file is missing. To improve readability, the decision is moved off to a new function rather than being inline in _SConscript. A global setting to control the overall behavior is also added. A deprecation warning is added for the current behavior, which is printed only once. Signed-off-by: Mats Wichmann --- src/CHANGES.txt | 1 + src/engine/SCons/Script/SConscript.py | 24 ++++++++++++++++++++++-- src/engine/SCons/Script/SConscript.xml | 18 ++++++++++++++---- src/engine/SCons/Script/__init__.py | 10 ++++++++++ src/engine/SCons/Warnings.py | 7 +++++-- 5 files changed, 52 insertions(+), 8 deletions(-) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 79d25db..3b0e603 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -97,6 +97,7 @@ RELEASE 3.1.0.alpha.yyyymmdd - NEW DATE WILL BE INSERTED HERE This changes SCons to better comply with normal Python installation practices. From Mats Wichmann: + - Begin adding support for SConscript() failing on missing script - Updated manpage scons.xml to fix a nested list problem - Updated doc terminiology: use prepend instead of append as appropriate - xml validity fixes from SConstruct.py change diff --git a/src/engine/SCons/Script/SConscript.py b/src/engine/SCons/Script/SConscript.py index db6552c..5968346 100644 --- a/src/engine/SCons/Script/SConscript.py +++ b/src/engine/SCons/Script/SConscript.py @@ -153,6 +153,27 @@ def Return(*vars, **kw): stack_bottom = '% Stack boTTom %' # hard to define a variable w/this name :) +def handle_missing_SConscript(f, must_exist): + """Take appropriate action on missing file in SConscript() call. + + The action may be to raise an exception, or print a warning. + On first warning, also print a deprecation warning. + """ + + if SCons.Script._no_missing_sconscript or must_exist: + msg = "Fatal: missing SConscript '%s'" % f.get_internal_path() + raise SCons.Errors.UserError(msg) + + if SCons.Script._warn_missing_sconscript_deprecated: + msg = "Calling missing SConscripts without error is deprecated.\n" + \ + "Transition by adding must_exist=0 to SConscript calls.\n" + \ + "Missing SConscript '%s'" % f.get_internal_path() + SCons.Warnings.warn(SCons.Warnings.DeprecatedMissingSConscriptWarning, msg) + SCons.Script._warn_missing_sconscript_deprecated = False + else: + msg = "Ignoring missing SConscript '%s'" % f.get_internal_path() + SCons.Warnings.warn(SCons.Warnings.MissingSConscriptWarning, msg) + def _SConscript(fs, *files, **kw): top = fs.Top sd = fs.SConstruct_dir.rdir() @@ -264,8 +285,7 @@ def _SConscript(fs, *files, **kw): if old_file is not None: call_stack[-1].globals.update({__file__:old_file}) else: - SCons.Warnings.warn(SCons.Warnings.MissingSConscriptWarning, - "Ignoring missing SConscript '%s'" % f.get_internal_path()) + handle_missing_SConscript(f, kw.get('must_exist', False)) finally: SCons.Script.sconscript_reading = SCons.Script.sconscript_reading - 1 diff --git a/src/engine/SCons/Script/SConscript.xml b/src/engine/SCons/Script/SConscript.xml index 8553fbe..29a89c2 100644 --- a/src/engine/SCons/Script/SConscript.xml +++ b/src/engine/SCons/Script/SConscript.xml @@ -357,12 +357,12 @@ Return('val1 val2') -(scripts, [exports, variant_dir, duplicate]) - +(scripts, [exports, variant_dir, duplicate, must_exist=flag]) + -(dirs=subdirs, [name=script, exports, variant_dir, duplicate]) - +(dirs=subdirs, [name=script, exports, variant_dir, duplicate, must_exist=flag]) + @@ -562,6 +562,16 @@ and what about this alternative? TODO??? SConscript('build/SConscript', src_dir='src') --> + +The optional +must_exist +argument, if true, causes an exception to be raised if a requested +&SConscript; file is not found. The default is false, +which only prints a warning, but this behavior is deprecated. +For scripts which truly intend to be optional, transition to +explicty supplying +must_exist=False to the call. + Here are some composite examples: diff --git a/src/engine/SCons/Script/__init__.py b/src/engine/SCons/Script/__init__.py index 89fc061..90bc311 100644 --- a/src/engine/SCons/Script/__init__.py +++ b/src/engine/SCons/Script/__init__.py @@ -276,6 +276,16 @@ def HelpFunction(text, append=False): # Will be non-zero if we are reading an SConscript file. sconscript_reading = 0 +_no_missing_sconscript = False +_warn_missing_sconscript_deprecated = True + +def set_missing_sconscript_error(flag=1): + """Set behavior on missing file in SConscript() call. Returns previous value""" + global _no_missing_sconscript + old = _no_missing_sconscript + _no_missing_sconscript = flag + return old + # def Variables(files=[], args=ARGUMENTS): return SCons.Variables.Variables(files, args) diff --git a/src/engine/SCons/Warnings.py b/src/engine/SCons/Warnings.py index e8158a4..63acd22 100644 --- a/src/engine/SCons/Warnings.py +++ b/src/engine/SCons/Warnings.py @@ -147,6 +147,9 @@ class DeprecatedSigModuleWarning(MandatoryDeprecatedWarning): class DeprecatedBuilderKeywordsWarning(MandatoryDeprecatedWarning): pass +class DeprecatedMissingSConscriptWarning(DeprecatedWarning): + pass + # The below is a list of 2-tuples. The first element is a class object. # The second element is true if that class is enabled, false if it is disabled. @@ -179,8 +182,8 @@ def warn(clazz, *args): global _enabled, _warningAsException, _warningOut warning = clazz(args) - for clazz, flag in _enabled: - if isinstance(warning, clazz): + for cls, flag in _enabled: + if isinstance(warning, cls): if flag: if _warningAsException: raise warning -- cgit v0.12 From d15065cdcfccf8943fa3ede7b225b698f3aec707 Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Wed, 25 Jul 2018 16:46:25 -0600 Subject: Testing: python 3 fix for must_contain TestCommon defines a method must_contain which checks for a file including a given string. With Python 3, the test runs into some typing problems. This could be fixed either by changing all the tests which call the routine either omitting the mode argument (which then defaults to 'rb'), or specifying a mode which includes 'b'; or by modifying must_contain to align the types of the file data and the data to check for. This patch uses the latter approach. This is a test-only change, no run-time scons code is modified. Signed-off-by: Mats Wichmann --- src/CHANGES.txt | 5 +++-- testing/framework/TestCommon.py | 9 +++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index c875f1f..cc8e5c6 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -103,8 +103,9 @@ RELEASE 3.1.0.alpha.yyyymmdd - NEW DATE WILL BE INSERTED HERE - update wiki links to new github location - update bug links to new github location - convert TestCmd.read to use with statement on open (quiets 17 py3 warnings) - - quiet warning in UtilTests.py - - fix tests specifying octal constants for Py3 + - quiet py3 warning in UtilTests.py + - fix tests specifying octal constants for py3 + - fix must_contain tests for py3 From Hao Wu - typo in customized decider example in user guide diff --git a/testing/framework/TestCommon.py b/testing/framework/TestCommon.py index 47a149b..e551cce 100644 --- a/testing/framework/TestCommon.py +++ b/testing/framework/TestCommon.py @@ -268,6 +268,15 @@ class TestCommon(TestCmd): def must_contain(self, file, required, mode = 'rb', find = None): """Ensures that the specified file contains the required text. """ + if 'b' in mode: + # Python 3: reading a file in binary mode returns a + # bytes object. We cannot find the index of a different + # (str) type in that, so encode "required". For Py2 + # it is all just strings, so it still works. + try: + required = required.encode() + except AttributeError: + pass # in case it's encoded already file_contents = self.read(file, mode) if find is None: def find(o, l): -- cgit v0.12 From 14daa07c0d95e1cd806e92911a74bde3ccf95b9f Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Sat, 28 Jul 2018 10:04:35 -0600 Subject: Add tests for SConscript(must_warn) option Testcases added to confirm the behavior of: first attempt to call a non-existent script gives a deprecation warning, additional ones give plain warning; True/False values for must_warn behave as expected; if scons default is changed to exception the call fails but if must_warn=False it still works. Tweaked the logic to actually get that last bit to work. Also minor doc update. Signed-off-by: Mats Wichmann --- src/engine/SCons/Script/SConscript.py | 7 +- src/engine/SCons/Script/SConscript.xml | 13 ++-- test/SConscript/must_exist.py | 119 +++++++++++++++++++++++++++++++++ 3 files changed, 130 insertions(+), 9 deletions(-) create mode 100644 test/SConscript/must_exist.py diff --git a/src/engine/SCons/Script/SConscript.py b/src/engine/SCons/Script/SConscript.py index 5968346..fb6ec0d 100644 --- a/src/engine/SCons/Script/SConscript.py +++ b/src/engine/SCons/Script/SConscript.py @@ -153,14 +153,14 @@ def Return(*vars, **kw): stack_bottom = '% Stack boTTom %' # hard to define a variable w/this name :) -def handle_missing_SConscript(f, must_exist): +def handle_missing_SConscript(f, must_exist=None): """Take appropriate action on missing file in SConscript() call. The action may be to raise an exception, or print a warning. On first warning, also print a deprecation warning. """ - if SCons.Script._no_missing_sconscript or must_exist: + if must_exist or (SCons.Script._no_missing_sconscript and must_exist is not False): msg = "Fatal: missing SConscript '%s'" % f.get_internal_path() raise SCons.Errors.UserError(msg) @@ -285,7 +285,7 @@ def _SConscript(fs, *files, **kw): if old_file is not None: call_stack[-1].globals.update({__file__:old_file}) else: - handle_missing_SConscript(f, kw.get('must_exist', False)) + handle_missing_SConscript(f, kw.get('must_exist', None)) finally: SCons.Script.sconscript_reading = SCons.Script.sconscript_reading - 1 @@ -568,6 +568,7 @@ class SConsEnvironment(SCons.Environment.Base): files, exports = self._get_SConscript_filenames(ls, subst_kw) subst_kw['exports'] = exports + return _SConscript(self.fs, *files, **subst_kw) def SConscriptChdir(self, flag): diff --git a/src/engine/SCons/Script/SConscript.xml b/src/engine/SCons/Script/SConscript.xml index 29a89c2..a6258c4 100644 --- a/src/engine/SCons/Script/SConscript.xml +++ b/src/engine/SCons/Script/SConscript.xml @@ -357,12 +357,12 @@ Return('val1 val2') -(scripts, [exports, variant_dir, duplicate, must_exist=flag]) - +(scripts, [exports, variant_dir, duplicate, must_exist]) + -(dirs=subdirs, [name=script, exports, variant_dir, duplicate, must_exist=flag]) - +(dirs=subdirs, [name=script, exports, variant_dir, duplicate, must_exist]) + @@ -562,12 +562,13 @@ and what about this alternative? TODO??? SConscript('build/SConscript', src_dir='src') --> + The optional must_exist argument, if true, causes an exception to be raised if a requested -&SConscript; file is not found. The default is false, -which only prints a warning, but this behavior is deprecated. +&SConscript; file is not found. The current default is false, +causing only a warning to be omitted, but this behavior is deprecated. For scripts which truly intend to be optional, transition to explicty supplying must_exist=False to the call. diff --git a/test/SConscript/must_exist.py b/test/SConscript/must_exist.py new file mode 100644 index 0000000..a4341fa --- /dev/null +++ b/test/SConscript/must_exist.py @@ -0,0 +1,119 @@ +#!/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__" + +''' +Test handling of must_exist flag and global setting requiring the +file to exist in an SConscript call +''' + +import TestSCons + +test = TestSCons.TestSCons() + +# catch the exception if is raised, send it on as a warning +# this gives us traceability of the line responsible +SConstruct_path = test.workpath('SConstruct') +test.write(SConstruct_path, """\ +import SCons +from SCons.Warnings import _warningOut +import sys + +# 1. call should succeed with deprecation warning +try: + SConscript('missing/SConscript') +except SCons.Errors.UserError as e: + if _warningOut: + _warningOut(e) +# 2. call should succeed with warning +try: + SConscript('missing/SConscript') +except SCons.Errors.UserError as e: + if _warningOut: + _warningOut(e) +# 3. call should raise exception +try: + SConscript('missing/SConscript', must_exist=True) +except SCons.Errors.UserError as e: + if _warningOut: + _warningOut(e) +# 4. call should succeed with warning +try: + SConscript('missing/SConscript', must_exist=False) +except SCons.Errors.UserError as e: + if _warningOut: + _warningOut(e) +SCons.Script.set_missing_sconscript_error() +# 5. with system setting changed, should raise exception +try: + SConscript('missing/SConscript') +except SCons.Errors.UserError as e: + if _warningOut: + _warningOut(e) +# 6. must_exist=False should override system setting +try: + SConscript('missing/SConscript', must_exist=False) +except SCons.Errors.UserError as e: + if _warningOut: + _warningOut(e) +""") + +# we should see two exceptions as "Fatal" and +# and see four warnings, the first having the depr message +warn1 = """ +scons: warning: Calling missing SConscripts without error is deprecated. +Transition by adding must_exist=0 to SConscript calls. +Missing SConscript 'missing/SConscript' +""" + test.python_file_line(SConstruct_path, 7) + +warn2 = """ +scons: warning: Ignoring missing SConscript 'missing/SConscript' +""" + test.python_file_line(SConstruct_path, 13) + +err1 = """ +scons: warning: Fatal: missing SConscript 'missing/SConscript' +""" + test.python_file_line(SConstruct_path, 22) + +warn3 = """ +scons: warning: Ignoring missing SConscript 'missing/SConscript' +""" + test.python_file_line(SConstruct_path, 25) + +err2 = """ +scons: warning: Fatal: missing SConscript 'missing/SConscript' +""" + test.python_file_line(SConstruct_path, 35) + +warn4 = """ +scons: warning: Ignoring missing SConscript 'missing/SConscript' +""" + test.python_file_line(SConstruct_path, 38) + +expect_stderr = warn1 + warn2 + err1 + warn3 + err2 + warn4 +test.run(arguments = ".", stderr = expect_stderr) +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: -- cgit v0.12 From 6166782fe90fc96a866424958fd6a632c76318f6 Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Sun, 29 Jul 2018 08:12:42 -0600 Subject: Add a docstring for SConscript() Signed-off-by: Mats Wichmann --- src/engine/SCons/Script/SConscript.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/engine/SCons/Script/SConscript.py b/src/engine/SCons/Script/SConscript.py index fb6ec0d..3b73010 100644 --- a/src/engine/SCons/Script/SConscript.py +++ b/src/engine/SCons/Script/SConscript.py @@ -543,6 +543,31 @@ class SConsEnvironment(SCons.Environment.Base): raise SCons.Errors.UserError("Import of non-existent variable '%s'"%x) def SConscript(self, *ls, **kw): + """Execute SCons configuration files. + + Parameters: + *ls (str or list): configuration file(s) to execute. + + Keyword arguments: + dirs (list): execute SConscript in each listed directory. + name (str): execute script 'name' (used with 'dirs'). + exports (list or dict): locally export variables the script(s) + can import. + variant_dir (str): mirror sources needed for build to variant_dir + to allow building there. + duplicate (bool): pysically duplicate sources instead of just + adjusting paths of derived files (used only with 'variant_dir') + (default is True). + must_exist (bool): fail if a requested script is missing + (default is False, default is deprecated). + + Returns: + variables returned by the called script + + Raises: + UserError if a script is not found and such exceptions are enabled. + """ + if 'build_dir' in kw: msg = """The build_dir keyword has been deprecated; use the variant_dir keyword instead.""" SCons.Warnings.warn(SCons.Warnings.DeprecatedBuildDirWarning, msg) @@ -568,7 +593,6 @@ class SConsEnvironment(SCons.Environment.Base): files, exports = self._get_SConscript_filenames(ls, subst_kw) subst_kw['exports'] = exports - return _SConscript(self.fs, *files, **subst_kw) def SConscriptChdir(self, flag): -- cgit v0.12 From 44ed2ad161836d9d3f119fc6454c9e92a356c1e1 Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Sun, 29 Jul 2018 20:24:18 -0600 Subject: Some further adjustments to missing-sconscript tests Signed-off-by: Mats Wichmann --- src/engine/SCons/Script/SConscript.py | 4 ++-- test/SConscript/must_exist.py | 4 ++-- test/option-f.py | 9 ++++++--- test/option/warn-missing-sconscript.py | 11 +++++++++-- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/engine/SCons/Script/SConscript.py b/src/engine/SCons/Script/SConscript.py index 3b73010..1d83bb6 100644 --- a/src/engine/SCons/Script/SConscript.py +++ b/src/engine/SCons/Script/SConscript.py @@ -165,10 +165,10 @@ def handle_missing_SConscript(f, must_exist=None): raise SCons.Errors.UserError(msg) if SCons.Script._warn_missing_sconscript_deprecated: - msg = "Calling missing SConscripts without error is deprecated.\n" + \ + msg = "Calling missing SConscript without error is deprecated.\n" + \ "Transition by adding must_exist=0 to SConscript calls.\n" + \ "Missing SConscript '%s'" % f.get_internal_path() - SCons.Warnings.warn(SCons.Warnings.DeprecatedMissingSConscriptWarning, msg) + SCons.Warnings.warn(SCons.Warnings.MissingSConscriptWarning, msg) SCons.Script._warn_missing_sconscript_deprecated = False else: msg = "Ignoring missing SConscript '%s'" % f.get_internal_path() diff --git a/test/SConscript/must_exist.py b/test/SConscript/must_exist.py index a4341fa..ac90cd1 100644 --- a/test/SConscript/must_exist.py +++ b/test/SConscript/must_exist.py @@ -72,7 +72,7 @@ try: except SCons.Errors.UserError as e: if _warningOut: _warningOut(e) -# 6. must_exist=False should override system setting +# 6. must_exist=False overrides system setting, should emit warning try: SConscript('missing/SConscript', must_exist=False) except SCons.Errors.UserError as e: @@ -83,7 +83,7 @@ except SCons.Errors.UserError as e: # we should see two exceptions as "Fatal" and # and see four warnings, the first having the depr message warn1 = """ -scons: warning: Calling missing SConscripts without error is deprecated. +scons: warning: Calling missing SConscript without error is deprecated. Transition by adding must_exist=0 to SConscript calls. Missing SConscript 'missing/SConscript' """ + test.python_file_line(SConstruct_path, 7) diff --git a/test/option-f.py b/test/option-f.py index 21afacb..46e2686 100644 --- a/test/option-f.py +++ b/test/option-f.py @@ -97,9 +97,12 @@ test.run(arguments = '-f Build2 -f SConscript .', stdout=expect) test.run(arguments = '-f no_such_file .', stdout = test.wrap_stdout("scons: `.' is up to date.\n"), stderr = None) -test.fail_test(not test.match_re(test.stderr(), """ -scons: warning: Ignoring missing SConscript 'no_such_file' -""" + TestSCons.file_expr)) +expect = """ +scons: warning: Calling missing SConscript without error is deprecated. +Transition by adding must_exist=0 to SConscript calls. +Missing SConscript 'no_such_file'""" +stderr = test.stderr() +test.must_contain_all(test.stderr(), expect) test.pass_test() diff --git a/test/option/warn-missing-sconscript.py b/test/option/warn-missing-sconscript.py index 4f1f8bd..492131b 100644 --- a/test/option/warn-missing-sconscript.py +++ b/test/option/warn-missing-sconscript.py @@ -51,16 +51,23 @@ test.write("foo.c",""" """) expect = r""" -scons: warning: Ignoring missing SConscript 'no_such_file' +scons: warning: Calling missing SConscript without error is deprecated. +Transition by adding must_exist=0 to SConscript calls. +Missing SConscript 'no_such_file' """ + TestSCons.file_expr +# this is the old message: +#expect = r""" +#scons: warning: Ignoring missing SConscript 'no_such_file' +"" + TestSCons.file_expr + test.run(arguments = '--warn=missing-sconscript .', stderr = expect) test.run(arguments = '--warn=no-missing-sconscript .', stderr = "") test.run(arguments = 'WARN=missing-sconscript .', stderr = expect) -test.run(arguments = 'WARN=no-missing-sconscript .') +test.run(arguments = 'WARN=no-missing-sconscript .', stderr = "") test.pass_test() -- cgit v0.12 From b4d4d281f771c2bec37829188b96ec2b148a8198 Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Mon, 30 Jul 2018 07:33:30 -0600 Subject: Fix for #3162: tweak SConscript() docstrings a little more Also handle_missing_SConscript(), internal interface added by this patch series. Signed-off-by: Mats Wichmann --- src/engine/SCons/Script/SConscript.py | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/engine/SCons/Script/SConscript.py b/src/engine/SCons/Script/SConscript.py index 1d83bb6..560402c 100644 --- a/src/engine/SCons/Script/SConscript.py +++ b/src/engine/SCons/Script/SConscript.py @@ -156,8 +156,16 @@ stack_bottom = '% Stack boTTom %' # hard to define a variable w/this name :) def handle_missing_SConscript(f, must_exist=None): """Take appropriate action on missing file in SConscript() call. - The action may be to raise an exception, or print a warning. - On first warning, also print a deprecation warning. + Print a warning or raise an exception on missing file. + On first warning, print a deprecation message. + + Args: + f (str): path of missing configuration file + must_exist (bool): raise exception if file does not exist + + Raises: + UserError if 'must_exist' is True or if global + SCons.Script._no_missing_sconscript is True. """ if must_exist or (SCons.Script._no_missing_sconscript and must_exist is not False): @@ -550,22 +558,22 @@ class SConsEnvironment(SCons.Environment.Base): Keyword arguments: dirs (list): execute SConscript in each listed directory. - name (str): execute script 'name' (used with 'dirs'). - exports (list or dict): locally export variables the script(s) - can import. - variant_dir (str): mirror sources needed for build to variant_dir - to allow building there. - duplicate (bool): pysically duplicate sources instead of just + name (str): execute script 'name' (used only with 'dirs'). + exports (list or dict): locally export variables the + called script(s) can import. + variant_dir (str): mirror sources needed for the build in + a variant directory to allow building in it. + duplicate (bool): physically duplicate sources instead of just adjusting paths of derived files (used only with 'variant_dir') (default is True). must_exist (bool): fail if a requested script is missing (default is False, default is deprecated). Returns: - variables returned by the called script + list of variables returned by the called script Raises: - UserError if a script is not found and such exceptions are enabled. + UserError: a script is not found and such exceptions are enabled. """ if 'build_dir' in kw: -- cgit v0.12 From 0cf044543fb089bcd997b3ad2d877b71026ce5bf Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Tue, 31 Jul 2018 16:57:26 -0600 Subject: Try a more scons-y file conversion for Py3 file reads Instead of custom conversion as in the previous iteration, use the to_bytes function. The two known tests which incorrectly let the text-mode xml file be opened in binary mode are adjusted to supply mode='r' Signed-off-by: Mats Wichmann --- test/Docbook/basic/xinclude/xinclude.py | 2 +- test/Docbook/dependencies/xinclude/xinclude.py | 2 +- testing/framework/TestCommon.py | 24 ++++++++++++++++-------- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/test/Docbook/basic/xinclude/xinclude.py b/test/Docbook/basic/xinclude/xinclude.py index 302c777..9b22c13 100644 --- a/test/Docbook/basic/xinclude/xinclude.py +++ b/test/Docbook/basic/xinclude/xinclude.py @@ -44,7 +44,7 @@ test.dir_fixture('image') # Normal invocation test.run() test.must_exist(test.workpath('manual_xi.xml')) -test.must_contain(test.workpath('manual_xi.xml'),'This is an included text.') +test.must_contain(test.workpath('manual_xi.xml'),'This is an included text.', mode='r') # Cleanup diff --git a/test/Docbook/dependencies/xinclude/xinclude.py b/test/Docbook/dependencies/xinclude/xinclude.py index 115163c..c3d9e25 100644 --- a/test/Docbook/dependencies/xinclude/xinclude.py +++ b/test/Docbook/dependencies/xinclude/xinclude.py @@ -44,7 +44,7 @@ test.dir_fixture('image') # Normal invocation test.run() test.must_exist(test.workpath('manual_xi.xml')) -test.must_contain(test.workpath('manual_xi.xml'),'This is an included text.') +test.must_contain(test.workpath('manual_xi.xml'),'This is an included text.', mode='r') # Change included file test.write('include.txt', 'This is another text.') diff --git a/testing/framework/TestCommon.py b/testing/framework/TestCommon.py index e551cce..e55b491 100644 --- a/testing/framework/TestCommon.py +++ b/testing/framework/TestCommon.py @@ -265,18 +265,26 @@ class TestCommon(TestCmd): print("Unwritable files: `%s'" % "', `".join(unwritable)) self.fail_test(missing + unwritable) - def must_contain(self, file, required, mode = 'rb', find = None): - """Ensures that the specified file contains the required text. + def must_contain(self, file, required, mode='rb', find=None): + """Ensures specified file contains the required text. + + Args: + file (string): name of file to search in. + required (string): text to search for. For the default + find function, type must match the return type from + reading the file; current implementation will convert. + mode (string): file open mode. + find (func): optional custom search routine. Must take the + form "find(output, line)" returning non-zero on success + and None on failure. + + Calling test exits FAILED if search result is false """ if 'b' in mode: # Python 3: reading a file in binary mode returns a # bytes object. We cannot find the index of a different - # (str) type in that, so encode "required". For Py2 - # it is all just strings, so it still works. - try: - required = required.encode() - except AttributeError: - pass # in case it's encoded already + # (str) type in that, so convert. + required = to_bytes(required) file_contents = self.read(file, mode) if find is None: def find(o, l): -- cgit v0.12 From 6892a428fa4a8fc8b3994e05458104a48d3c9ed1 Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Wed, 1 Aug 2018 13:41:30 -0600 Subject: Fix conflict on java-version patch due to dropped character --- src/engine/SCons/Tool/JavaCommon.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/SCons/Tool/JavaCommon.py b/src/engine/SCons/Tool/JavaCommon.py index 5f54605..47555a7 100644 --- a/src/engine/SCons/Tool/JavaCommon.py +++ b/src/engine/SCons/Tool/JavaCommon.py @@ -64,7 +64,7 @@ if java_parsing: interfaces, and anonymous inner classes.""" def __init__(self, version=default_java_version): - if not version in ('1.1', '1.2', '1.3','1.4', '1.5', '1.6', '1.7', + if not version in ('1.1', '1.2', '1.3', '1.4', '1.5', '1.6', '1.7', '1.8', '5', '6', '9.0', '10.0'): msg = "Java version %s not supported" % version raise NotImplementedError(msg) -- cgit v0.12 From e5390b34767b3911108841caedd6c1c73f982fbd Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Mon, 6 Aug 2018 18:01:23 -0600 Subject: Fix for #3162: be more descriptive in changelog --- src/CHANGES.txt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 3b0e603..cf2a8b1 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -97,12 +97,23 @@ RELEASE 3.1.0.alpha.yyyymmdd - NEW DATE WILL BE INSERTED HERE This changes SCons to better comply with normal Python installation practices. From Mats Wichmann: - - Begin adding support for SConscript() failing on missing script - Updated manpage scons.xml to fix a nested list problem - Updated doc terminiology: use prepend instead of append as appropriate - xml validity fixes from SConstruct.py change - update wiki links to new github location - update bug links to new github location + - Make it easier for SConscript() call to fail on missing script. + It was possible to call SCons.Warnings.warningAsException + (not documented as a user API) to make all warnings fail. Now + SConscript can take an optional must_exist flag which if true fails + if the script does not exist. Not failing on missing script is + now considered deprecated, and the first instance will print a + deprecation message. It is now also possible to flip the scons + behavior (which still defaults to warn, not fail) by calling + SCons.Script.set_missing_sconscript_error, which is also not a + documented interface at the moment. + +Begin adding support for SConscript() failing on missing script From Hao Wu - typo in customized decider example in user guide -- cgit v0.12 From ab762bc68d5f4bf06e696897291c8c76ea006ae2 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Tue, 7 Aug 2018 22:00:48 -0700 Subject: Add python 3.7 to travis builds --- .travis.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.travis.yml b/.travis.yml index a1f58b0..31fd324 100644 --- a/.travis.yml +++ b/.travis.yml @@ -36,6 +36,11 @@ jobs: sudo: required - <<: *test_job + python: 3.7 + env: PYVER=37 + sudo: required + + - <<: *test_job python: pypy env: PYVER=pypy sudo: required -- cgit v0.12 From 15ec7da378436e4d9ddb197a6bad43c7059b336c Mon Sep 17 00:00:00 2001 From: William Deegan Date: Tue, 7 Aug 2018 22:04:03 -0700 Subject: Add python 3.7 dev to travis builds --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 31fd324..58ca595 100644 --- a/.travis.yml +++ b/.travis.yml @@ -36,7 +36,7 @@ jobs: sudo: required - <<: *test_job - python: 3.7 + python: 3.7-dev env: PYVER=37 sudo: required -- cgit v0.12 From 522d235045a3e485c12f34ecb631c1ecfdd4c216 Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Thu, 9 Aug 2018 09:38:41 -0600 Subject: Fix the new missing-sconscript test for Windows Missed that string matching on the invalid sconscript path needs to be OS-agnostic - the CI builders don't include a windows image, so this was not caught. Call normpath on the path before pushing it into the expected strings. Signed-off-by: Mats Wichmann --- test/SConscript/must_exist.py | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/test/SConscript/must_exist.py b/test/SConscript/must_exist.py index ac90cd1..3faf0ce 100644 --- a/test/SConscript/must_exist.py +++ b/test/SConscript/must_exist.py @@ -29,6 +29,7 @@ Test handling of must_exist flag and global setting requiring the file to exist in an SConscript call ''' +import os import TestSCons test = TestSCons.TestSCons() @@ -82,31 +83,33 @@ except SCons.Errors.UserError as e: # we should see two exceptions as "Fatal" and # and see four warnings, the first having the depr message +# need to build the path in the expected msg in an OS-agnostic way +missing = os.path.normpath('missing/SConscript') warn1 = """ scons: warning: Calling missing SConscript without error is deprecated. Transition by adding must_exist=0 to SConscript calls. -Missing SConscript 'missing/SConscript' -""" + test.python_file_line(SConstruct_path, 7) +Missing SConscript '{}' +""".format(missing) + test.python_file_line(SConstruct_path, 7) warn2 = """ -scons: warning: Ignoring missing SConscript 'missing/SConscript' -""" + test.python_file_line(SConstruct_path, 13) +scons: warning: Ignoring missing SConscript '{}' +""".format(missing) + test.python_file_line(SConstruct_path, 13) err1 = """ -scons: warning: Fatal: missing SConscript 'missing/SConscript' -""" + test.python_file_line(SConstruct_path, 22) +scons: warning: Fatal: missing SConscript '{}' +""".format(missing) + test.python_file_line(SConstruct_path, 22) warn3 = """ -scons: warning: Ignoring missing SConscript 'missing/SConscript' -""" + test.python_file_line(SConstruct_path, 25) +scons: warning: Ignoring missing SConscript '{}' +""".format(missing) + test.python_file_line(SConstruct_path, 25) err2 = """ -scons: warning: Fatal: missing SConscript 'missing/SConscript' -""" + test.python_file_line(SConstruct_path, 35) +scons: warning: Fatal: missing SConscript '{}' +""".format(missing) + test.python_file_line(SConstruct_path, 35) warn4 = """ -scons: warning: Ignoring missing SConscript 'missing/SConscript' -""" + test.python_file_line(SConstruct_path, 38) +scons: warning: Ignoring missing SConscript '{}' +""".format(missing) + test.python_file_line(SConstruct_path, 38) expect_stderr = warn1 + warn2 + err1 + warn3 + err2 + warn4 test.run(arguments = ".", stderr = expect_stderr) -- cgit v0.12 From 680805f3ff9fc0c2823f084ff2f5b31e38f9471f Mon Sep 17 00:00:00 2001 From: Daniel Moody Date: Fri, 10 Aug 2018 15:45:54 -0500 Subject: Updated FS to handle removal of splitunc function from python 3.7 --- src/engine/SCons/Node/FS.py | 5 ++++- src/engine/SCons/Node/FSTests.py | 7 ++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index 9a48432..54cd423 100644 --- a/src/engine/SCons/Node/FS.py +++ b/src/engine/SCons/Node/FS.py @@ -132,7 +132,10 @@ def initialize_do_splitdrive(): global do_splitdrive global has_unc drive, path = os.path.splitdrive('X:/foo') - has_unc = hasattr(os.path, 'splitunc') + # splitunc is removed from python 3.7 and newer + # so we can also just test if splitdrive works with UNC + has_unc = (hasattr(os.path, 'splitunc') + or os.path.splitdrive(r'\\split\drive\test')[0] == r'\\split\drive') do_splitdrive = not not drive or has_unc diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py index 273f809..2c4dcfa 100644 --- a/src/engine/SCons/Node/FSTests.py +++ b/src/engine/SCons/Node/FSTests.py @@ -1657,7 +1657,12 @@ class FSTestCase(_tempdirTestCase): import ntpath x = test.workpath(*dirs) drive, path = ntpath.splitdrive(x) - unc, path = ntpath.splitunc(path) + try: + unc, path = ntpath.splitunc(path) + except AttributeError: + # could be python 3.7 or newer, make sure splitdrive can do UNC + assert ntpath.splitdrive(r'\\split\drive\test')[0] == r'\\split\drive' + pass path = strip_slash(path) return '//' + path[1:] -- cgit v0.12 From a582b0671ee3dbf152dfec15bef968410af5ece8 Mon Sep 17 00:00:00 2001 From: Daniel Moody Date: Fri, 10 Aug 2018 16:00:14 -0500 Subject: Switched test to use assertFalse because of deprication warning in 3.7 --- src/engine/SCons/Node/FSTests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py index 2c4dcfa..698f574 100644 --- a/src/engine/SCons/Node/FSTests.py +++ b/src/engine/SCons/Node/FSTests.py @@ -605,7 +605,7 @@ class VariantDirTestCase(unittest.TestCase): print("File `%s' alter_targets() `%s' != expected `%s'" % (f, tp, expect)) errors = errors + 1 - self.failIf(errors) + self.assertFalse(errors) class BaseTestCase(_tempdirTestCase): def test_stat(self): -- cgit v0.12 From 47db1a99a1017144a10e0f1537b1d6b585bae786 Mon Sep 17 00:00:00 2001 From: Daniel Moody Date: Fri, 10 Aug 2018 16:01:53 -0500 Subject: updated CHANGES.txt --- src/CHANGES.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 51cbc27..58b8a7e 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -7,7 +7,10 @@ RELEASE 3.1.0.alpha.yyyymmdd - NEW DATE WILL BE INSERTED HERE - From Matthew Marinets + From Daniel Moody: + - Updated FS.py to handle removal of splitunc function from python 3.7 + + From Matthew Marinets: - Fixed an issue that caused the Java emitter to incorrectly parse arguments to constructors that implemented a class. -- cgit v0.12 From 17fe6134fee6c574f27405d480572549f433c5be Mon Sep 17 00:00:00 2001 From: Daniel Moody Date: Fri, 10 Aug 2018 16:25:26 -0500 Subject: trying just some of the base packages, no docs or extra langs --- .travis/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis/install.sh b/.travis/install.sh index 16f7263..c15e991 100755 --- a/.travis/install.sh +++ b/.travis/install.sh @@ -8,7 +8,7 @@ sudo apt-get -y install gdc # dependencies for docbook tests sudo apt-get -y install docbook-xml xsltproc libxml2-dev libxslt-dev fop docbook-xsl-doc-pdf # dependencies for latex tests -sudo apt-get -y install texlive-full biber texmaker +sudo apt-get -y install texlive texlive-bibtex-extra texlive-latex3 biber texmaker # need some things for building dependencies for other tests sudo apt-get -y install python-pip python-dev build-essential libpcre3-dev autoconf automake libtool bison subversion git # dependencies for docbook tests continued -- cgit v0.12 From eea7786935c30c9048bd186849f269b39fd174ab Mon Sep 17 00:00:00 2001 From: Daniel Moody Date: Fri, 10 Aug 2018 17:12:22 -0500 Subject: removing the biber-extras for reduced travis install footprint --- .travis/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis/install.sh b/.travis/install.sh index c15e991..24735a8 100755 --- a/.travis/install.sh +++ b/.travis/install.sh @@ -8,7 +8,7 @@ sudo apt-get -y install gdc # dependencies for docbook tests sudo apt-get -y install docbook-xml xsltproc libxml2-dev libxslt-dev fop docbook-xsl-doc-pdf # dependencies for latex tests -sudo apt-get -y install texlive texlive-bibtex-extra texlive-latex3 biber texmaker +sudo apt-get -y install texlive texlive-latex3 biber texmaker # need some things for building dependencies for other tests sudo apt-get -y install python-pip python-dev build-essential libpcre3-dev autoconf automake libtool bison subversion git # dependencies for docbook tests continued -- cgit v0.12