diff --git a/CHANGES.txt b/CHANGES.txt index 97f7be243..acc087a9e 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -200,6 +200,8 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER attribute and to explain what's being done in the example. - Test framework reformatted using settings from pyproject.toml. Includes code embedded in docstrings. + - Handle case of "memoizer" as one member of a comma-separated + --debug string - this was previously missed. From Adam Scott: - Changed Ninja's TEMPLATE rule pool to use `install_pool` instead of diff --git a/RELEASE.txt b/RELEASE.txt index 1b823b91d..54b4800a6 100644 --- a/RELEASE.txt +++ b/RELEASE.txt @@ -179,6 +179,9 @@ FIXES - Fix Issue #2281, AddPreAction() & AddPostAction() were being ignored if no action was specified when the Alias was initially created. +- Handle case of "memoizer" as one member of a comma-separated + --debug string - this was previously missed. + IMPROVEMENTS ------------ diff --git a/SCons/Script/__init__.py b/SCons/Script/__init__.py index 2083e4f67..0243a9cf6 100644 --- a/SCons/Script/__init__.py +++ b/SCons/Script/__init__.py @@ -35,6 +35,7 @@ start_time = time.time() import collections +import itertools import os from io import StringIO @@ -53,9 +54,17 @@ # to not add the shims. So we use a special-case, up-front check for # the "--debug=memoizer" flag and enable Memoizer before we import any # of the other modules that use it. - -_args = sys.argv + os.environ.get('SCONSFLAGS', '').split() -if "--debug=memoizer" in _args: +# Update: this breaks if the option isn't exactly "--debug=memoizer", +# like if there is more than one debug option as a csv. Do a bit more work. + +_args = sys.argv + os.environ.get("SCONSFLAGS", "").split() +_args = ( + arg[len("--debug=") :].split(",") + for arg in _args + if arg.startswith("--debug=") +) +_args = list(itertools.chain.from_iterable(_args)) +if "memoizer" in _args: import SCons.Memoize import SCons.Warnings try: diff --git a/test/option/debug-memoizer.py b/test/option/debug-memoizer.py index 01af561b6..2425eaa0c 100644 --- a/test/option/debug-memoizer.py +++ b/test/option/debug-memoizer.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,26 +22,21 @@ # 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 calling the --debug=memoizer option. -""" +"""Test calling the --debug=memoizer option.""" import os import TestSCons -test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) - +test = TestSCons.TestSCons(match=TestSCons.match_re_dotall) test.write('SConstruct', """ -DefaultEnvironment(tools=[]) def cat(target, source, env): with open(str(target[0]), 'wb') as f, open(str(source[0]), 'rb') as infp: f.write(infp.read()) + +DefaultEnvironment(tools=[]) env = Environment(tools=[], BUILDERS={'Cat':Builder(action=Action(cat))}) env.Cat('file.out', 'file.in') """) @@ -51,36 +48,35 @@ def cat(target, source, env): # names in the implementation, so if we change them, we'll have to # change this test... expect = [ - "Memoizer (memory cache) hits and misses", - "Base.stat()", + # "Memoizer (memory cache) hits and misses", "Dir.srcdir_list()", + "File.stat()", "File.exists()", "Node._children_get()", ] - -for args in ['-h --debug=memoizer', '--debug=memoizer']: - test.run(arguments = args) - test.must_contain_any_line(test.stdout(), expect) - +test.run(arguments='--debug=memoizer') +test.must_contain_any_line(test.stdout(), expect) test.must_match('file.out', "file.in\n") - - - test.unlink("file.out") +# make sure it also works if memoizer is not the only debug flag +test.run(arguments='--debug=sconscript,memoizer') +test.must_contain_any_line(test.stdout(), expect) +test.must_match('file.out', "file.in\n") +test.unlink("file.out") +# memoization should still report even in help mode +test.run(arguments='-h --debug=memoizer') +test.must_contain_any_line(test.stdout(), expect) +test.must_not_exist("file.out") +# also try setting in SCONSFLAGS os.environ['SCONSFLAGS'] = '--debug=memoizer' - -test.run(arguments = '') - +test.run(arguments='.') test.must_contain_any_line(test.stdout(), expect) - test.must_match('file.out', "file.in\n") - - test.pass_test() # Local Variables: