From 1960eaffb7089069e645a648f13d1ffda93f4d28 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 4 Jun 2023 18:09:49 -0700 Subject: Added test, CHANGES/RELEASE text. Fixturized SConstruct from test/option/debug-count.py, and used that in test/option/debug-json.py --- CHANGES.txt | 5 ++ RELEASE.txt | 3 ++ SCons/Script/Main.py | 1 - SCons/Util/stats.py | 2 +- test/option/debug-count.py | 16 ++---- test/option/debug-json.py | 82 ++++++++++++++++++++++++++++++ test/option/fixture/SConstruct_debug_count | 6 +++ 7 files changed, 101 insertions(+), 14 deletions(-) create mode 100644 test/option/debug-json.py create mode 100644 test/option/fixture/SConstruct_debug_count diff --git a/CHANGES.txt b/CHANGES.txt index 2584583..b9f0c49 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -9,6 +9,11 @@ NOTE: 4.3.0 now requires Python 3.6.0 and above. Python 3.5.x is no longer suppo RELEASE VERSION/DATE TO BE FILLED IN LATER + From William Deegan + - The --debug flag now has a 'json' option which will write information + generated by --debug={count, memory, time, action-timestamps} and about + the build. + From Mats Wichmann - C scanner's dictifyCPPDEFINES routine did not understand the possible combinations of CPPDEFINES - not aware of a "name=value" string either diff --git a/RELEASE.txt b/RELEASE.txt index e71e2b6..f7566fb 100644 --- a/RELEASE.txt +++ b/RELEASE.txt @@ -34,6 +34,9 @@ CHANGED/ENHANCED EXISTING FUNCTIONALITY were dropped: get_src_sig_type, get_tgt_sig_type, _changed_source. These were unused remnants of the previously removed SourceSignatures and TargetSignatures features (dropped in 3.1.2). +- The --debug flag now has a 'json' option which will write information + generated by --debug={count, memory, time, action-timestamps} and about + the build. FIXES ----- diff --git a/SCons/Script/Main.py b/SCons/Script/Main.py index 05a45b5..73070b2 100644 --- a/SCons/Script/Main.py +++ b/SCons/Script/Main.py @@ -1506,7 +1506,6 @@ def main() -> None: if SCons.Util.stats.ENABLE_JSON: WriteJsonFile() - TIME_STATS.total_times(total_time, sconscript_time, scons_time, ct) if SCons.Util.stats.ENABLE_JSON: diff --git a/SCons/Util/stats.py b/SCons/Util/stats.py index 5a05f1c..c407871 100644 --- a/SCons/Util/stats.py +++ b/SCons/Util/stats.py @@ -159,7 +159,7 @@ def WriteJsonFile(): from SCons.Script import BUILD_TARGETS, COMMAND_LINE_TARGETS, ARGUMENTS, ARGLIST - print("DUMPING JSON FILE") + # print("DUMPING JSON FILE") json_structure = {} if COUNT_STATS.enabled: json_structure['Object counts'] = {} diff --git a/test/option/debug-count.py b/test/option/debug-count.py index cf46feb..dd252fc 100644 --- a/test/option/debug-count.py +++ b/test/option/debug-count.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 @@ -25,8 +27,6 @@ Test that the --debug=count option works. """ -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" - import re import sys @@ -34,15 +34,7 @@ import TestSCons test = TestSCons.TestSCons() - -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()) -env = Environment(BUILDERS={'Cat':Builder(action=Action(cat))}) -env.Cat('file.out', 'file.in') -""") +test.file_fixture('fixture/SConstruct_debug_count', 'SConstruct') test.write('file.in', "file.in\n") diff --git a/test/option/debug-json.py b/test/option/debug-json.py new file mode 100644 index 0000000..283b67d --- /dev/null +++ b/test/option/debug-json.py @@ -0,0 +1,82 @@ +#!/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 that the --debug=json option works. +""" + +import json +import re +import sys + +import TestSCons + +test = TestSCons.TestSCons() + +test.file_fixture('fixture/SConstruct_debug_count', 'SConstruct') +test.write('file.in', "file.in\n") + + +# Just check that object counts for some representative classes +# show up in the output. + +def find_object_count(s, stdout): + re_string = r'\d+ +\d+ %s' % re.escape(s) + return re.search(re_string, stdout) + + +objects = [ + 'Action.CommandAction', + 'Builder.BuilderBase', + 'Environment.Base', + 'Executor.Executor', + 'Node.FS.File', + 'Node.FS.Base', + 'Node.Node', +] + +test.run(arguments='--debug=count,json') +test.must_exist('scons_stats.json') +with open('scons_stats.json') as jf: + stats_info = json.load(jf) + if 'Build_Info' not in stats_info: + test.fail_test(message='No Build_Info in json') + if 'Object counts' not in stats_info: + test.fail_test(message='No "Object counts" in json') + + for o in objects: + if o not in stats_info['Object counts']: + test.fail_test(message=f"Object counts missing {o}") + + if stats_info['Build_Info']['PYTHON_VERSION']['major'] != sys.version_info.major: + test.fail_test(message=f"Build Info PYTHON_VERSION incorrect") + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/option/fixture/SConstruct_debug_count b/test/option/fixture/SConstruct_debug_count new file mode 100644 index 0000000..be55d35 --- /dev/null +++ b/test/option/fixture/SConstruct_debug_count @@ -0,0 +1,6 @@ +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()) +env = Environment(BUILDERS={'Cat':Builder(action=Action(cat))}) +env.Cat('file.out', 'file.in') -- cgit v0.12