From a6f3af3310410cfad4d4d010bab90c25a07dafe2 Mon Sep 17 00:00:00 2001 From: Joseph Brill <48932340+jcbrill@users.noreply.github.com> Date: Wed, 22 Sep 2021 15:54:05 -0400 Subject: import os module due to NameError exception due to 'os' is not defined. --- CHANGES.txt | 3 +++ test/MSVS/vs-6.0-exec.py | 1 + test/MSVS/vs-7.0-exec.py | 1 + test/MSVS/vs-7.1-exec.py | 1 + 4 files changed, 6 insertions(+) diff --git a/CHANGES.txt b/CHANGES.txt index c4cbdcd..26cf8a3 100755 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -9,6 +9,9 @@ NOTE: The 4.2.0 Release of SCons will deprecate Python 3.5 Support. Python 3.5 s RELEASE VERSION/DATE TO BE FILLED IN LATER + From Joseph Brill: + - Fix MSVS tests (vs-N.N-exec.py) for MSVS 6.0, 7.0, and 7.1 (import missing module). + From William Deegan: - Fix reproducible builds. Restore logic respecting SOURCE_DATE_EPOCH when set. - Fix version tests to work with updated scons --version output. (Date format changed) diff --git a/test/MSVS/vs-6.0-exec.py b/test/MSVS/vs-6.0-exec.py index 40f69c0..ab70872 100644 --- a/test/MSVS/vs-6.0-exec.py +++ b/test/MSVS/vs-6.0-exec.py @@ -29,6 +29,7 @@ Test that we can actually build a simple program using our generated Visual Studio 6 project (.dsp) and solution (.dsw) files. """ +import os import sys import TestSConsMSVS diff --git a/test/MSVS/vs-7.0-exec.py b/test/MSVS/vs-7.0-exec.py index a6235a7..3c41aa5 100644 --- a/test/MSVS/vs-7.0-exec.py +++ b/test/MSVS/vs-7.0-exec.py @@ -29,6 +29,7 @@ Test that we can actually build a simple program using our generated Visual Studio 7.0 project (.vcproj) and solution (.sln) files. """ +import os import sys import TestSConsMSVS diff --git a/test/MSVS/vs-7.1-exec.py b/test/MSVS/vs-7.1-exec.py index 7bb3055..f66b92d 100644 --- a/test/MSVS/vs-7.1-exec.py +++ b/test/MSVS/vs-7.1-exec.py @@ -29,6 +29,7 @@ Test that we can actually build a simple program using our generated Visual Studio 7.1 project (.vcproj) and solution (.sln) files """ +import os import sys import TestSConsMSVS -- cgit v0.12 From c13797579e4ebd0092ae0bc929c0c618f54887bc Mon Sep 17 00:00:00 2001 From: Joseph Brill <48932340+jcbrill@users.noreply.github.com> Date: Thu, 23 Sep 2021 16:12:51 -0400 Subject: Add support for Visual Studio 2022 --- CHANGES.txt | 1 + SCons/Tool/MSCommon/common.py | 3 +- SCons/Tool/MSCommon/vc.py | 32 ++++++++++- SCons/Tool/MSCommon/vs.py | 12 ++++ SCons/Tool/msvc.xml | 1 + SCons/Tool/msvs.py | 10 +++- test/MSVC/MSVC_UWP_APP.py | 24 +++++++- test/MSVS/vs-14.3-exec.py | 115 +++++++++++++++++++++++++++++++++++++ testing/framework/TestSConsMSVS.py | 5 +- 9 files changed, 193 insertions(+), 10 deletions(-) create mode 100644 test/MSVS/vs-14.3-exec.py diff --git a/CHANGES.txt b/CHANGES.txt index 26cf8a3..277e106 100755 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -11,6 +11,7 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER From Joseph Brill: - Fix MSVS tests (vs-N.N-exec.py) for MSVS 6.0, 7.0, and 7.1 (import missing module). + - Add support for Visual Studio 2022. From William Deegan: - Fix reproducible builds. Restore logic respecting SOURCE_DATE_EPOCH when set. diff --git a/SCons/Tool/MSCommon/common.py b/SCons/Tool/MSCommon/common.py index 9d01835..0652ec5 100644 --- a/SCons/Tool/MSCommon/common.py +++ b/SCons/Tool/MSCommon/common.py @@ -238,7 +238,8 @@ def get_output(vcbat, args=None, env=None): # or synced with the the common_tools_var # settings in vs.py. vs_vc_vars = [ 'COMSPEC', # path to "shell" - 'VS160COMNTOOLS', # path to common tools for given version + 'VS170COMNTOOLS', # path to common tools for given version + 'VS160COMNTOOLS', 'VS150COMNTOOLS', 'VS140COMNTOOLS', 'VS120COMNTOOLS', diff --git a/SCons/Tool/MSCommon/vc.py b/SCons/Tool/MSCommon/vc.py index 66a081f..5ca1630 100644 --- a/SCons/Tool/MSCommon/vc.py +++ b/SCons/Tool/MSCommon/vc.py @@ -228,18 +228,42 @@ def get_host_target(env): return (host, target, req_target_platform) +# Enable prerelease version(s) via vswhere query argument. +# When enabled, an installed prerelease version will likely be the default msvc version. +_MSVC_CHECK_PRERELEASE = os.environ.get('MSVC_CHECK_PRERELEASE') +_prerelease = ['-prerelease'] if _MSVC_CHECK_PRERELEASE in ('1', 'true', 'True') else [] + # If you update this, update SupportedVSList in Tool/MSCommon/vs.py, and the # MSVC_VERSION documentation in Tool/msvc.xml. -_VCVER = ["14.2", "14.1", "14.1Exp", "14.0", "14.0Exp", "12.0", "12.0Exp", "11.0", "11.0Exp", "10.0", "10.0Exp", "9.0", "9.0Exp","8.0", "8.0Exp","7.1", "7.0", "6.0"] +_VCVER = [ + "14.3", + "14.2", + "14.1", "14.1Exp", + "14.0", "14.0Exp", + "12.0", "12.0Exp", + "11.0", "11.0Exp", + "10.0", "10.0Exp", + "9.0", "9.0Exp", + "8.0", "8.0Exp", + "7.1", + "7.0", + "6.0"] # if using vswhere, configure command line arguments to probe for installed VC editions _VCVER_TO_VSWHERE_VER = { + '14.3': [ + ["-version", "[17.0, 18.0)"], # default: Enterprise, Professional, Community (order unpredictable?) + ["-version", "[17.0, 18.0)", "-products", "Microsoft.VisualStudio.Product.BuildTools"] , # BuildTools + # TODO: remove _prerelease when VS 2022 is released + _prerelease + ["-version", "[17.0, 18.0)"], # default: Enterprise, Professional, Community (order unpredictable?) + _prerelease + ["-version", "[17.0, 18.0)", "-products", "Microsoft.VisualStudio.Product.BuildTools"] , # BuildTools + ], '14.2': [ - ["-version", "[16.0, 17.0)", ], # default: Enterprise, Professional, Community (order unpredictable?) + ["-version", "[16.0, 17.0)"], # default: Enterprise, Professional, Community (order unpredictable?) ["-version", "[16.0, 17.0)", "-products", "Microsoft.VisualStudio.Product.BuildTools"], # BuildTools ], '14.1': [ - ["-version", "[15.0, 16.0)", ], # default: Enterprise, Professional, Community (order unpredictable?) + ["-version", "[15.0, 16.0)"], # default: Enterprise, Professional, Community (order unpredictable?) ["-version", "[15.0, 16.0)", "-products", "Microsoft.VisualStudio.Product.BuildTools"], # BuildTools ], '14.1Exp': [ @@ -248,6 +272,8 @@ _VCVER_TO_VSWHERE_VER = { } _VCVER_TO_PRODUCT_DIR = { + '14.3': [ + (SCons.Util.HKEY_LOCAL_MACHINE, r'')], # not set by this version '14.2': [ (SCons.Util.HKEY_LOCAL_MACHINE, r'')], # not set by this version '14.1': [ diff --git a/SCons/Tool/MSCommon/vs.py b/SCons/Tool/MSCommon/vs.py index 7be7049..b6fe282 100644 --- a/SCons/Tool/MSCommon/vs.py +++ b/SCons/Tool/MSCommon/vs.py @@ -197,6 +197,18 @@ class VisualStudio: # Tool/MSCommon/vc.py, and the MSVC_VERSION documentation in Tool/msvc.xml. SupportedVSList = [ + # Visual Studio 2022 + VisualStudio('14.3', + vc_version='14.3', + sdk_version='10.0A', + hkeys=[], + common_tools_var='VS170COMNTOOLS', + executable_path=r'Common7\IDE\devenv.com', + # should be a fallback, prefer use vswhere installationPath + batch_file_path=r'Common7\Tools\VsDevCmd.bat', + supported_arch=['x86', 'amd64', "arm"], + ), + # Visual Studio 2019 VisualStudio('14.2', vc_version='14.2', diff --git a/SCons/Tool/msvc.xml b/SCons/Tool/msvc.xml index d6cf6b2..8128235 100644 --- a/SCons/Tool/msvc.xml +++ b/SCons/Tool/msvc.xml @@ -353,6 +353,7 @@ constructor; setting it later has no effect. Valid values for Windows are +14.3, 14.2, 14.1, 14.1Exp, diff --git a/SCons/Tool/msvs.py b/SCons/Tool/msvs.py index 9fdee65..7a827f4 100644 --- a/SCons/Tool/msvs.py +++ b/SCons/Tool/msvs.py @@ -379,7 +379,10 @@ class _GenerateV10User(_UserGenerator): def __init__(self, dspfile, source, env): version_num, suite = msvs_parse_version(env['MSVS_VERSION']) - if version_num >= 14.2: + if version_num >= 14.3: + # Visual Studio 2022 is considered to be version 17. + self.versionstr = '17.0' + elif version_num >= 14.2: # Visual Studio 2019 is considered to be version 16. self.versionstr = '16.0' elif version_num >= 14.1: @@ -1599,7 +1602,10 @@ class _GenerateV7DSW(_DSWGenerator): def PrintSolution(self): """Writes a solution file""" self.file.write('Microsoft Visual Studio Solution File, Format Version %s\n' % self.versionstr) - if self.version_num >= 14.2: + if self.version_num >= 14.3: + # Visual Studio 2022 is considered to be version 17. + self.file.write('# Visual Studio 17\n') + elif self.version_num >= 14.2: # Visual Studio 2019 is considered to be version 16. self.file.write('# Visual Studio 16\n') elif self.version_num > 14.0: diff --git a/test/MSVC/MSVC_UWP_APP.py b/test/MSVC/MSVC_UWP_APP.py index 4bb2f5c..ca0bdd7 100644 --- a/test/MSVC/MSVC_UWP_APP.py +++ b/test/MSVC/MSVC_UWP_APP.py @@ -89,8 +89,9 @@ installed_msvc_versions = msvc.get_installed_vcs() msvc_140 = '14.0' in installed_msvc_versions msvc_141 = '14.1' in installed_msvc_versions msvc_142 = '14.2' in installed_msvc_versions +msvc_143 = '14.3' in installed_msvc_versions -if not any((msvc_140, msvc_141, msvc_142)): +if not any((msvc_140, msvc_141, msvc_142, msvc_143)): test.skip_test("Available MSVC doesn't support App store\n") if msvc_140: @@ -128,8 +129,25 @@ print('env[MSVC_VERSION]=%s' % env.get('MSVC_VERSION')) test.fail_test((vclibstore_path_present is True) or (vclibstorerefs_path_present is True), message='VC Store LIBPATHs present when MSVC_UWP_APP not set (msvc_version=%s)' % msvc_version) -if msvc_141 or msvc_142: - if msvc_142: +if msvc_141 or msvc_142 or msvs_143: + if msvc_143: + test.write('SConstruct', """\ +if ARGUMENTS.get('MSVC_UWP_APP'): + help_vars = Variables() + help_vars.Add(EnumVariable( + 'MSVC_UWP_APP', + 'Build a Universal Windows Platform (UWP) Application', + '0', + allowed_values=('0', '1'))) +else: + help_vars = None +env = Environment(tools=['default', 'msvc'], variables=help_vars, MSVC_VERSION='14.3') +# Print the ENV LIBPATH to stdout +print('env[ENV][LIBPATH]=%s' % env.get('ENV').get('LIBPATH')) +print('env[MSVC_VERSION]=%s' % env.get('MSVC_VERSION')) +print('env[ENV][VSCMD_ARG_app_plat]=%s' % env.get('ENV').get('VSCMD_ARG_app_plat')) +""") + elif msvc_142: test.write('SConstruct', """\ if ARGUMENTS.get('MSVC_UWP_APP'): help_vars = Variables() diff --git a/test/MSVS/vs-14.3-exec.py b/test/MSVS/vs-14.3-exec.py new file mode 100644 index 0000000..0f038f0 --- /dev/null +++ b/test/MSVS/vs-14.3-exec.py @@ -0,0 +1,115 @@ +#!/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 that we can actually build a simple program using our generated +Visual Studio 14.0 project (.vcxproj) and solution (.sln) files +using Visual Studio 14.3 +""" + +import os +import sys + +import TestSConsMSVS + +test = TestSConsMSVS.TestSConsMSVS() + +if sys.platform != 'win32': + msg = "Skipping Visual Studio test on non-Windows platform '%s'\n" % sys.platform + test.skip_test(msg) + +msvs_version = '14.3' + +if not msvs_version in test.msvs_versions(): + msg = "Visual Studio %s not installed; skipping test.\n" % msvs_version + test.skip_test(msg) + + + +# Let SCons figure out the Visual Studio environment variables for us and +# print out a statement that we can exec to suck them into our external +# environment so we can execute devenv and really try to build something. + +test.run(arguments = '-n -q -Q -f -', stdin = """\ +env = Environment(tools = ['msvc'], MSVS_VERSION='%(msvs_version)s') +if env.WhereIs('cl'): + print("os.environ.update(%%s)" %% repr(env['ENV'])) +""" % locals()) + +if(test.stdout() == ""): + msg = "Visual Studio %s missing cl.exe; skipping test.\n" % msvs_version + test.skip_test(msg) + +exec(test.stdout()) + + + +test.subdir('sub dir') + +test.write(['sub dir', 'SConstruct'], """\ +env=Environment(MSVS_VERSION = '%(msvs_version)s') + +env.MSVSProject(target = 'foo.vcxproj', + srcs = ['foo.c'], + buildtarget = 'foo.exe', + variant = 'Release', + DebugSettings = {'LocalDebuggerCommandArguments':'echo "" > output.txt'}) +env.Program('foo.c') +""" % locals()) + +test.write(['sub dir', 'foo.c'], r""" +#include +int +main(int argc, char *argv) +{ + printf("foo.c\n"); + exit (0); +} +""") + +test.run(chdir='sub dir', arguments='.') + +test.vcproj_sys_path(test.workpath('sub dir', 'foo.vcxproj')) + +import SCons.Platform.win32 +system_dll_path = os.path.join( SCons.Platform.win32.get_system_root(), 'System32' ) +os.environ['PATH'] = os.environ['PATH'] + os.pathsep + system_dll_path + +test.run(chdir='sub dir', + program=[test.get_msvs_executable(msvs_version)], + arguments=['foo.sln', '/build', 'Release']) + +test.run(program=test.workpath('sub dir', 'foo'), stdout="foo.c\n") +test.validate_msvs_file(test.workpath('sub dir', 'foo.vcxproj.user')) + + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/testing/framework/TestSConsMSVS.py b/testing/framework/TestSConsMSVS.py index 1ab4136..fc0a411 100644 --- a/testing/framework/TestSConsMSVS.py +++ b/testing/framework/TestSConsMSVS.py @@ -655,7 +655,7 @@ def get_tested_proj_file_vc_versions(): """ Returns all MSVC versions that we want to test project file creation for. """ - return ['8.0', '9.0', '10.0', '11.0', '12.0', '14.0', '14.1', '14.2'] + return ['8.0', '9.0', '10.0', '11.0', '12.0', '14.0', '14.1', '14.2', '14.3'] class TestSConsMSVS(TestSCons): @@ -879,6 +879,9 @@ print("self._msvs_versions =%%s"%%str(SCons.Tool.MSCommon.query_versions())) elif vc_version == '14.2': # ToolsVersion='16' return '16.0' + elif vc_version == '14.3': + # ToolsVersion='17' + return '17.0' else: raise SCons.Errors.UserError('Received unexpected VC version %s' % vc_version) -- cgit v0.12 From 271293587215f0a3c255a37202158c0fa5795cbb Mon Sep 17 00:00:00 2001 From: Joseph Brill <48932340+jcbrill@users.noreply.github.com> Date: Thu, 23 Sep 2021 17:21:38 -0400 Subject: Simplify VS 2022 prerelease handling. --- SCons/Tool/MSCommon/vc.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/SCons/Tool/MSCommon/vc.py b/SCons/Tool/MSCommon/vc.py index 5ca1630..129a9b4 100644 --- a/SCons/Tool/MSCommon/vc.py +++ b/SCons/Tool/MSCommon/vc.py @@ -230,8 +230,7 @@ def get_host_target(env): # Enable prerelease version(s) via vswhere query argument. # When enabled, an installed prerelease version will likely be the default msvc version. -_MSVC_CHECK_PRERELEASE = os.environ.get('MSVC_CHECK_PRERELEASE') -_prerelease = ['-prerelease'] if _MSVC_CHECK_PRERELEASE in ('1', 'true', 'True') else [] +_MSVC_CHECK_PRERELEASE = os.environ.get('MSVC_CHECK_PRERELEASE') in ('1', 'true', 'True') # If you update this, update SupportedVSList in Tool/MSCommon/vs.py, and the # MSVC_VERSION documentation in Tool/msvc.xml. @@ -253,11 +252,12 @@ _VCVER = [ _VCVER_TO_VSWHERE_VER = { '14.3': [ ["-version", "[17.0, 18.0)"], # default: Enterprise, Professional, Community (order unpredictable?) - ["-version", "[17.0, 18.0)", "-products", "Microsoft.VisualStudio.Product.BuildTools"] , # BuildTools - # TODO: remove _prerelease when VS 2022 is released - _prerelease + ["-version", "[17.0, 18.0)"], # default: Enterprise, Professional, Community (order unpredictable?) - _prerelease + ["-version", "[17.0, 18.0)", "-products", "Microsoft.VisualStudio.Product.BuildTools"] , # BuildTools - ], + ["-version", "[17.0, 18.0)", "-products", "Microsoft.VisualStudio.Product.BuildTools"], # BuildTools + ] + [ + # TODO: remove after VS 2022 is released + ["-prerelease", "-version", "[17.0, 18.0)"], # default: Enterprise, Professional, Community (order unpredictable?) + ["-prerelease", "-version", "[17.0, 18.0)", "-products", "Microsoft.VisualStudio.Product.BuildTools"], # BuildTools + ] if _MSVC_CHECK_PRERELEASE else [], '14.2': [ ["-version", "[16.0, 17.0)"], # default: Enterprise, Professional, Community (order unpredictable?) ["-version", "[16.0, 17.0)", "-products", "Microsoft.VisualStudio.Product.BuildTools"], # BuildTools -- cgit v0.12 From e8ac6cc06c5d2341053e8c9ffed5160d0d2e563f Mon Sep 17 00:00:00 2001 From: Joseph Brill <48932340+jcbrill@users.noreply.github.com> Date: Tue, 5 Oct 2021 08:12:30 -0400 Subject: Visual Studio 2022 and test fixes for MSVS 6.0, 7.0 and 7.1. --- RELEASE.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/RELEASE.txt b/RELEASE.txt index f1411e4..c8dbff6 100755 --- a/RELEASE.txt +++ b/RELEASE.txt @@ -9,7 +9,8 @@ Here is a summary of the changes since 4.2.0: NEW FUNCTIONALITY ----------------- -- List new features (presumably why a checkpoint is being released) +- Add support for Visual Studio 2022. +- Add support for pre-release versions of Visual Studio 2022 via an environment variable. DEPRECATED FUNCTIONALITY ------------------------ @@ -38,6 +39,7 @@ FIXES - Fix PCH not being evaluated by subst() where necessary. - Fix issue #4021. Change the way subst() is used in Textfile() to not evaluate '$$(' -> '$', but instead it should yield '$('. +- Fix MSVS tests (vs-N.N-exec.py) for MSVS 6.0, 7.0, and 7.1 (import missing module). IMPROVEMENTS ------------ -- cgit v0.12 From bbe2f48d6621ca55288a9e15a8bd9115a58214a8 Mon Sep 17 00:00:00 2001 From: Joseph Brill <48932340+jcbrill@users.noreply.github.com> Date: Tue, 5 Oct 2021 13:06:10 -0400 Subject: Fix variable name (msvs_143 to msvc_143) and minor updates based on slider output. --- test/MSVC/MSVC_UWP_APP.py | 2 +- test/MSVS/vs-14.3-exec.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/MSVC/MSVC_UWP_APP.py b/test/MSVC/MSVC_UWP_APP.py index ca0bdd7..6ccd117 100644 --- a/test/MSVC/MSVC_UWP_APP.py +++ b/test/MSVC/MSVC_UWP_APP.py @@ -129,7 +129,7 @@ print('env[MSVC_VERSION]=%s' % env.get('MSVC_VERSION')) test.fail_test((vclibstore_path_present is True) or (vclibstorerefs_path_present is True), message='VC Store LIBPATHs present when MSVC_UWP_APP not set (msvc_version=%s)' % msvc_version) -if msvc_141 or msvc_142 or msvs_143: +if msvc_141 or msvc_142 or msvc_143: if msvc_143: test.write('SConstruct', """\ if ARGUMENTS.get('MSVC_UWP_APP'): diff --git a/test/MSVS/vs-14.3-exec.py b/test/MSVS/vs-14.3-exec.py index 0f038f0..840b432 100644 --- a/test/MSVS/vs-14.3-exec.py +++ b/test/MSVS/vs-14.3-exec.py @@ -43,7 +43,7 @@ if sys.platform != 'win32': msvs_version = '14.3' -if not msvs_version in test.msvs_versions(): +if msvs_version not in test.msvs_versions(): msg = "Visual Studio %s not installed; skipping test.\n" % msvs_version test.skip_test(msg) @@ -95,7 +95,7 @@ test.run(chdir='sub dir', arguments='.') test.vcproj_sys_path(test.workpath('sub dir', 'foo.vcxproj')) import SCons.Platform.win32 -system_dll_path = os.path.join( SCons.Platform.win32.get_system_root(), 'System32' ) +system_dll_path = os.path.join(SCons.Platform.win32.get_system_root(), 'System32') os.environ['PATH'] = os.environ['PATH'] + os.pathsep + system_dll_path test.run(chdir='sub dir', -- cgit v0.12 From 145ea2dd95fdca55599625ef3f967aa106267e90 Mon Sep 17 00:00:00 2001 From: Brian Quistorff Date: Sun, 17 Oct 2021 22:05:55 -0400 Subject: Fix crash when a signal handler is set from outside Python If a signal handler is set from outside python (e.g., C extension) then retrieving the signal returns None, but that value can't be then used to set the signal. In this case reset to default handler after we're done. --- CHANGES.txt | 4 ++++ SCons/Job.py | 14 +++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 59b7621..18f248e 100755 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -57,6 +57,10 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - Change SCons.Scanner.Base to ScannerBase. Old name kept as an alias but is now unused in SCons itself. + From Brian Quistorff: + - Fix crash when scons is run from a python environement where a signal + is set from outside Python. + RELEASE 4.2.0 - Sat, 31 Jul 2021 18:12:46 -0700 diff --git a/SCons/Job.py b/SCons/Job.py index f87a3bb..0dcc6ca 100644 --- a/SCons/Job.py +++ b/SCons/Job.py @@ -147,15 +147,23 @@ class Jobs: self.old_sighup = signal.signal(signal.SIGHUP, handler) except AttributeError: pass + if (self.old_sigint is None) or (self.old_sigterm is None) or \ + (hasattr(self, "old_sighup") and self.old_sighup is None): + msg = "Overwritting previous signal handler which was not installed from Python. " + \ + "Will not be able to reinstate and so will return to default handler." + SCons.Warnings.warn(SCons.Warnings.SConsWarning, msg) def _reset_sig_handler(self): """Restore the signal handlers to their previous state (before the call to _setup_sig_handler().""" - signal.signal(signal.SIGINT, self.old_sigint) - signal.signal(signal.SIGTERM, self.old_sigterm) + signal.signal(signal.SIGINT, self.old_sigint if self.old_sigint is not None \ + else signal.SIG_DFL) + signal.signal(signal.SIGTERM, self.old_sigterm if self.old_sigterm is not None \ + else signal.SIG_DFL) try: - signal.signal(signal.SIGHUP, self.old_sighup) + signal.signal(signal.SIGHUP, self.old_sighup if self.old_sighup is not None \ + else signal.SIG_DFL) except AttributeError: pass -- cgit v0.12 From eeae0ba0ad3d2571c0360e1a28b4013125edea8f Mon Sep 17 00:00:00 2001 From: Brian Quistorff Date: Mon, 18 Oct 2021 14:36:33 -0400 Subject: Address PR comments (isolate conditional and address flake8) --- SCons/Job.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/SCons/Job.py b/SCons/Job.py index 0dcc6ca..dc5398e 100644 --- a/SCons/Job.py +++ b/SCons/Job.py @@ -148,7 +148,7 @@ class Jobs: except AttributeError: pass if (self.old_sigint is None) or (self.old_sigterm is None) or \ - (hasattr(self, "old_sighup") and self.old_sighup is None): + (hasattr(self, "old_sighup") and self.old_sighup is None): msg = "Overwritting previous signal handler which was not installed from Python. " + \ "Will not be able to reinstate and so will return to default handler." SCons.Warnings.warn(SCons.Warnings.SConsWarning, msg) @@ -156,14 +156,13 @@ class Jobs: def _reset_sig_handler(self): """Restore the signal handlers to their previous state (before the call to _setup_sig_handler().""" - - signal.signal(signal.SIGINT, self.old_sigint if self.old_sigint is not None \ - else signal.SIG_DFL) - signal.signal(signal.SIGTERM, self.old_sigterm if self.old_sigterm is not None \ - else signal.SIG_DFL) + sigint_to_use = self.old_sigint if self.old_sigint is not None else signal.SIG_DFL + sigterm_to_use = self.old_sigterm if self.old_sigterm is not None else signal.SIG_DFL + signal.signal(signal.SIGINT, sigint_to_use) + signal.signal(signal.SIGTERM, sigterm_to_use) try: - signal.signal(signal.SIGHUP, self.old_sighup if self.old_sighup is not None \ - else signal.SIG_DFL) + sigterm_to_use = self.old_sighup if self.old_sighup is not None else signal.SIG_DFL + signal.signal(signal.SIGHUP, sigterm_to_use) except AttributeError: pass -- cgit v0.12 From bf92ddc050fc3807ba2b8ff6116528f656e3197f Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Sat, 23 Oct 2021 08:39:40 -0600 Subject: Make subst call a callable with sig set properly If the substable element is a callable, only set for_signature true if the mode is SUBST_SIG. Previously it was set even if the mode was SUBST_RAW. Fixes #4037 Signed-off-by: Mats Wichmann --- CHANGES.txt | 4 +++ SCons/Subst.py | 3 +- test/textfile/fixture/SConstruct.issue-4037 | 18 ++++++++++ test/textfile/issue-3540.py | 6 ++-- test/textfile/issue-3550.py | 11 +++--- test/textfile/issue-4037.py | 52 +++++++++++++++++++++++++++++ test/textfile/textfile.py | 1 + 7 files changed, 86 insertions(+), 9 deletions(-) create mode 100644 test/textfile/fixture/SConstruct.issue-4037 create mode 100644 test/textfile/issue-4037.py diff --git a/CHANGES.txt b/CHANGES.txt index ff7aa5c..6116748 100755 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -75,6 +75,10 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER problems, allowing a more helpful error to be emitted (issue #2828) - Maintenance: Python thread.setDaemon is deprecated in favor of directly updating daemon attribute - update SCons to do this. + - Make sure when subst'ing a callable, the callable is called with + the correct for_signature value, previously it would be true even + if doing SUBST_RAW (issue #4037) + RELEASE 4.2.0 - Sat, 31 Jul 2021 18:12:46 -0700 diff --git a/SCons/Subst.py b/SCons/Subst.py index 4d732c3..298df38 100644 --- a/SCons/Subst.py +++ b/SCons/Subst.py @@ -416,6 +416,7 @@ class StringSubber: return conv(substitute(l, lvars)) return list(map(func, s)) elif callable(s): + # SCons has the unusual Null class where any __getattr__ call returns it's self, # which does not work the signature module, and the Null class returns an empty # string if called on, so we make an exception in this condition for Null class @@ -427,7 +428,7 @@ class StringSubber: s = s(target=lvars['TARGETS'], source=lvars['SOURCES'], env=self.env, - for_signature=(self.mode != SUBST_CMD)) + for_signature=(self.mode == SUBST_SIG)) else: # This probably indicates that it's a callable # object that doesn't match our calling arguments diff --git a/test/textfile/fixture/SConstruct.issue-4037 b/test/textfile/fixture/SConstruct.issue-4037 new file mode 100644 index 0000000..d5c8f96 --- /dev/null +++ b/test/textfile/fixture/SConstruct.issue-4037 @@ -0,0 +1,18 @@ +env = Environment() + +def generator(source, target, env, for_signature): + if for_signature: + return "sig" + return "val" + +env['GENERATOR'] = generator + +env.Textfile( + target="target", + source=[ + "@generated@", + ], + SUBST_DICT={ + '@generated@' : '$GENERATOR', + }, +) diff --git a/test/textfile/issue-3540.py b/test/textfile/issue-3540.py index 44a185b..3e24362 100644 --- a/test/textfile/issue-3540.py +++ b/test/textfile/issue-3540.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,9 +22,7 @@ # 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 for GH Issue 3540 diff --git a/test/textfile/issue-3550.py b/test/textfile/issue-3550.py index de82ee2..199d95d 100644 --- a/test/textfile/issue-3550.py +++ b/test/textfile/issue-3550.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,14 +22,13 @@ # 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 for GH Issue 3550 - You can't pass a Windows path in a value to be interpolated, - because SCons will try to pass it through re.sub which rejects certain character sequences. +You can't pass a Windows path in a value to be interpolated, +because SCons will try to pass it through re.sub which rejects +certain character sequences. """ import TestSCons diff --git a/test/textfile/issue-4037.py b/test/textfile/issue-4037.py new file mode 100644 index 0000000..b18b6ef --- /dev/null +++ b/test/textfile/issue-4037.py @@ -0,0 +1,52 @@ +#!/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 for GH Issue 4037 + +The fix for #4031 created a code path where the subst function +used by textfile was called with SUBST_RAW, which, if the items to +subst was a callable, caused it to be called with for_signature=True. +This did not happen previously as the test was "!= SUBST_CMD", +and the mode coming in was indeed SUBST_CMD. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +match_mode = 'r' + +test.file_fixture('fixture/SConstruct.issue-4037', 'SConstruct') + +test.run(arguments='.') + +test.must_match( + 'target.txt', + "val", + mode=match_mode, +) + +test.pass_test() diff --git a/test/textfile/textfile.py b/test/textfile/textfile.py index 936eaf5..a2d005c 100644 --- a/test/textfile/textfile.py +++ b/test/textfile/textfile.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# # MIT License # # Copyright The SCons Foundation -- cgit v0.12 From 5465de09579826352bbe090b15751f44c8aed61d Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Thu, 28 Oct 2021 07:27:51 -0600 Subject: Update NodeList to get rid of old workaround The NodeList had code to sort of manually build up a new list due to some issues over slicing in very early Python 3. Added some return-type annotations. Signed-off-by: Mats Wichmann --- CHANGES.txt | 2 ++ SCons/Util.py | 34 ++++++++++++++-------------------- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 6116748..b251b83 100755 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -78,6 +78,8 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - Make sure when subst'ing a callable, the callable is called with the correct for_signature value, previously it would be true even if doing SUBST_RAW (issue #4037) + - Update Util/NodeList implementation to get rid of a workaround for + early Python 3 slicing issue that is no longer a problem. diff --git a/SCons/Util.py b/SCons/Util.py index 1045ccf..0dd6ff1 100644 --- a/SCons/Util.py +++ b/SCons/Util.py @@ -119,10 +119,14 @@ def updrive(path) -> str: class NodeList(UserList): """A list of Nodes with special attribute retrieval. - This class is almost exactly like a regular list of Nodes - (actually it can hold any object), with one important difference. - If you try to get an attribute from this list, it will return that - attribute from every item in the list. For example: + Unlike an ordinary list, access to a member's attribute returns a + `NodeList` containing the same attribute for each member. Although + this can hold any object, it is intended for use when processing + Nodes, where fetching an attribute of each member is very commone, + for example getting the content signature of each node. The term + "attribute" here includes the string representation. + + Example: >>> someList = NodeList([' foo ', ' bar ']) >>> someList.strip() @@ -138,30 +142,20 @@ class NodeList(UserList): def __iter__(self): return iter(self.data) - def __call__(self, *args, **kwargs): + def __call__(self, *args, **kwargs) -> 'NodeList': result = [x(*args, **kwargs) for x in self.data] return self.__class__(result) - def __getattr__(self, name): + def __getattr__(self, name) -> 'NodeList': + """Returns a NodeList of `name` from each member.""" result = [getattr(x, name) for x in self.data] return self.__class__(result) def __getitem__(self, index): - """ - This comes for free on py2, - but py3 slices of NodeList are returning a list - breaking slicing nodelist and refering to - properties and methods on contained object - """ -# return self.__class__(self.data[index]) - + """Returns one item, forces a `NodeList` if `index` is a slice.""" + # TODO: annotate return how? Union[] - don't know type of single item if isinstance(index, slice): - # Expand the slice object using range() - # limited by number of items in self.data - indices = index.indices(len(self.data)) - return self.__class__([self[x] for x in range(*indices)]) - - # Return one item of the tart + return self.__class__(self.data[index]) return self.data[index] -- cgit v0.12 From 0071e17593b0d094d570529dddefac0276ddb385 Mon Sep 17 00:00:00 2001 From: Omar Polo Date: Fri, 29 Oct 2021 09:22:34 +0200 Subject: skip test on non-linux platforms leaky-handles requires a /proc/ partition which isn't present on most posix-y platforms: OpenBSD and darwin lacks a procfs, while on FreeBSD must be explicitly mounted by the user (is disabled by default.) --- test/leaky-handles.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/leaky-handles.py b/test/leaky-handles.py index e64053c..13ea130 100644 --- a/test/leaky-handles.py +++ b/test/leaky-handles.py @@ -28,15 +28,14 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" Verify that file handles aren't leaked to child processes """ -import os import sys import TestSCons test = TestSCons.TestSCons() -if os.name != 'posix' or sys.platform == 'darwin': - msg = "Skipping fork leak test on non-posix platform '%s'\n" % os.name +if sys.platform != 'linux': + msg = "Skipping fork leak test on non-linux platforms\n" test.skip_test(msg) test.write('SConstruct', """ -- cgit v0.12 From ad95680fa935f0fcf320d9293535a811b88584e1 Mon Sep 17 00:00:00 2001 From: Omar Polo Date: Fri, 29 Oct 2021 09:34:52 +0200 Subject: drop unnecessary soname check on OpenBSD The changelog for the 4.1 release says that - No longer automatically disable setting SONAME on shared libraries on OpenBSD. this bit was left out. --- test/Libs/SharedLibrary.py | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/test/Libs/SharedLibrary.py b/test/Libs/SharedLibrary.py index f67d707..cda9065 100644 --- a/test/Libs/SharedLibrary.py +++ b/test/Libs/SharedLibrary.py @@ -57,13 +57,6 @@ obj = env.SharedObject('bar', 'foo.c') Default(env.Library(target='foo', source=obj)) """) -test.write('SConstructBaz', """ -env = Environment() -env['SHLIBVERSION'] = '1.0.0' -obj = env.SharedObject('baz', 'foo.c') -Default(env.SharedLibrary(target='baz', source=obj)) -""") - test.write('foo.c', r""" #include @@ -288,12 +281,6 @@ main(int argc, char *argv[]) test.run(program = test.workpath('progbar'), stdout = "f4.c\nprogbar.c\n") -if sys.platform.startswith('openbsd'): - # Make sure we don't link libraries with -Wl,-soname on OpenBSD. - test.run(arguments = '-f SConstructBaz') - for line in test.stdout().split('\n'): - test.fail_test(line.find('-Wl,-soname=libbaz.so') != -1) - test.pass_test() # Local Variables: -- cgit v0.12 From 1c2fa05120ba1df591235c05ad52fb80b0870b22 Mon Sep 17 00:00:00 2001 From: Omar Polo Date: Fri, 29 Oct 2021 09:47:40 +0200 Subject: fix test regexp On OpenBSD the output is sh: : cannot execute - Is a directory --- test/Errors/execute-a-directory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Errors/execute-a-directory.py b/test/Errors/execute-a-directory.py index ff50620..8460e26 100644 --- a/test/Errors/execute-a-directory.py +++ b/test/Errors/execute-a-directory.py @@ -64,7 +64,7 @@ scons: \\*\\*\\* \\[%s\\] Error 1 """ cannot_execute = """\ -(sh: )*.+: cannot execute( \\[Is a directory\\])? +(sh: )*.+: cannot execute(( -)? \\[?Is a directory\\]?)? scons: \\*\\*\\* \\[%s\\] Error %s """ -- cgit v0.12 From 71f1ae69b1e55dd3f61fe477063749da95cf8b08 Mon Sep 17 00:00:00 2001 From: Omar Polo Date: Fri, 29 Oct 2021 09:52:29 +0200 Subject: fix test regexp On OpenBSD the output is sh: : cannot execute - Permission denied --- test/Errors/non-executable-file.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Errors/non-executable-file.py b/test/Errors/non-executable-file.py index 98d4721..0363ab7 100644 --- a/test/Errors/non-executable-file.py +++ b/test/Errors/non-executable-file.py @@ -53,7 +53,7 @@ scons: \\*\\*\\* \\[%s\\] Error 1 """ cannot_execute = """\ -(sh: )*.+: cannot execute( \\[Permission denied\\])? +(sh: )*.+: cannot execute(( -)? \\[?Permission denied\\]?)? scons: \\*\\*\\* \\[%s\\] Error %s """ -- cgit v0.12 From 40ede9995361abb3169891486754f51bfaabdf9b Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Sun, 31 Oct 2021 12:01:25 -0600 Subject: Java tests: minor cleanups Update file headers Remove references to javah that are not used Black a couple of SConstcuts No functional changes - prep work for javah workarounds. Signed-off-by: Mats Wichmann --- test/Java/DerivedSourceTest.py | 7 +++---- test/Java/JAR.py | 7 +++---- test/Java/JARCHDIR.py | 7 +++---- test/Java/JARCOM.py | 7 +++---- test/Java/JARCOMSTR.py | 7 +++---- test/Java/JARFLAGS.py | 8 +++----- test/Java/JAVABOOTCLASSPATH.py | 19 +++++++------------ test/Java/JAVAC.py | 7 +++---- test/Java/JAVACCOM.py | 7 +++---- test/Java/JAVACCOMSTR.py | 7 +++---- test/Java/JAVACFLAGS.py | 7 +++---- test/Java/JAVACLASSPATH.py | 7 +++---- test/Java/JAVAH.py | 7 +++---- test/Java/JAVAHCOM.py | 19 ++++++++++--------- test/Java/JAVAHCOMSTR.py | 21 +++++++++++---------- test/Java/JAVASOURCEPATH.py | 19 ++++++++----------- test/Java/Java-1.4.py | 6 +++--- test/Java/Java-1.5.py | 6 +++--- test/Java/Java-1.6.py | 4 ---- test/Java/Java-1.8.py | 6 +++--- test/Java/RMIC.py | 7 +++---- test/Java/RMICCOM.py | 7 +++---- test/Java/RMICCOMSTR.py | 7 +++---- test/Java/jar_not_in_PATH.py | 7 +++---- test/Java/multi-step.py | 6 +++--- test/Java/nested-classes.py | 8 +++----- test/Java/no-JARCHDIR.py | 7 +++---- test/Java/rmic_not_in_PATH.py | 7 +++---- test/Java/source-files.py | 17 +++++++---------- test/Java/swig-dependencies.py | 17 +++++++---------- 30 files changed, 119 insertions(+), 156 deletions(-) diff --git a/test/Java/DerivedSourceTest.py b/test/Java/DerivedSourceTest.py index 7f80595..e54b8c8 100644 --- a/test/Java/DerivedSourceTest.py +++ b/test/Java/DerivedSourceTest.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,9 +22,6 @@ # 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 of javac.py when building java code from derived sources. diff --git a/test/Java/JAR.py b/test/Java/JAR.py index 2cd6012..bc52a89 100644 --- a/test/Java/JAR.py +++ b/test/Java/JAR.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,9 +22,6 @@ # 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 os import TestSCons diff --git a/test/Java/JARCHDIR.py b/test/Java/JARCHDIR.py index 24a8597..49e7344 100644 --- a/test/Java/JARCHDIR.py +++ b/test/Java/JARCHDIR.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,9 +22,6 @@ # 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 that when JARCHDIR that our command to create .jar files diff --git a/test/Java/JARCOM.py b/test/Java/JARCOM.py index 9146445..ce5dc77 100644 --- a/test/Java/JARCOM.py +++ b/test/Java/JARCOM.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,9 +22,6 @@ # 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 the ability to configure the $JARCOM construction variable. diff --git a/test/Java/JARCOMSTR.py b/test/Java/JARCOMSTR.py index 4bdc45b..b4a2efc 100644 --- a/test/Java/JARCOMSTR.py +++ b/test/Java/JARCOMSTR.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,9 +22,6 @@ # 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 that the $JARCOMSTR construction variable allows you to configure diff --git a/test/Java/JARFLAGS.py b/test/Java/JARFLAGS.py index fc6e55e..7c16491 100644 --- a/test/Java/JARFLAGS.py +++ b/test/Java/JARFLAGS.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,10 +22,6 @@ # 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 diff --git a/test/Java/JAVABOOTCLASSPATH.py b/test/Java/JAVABOOTCLASSPATH.py index 8aaf869..69d9471 100644 --- a/test/Java/JAVABOOTCLASSPATH.py +++ b/test/Java/JAVABOOTCLASSPATH.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,9 +22,6 @@ # 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 that use of $JAVABOOTCLASSPATH sets the -bootclasspath option @@ -33,19 +32,15 @@ import os import TestSCons -_python_ = TestSCons._python_ - test = TestSCons.TestSCons() where_javac, java_version = test.java_where_javac() -where_javah = test.java_where_javah() test.write('SConstruct', """ -env = Environment(tools = ['javac', 'javah'], - JAVABOOTCLASSPATH = ['dir1', 'dir2']) -j1 = env.Java(target = 'class', source = 'com/Example1.java') -j2 = env.Java(target = 'class', source = 'com/Example2.java') -""" % locals()) +env = Environment(tools=['javac'], JAVABOOTCLASSPATH=['dir1', 'dir2']) +j1 = env.Java(target='class', source='com/Example1.java') +j2 = env.Java(target='class', source='com/Example2.java') +""") test.subdir('com') diff --git a/test/Java/JAVAC.py b/test/Java/JAVAC.py index aaaa8f5..20f7f96 100644 --- a/test/Java/JAVAC.py +++ b/test/Java/JAVAC.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,9 +22,6 @@ # 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 setting the JAVAC variable. diff --git a/test/Java/JAVACCOM.py b/test/Java/JAVACCOM.py index 0de173d..3bb4dfb 100644 --- a/test/Java/JAVACCOM.py +++ b/test/Java/JAVACCOM.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,9 +22,6 @@ # 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 the ability to configure the $JAVACCOM construction variable. diff --git a/test/Java/JAVACCOMSTR.py b/test/Java/JAVACCOMSTR.py index 8540e13..4e25815 100644 --- a/test/Java/JAVACCOMSTR.py +++ b/test/Java/JAVACCOMSTR.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,9 +22,6 @@ # 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 that the $JAVACCOMSTR construction variable allows you to configure diff --git a/test/Java/JAVACFLAGS.py b/test/Java/JAVACFLAGS.py index 28c58c1..a40610d 100644 --- a/test/Java/JAVACFLAGS.py +++ b/test/Java/JAVACFLAGS.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,9 +22,6 @@ # 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 os diff --git a/test/Java/JAVACLASSPATH.py b/test/Java/JAVACLASSPATH.py index fb2b33f..aefacca 100644 --- a/test/Java/JAVACLASSPATH.py +++ b/test/Java/JAVACLASSPATH.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,9 +22,6 @@ # 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 that use of $JAVASOURCEPATH allows finding Java .class diff --git a/test/Java/JAVAH.py b/test/Java/JAVAH.py index c7ac334..853b2da 100644 --- a/test/Java/JAVAH.py +++ b/test/Java/JAVAH.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,9 +22,6 @@ # 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 os diff --git a/test/Java/JAVAHCOM.py b/test/Java/JAVAHCOM.py index 801707e..00df2ae 100644 --- a/test/Java/JAVAHCOM.py +++ b/test/Java/JAVAHCOM.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,9 +22,6 @@ # 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 the ability to configure the $JAVAHCOM construction variable. @@ -37,11 +36,13 @@ test = TestSCons.TestSCons() test.file_fixture('mycompile.py') test.write('SConstruct', """ -env = Environment(TOOLS = ['default', 'javah'], - JAVAHCOM = r'%(_python_)s mycompile.py javah $TARGET $SOURCES') -env.JavaH(target = 'out', source = 'file1.class') -env.JavaH(target = 'out', source = 'file2.class') -env.JavaH(target = 'out', source = 'file3.class') +env = Environment( + TOOLS=['default', 'javah'], + JAVAHCOM=r'%(_python_)s mycompile.py javah $TARGET $SOURCES', +) +env.JavaH(target='out', source='file1.class') +env.JavaH(target='out', source='file2.class') +env.JavaH(target='out', source='file3.class') """ % locals()) test.write('file1.class', "file1.class\n/*javah*/\n") diff --git a/test/Java/JAVAHCOMSTR.py b/test/Java/JAVAHCOMSTR.py index c205890..3936947 100644 --- a/test/Java/JAVAHCOMSTR.py +++ b/test/Java/JAVAHCOMSTR.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,9 +22,6 @@ # 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 that the $JAVAHCOMSTR construction variable allows you to configure @@ -46,12 +45,14 @@ out_file3_h = os.path.join('out', 'file3.h') test.file_fixture('mycompile.py') test.write('SConstruct', """ -env = Environment(TOOLS = ['default', 'javah'], - JAVAHCOM = r'%(_python_)s mycompile.py javah $TARGET $SOURCES', - JAVAHCOMSTR = 'Building javah $TARGET from $SOURCES') -env.JavaH(target = 'out', source = 'file1.class') -env.JavaH(target = 'out', source = 'file2.class') -env.JavaH(target = 'out', source = 'file3.class') +env = Environment( + TOOLS=['default', 'javah'], + JAVAHCOM=r'%(_python_)s mycompile.py javah $TARGET $SOURCES', + JAVAHCOMSTR='Building javah $TARGET from $SOURCES', +) +env.JavaH(target='out', source='file1.class') +env.JavaH(target='out', source='file2.class') +env.JavaH(target='out', source='file3.class') """ % locals()) test.write('file1.class', "file1.class\n/*javah*/\n") diff --git a/test/Java/JAVASOURCEPATH.py b/test/Java/JAVASOURCEPATH.py index 8e7b762..19a474d 100644 --- a/test/Java/JAVASOURCEPATH.py +++ b/test/Java/JAVASOURCEPATH.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,9 +22,6 @@ # 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 that use of $JAVASOURCEPATH allows finding source .java @@ -32,18 +31,16 @@ to the javac command line. import TestSCons -_python_ = TestSCons._python_ - test = TestSCons.TestSCons() where_javac, java_version = test.java_where_javac() test.write('SConstruct', """ -env = Environment(tools = ['javac', 'javah']) -bar = env.Java(target = 'bar/classes', - source = 'bar/src/TestBar.java', - JAVASOURCEPATH = ['foo/src']) -""" % locals()) +env = Environment(tools=['javac']) +bar = env.Java( + target='bar/classes', source='bar/src/TestBar.java', JAVASOURCEPATH=['foo/src'] +) +""") test.subdir('foo', ['foo', 'src'], diff --git a/test/Java/Java-1.4.py b/test/Java/Java-1.4.py index 8bbefaf..96e6368 100644 --- a/test/Java/Java-1.4.py +++ b/test/Java/Java-1.4.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 @@ -21,8 +23,6 @@ # 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 Java compilation with a live Java 1.4 "javac" compiler. """ diff --git a/test/Java/Java-1.5.py b/test/Java/Java-1.5.py index 58513e2..5e6cbd7 100644 --- a/test/Java/Java-1.5.py +++ b/test/Java/Java-1.5.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 @@ -21,8 +23,6 @@ # 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 Java compilation with a live Java 1.5 "javac" compiler. """ diff --git a/test/Java/Java-1.6.py b/test/Java/Java-1.6.py index b99a26a..c759e87 100644 --- a/test/Java/Java-1.6.py +++ b/test/Java/Java-1.6.py @@ -1,7 +1,5 @@ #!/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 @@ -21,8 +19,6 @@ # 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 Java compilation with a live Java 1.6 "javac" compiler. """ diff --git a/test/Java/Java-1.8.py b/test/Java/Java-1.8.py index 4fcfe2b..4e54208 100644 --- a/test/Java/Java-1.8.py +++ b/test/Java/Java-1.8.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 @@ -21,8 +23,6 @@ # 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 Java compilation with a live Java 1.8 "javac" compiler. """ diff --git a/test/Java/RMIC.py b/test/Java/RMIC.py index 519ad5b..dafb9cd 100644 --- a/test/Java/RMIC.py +++ b/test/Java/RMIC.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,9 +22,6 @@ # 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 os diff --git a/test/Java/RMICCOM.py b/test/Java/RMICCOM.py index 9f6595d..8a00b25 100644 --- a/test/Java/RMICCOM.py +++ b/test/Java/RMICCOM.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,9 +22,6 @@ # 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 the ability to configure the $RMICCOM construction variable. diff --git a/test/Java/RMICCOMSTR.py b/test/Java/RMICCOMSTR.py index d4d1904..2425a3d 100644 --- a/test/Java/RMICCOMSTR.py +++ b/test/Java/RMICCOMSTR.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,9 +22,6 @@ # 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 that the $RMICCOMSTR construction variable allows you to configure diff --git a/test/Java/jar_not_in_PATH.py b/test/Java/jar_not_in_PATH.py index d69f9c3..26e92ce 100644 --- a/test/Java/jar_not_in_PATH.py +++ b/test/Java/jar_not_in_PATH.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,9 +22,6 @@ # 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__" """ Ensures that the Tool gets initialized, even when jar is not directly diff --git a/test/Java/multi-step.py b/test/Java/multi-step.py index b3f9896..37656b8 100644 --- a/test/Java/multi-step.py +++ b/test/Java/multi-step.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 @@ -26,8 +28,6 @@ Real-world test (courtesy Leanid Nazdrynau) of the multi-step capabilities of the various Java Builders. """ -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" - import os import TestSCons diff --git a/test/Java/nested-classes.py b/test/Java/nested-classes.py index 0208eb6..6f4aff9 100644 --- a/test/Java/nested-classes.py +++ b/test/Java/nested-classes.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,15 +22,11 @@ # 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 Java compilation with inner and anonymous classes (Issue 2087). """ - import TestSCons _python_ = TestSCons._python_ diff --git a/test/Java/no-JARCHDIR.py b/test/Java/no-JARCHDIR.py index 11754c0..d339251 100644 --- a/test/Java/no-JARCHDIR.py +++ b/test/Java/no-JARCHDIR.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,9 +22,6 @@ # 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 the Jar() behavior when we have no JARCHDIR set (it should diff --git a/test/Java/rmic_not_in_PATH.py b/test/Java/rmic_not_in_PATH.py index 9c7030c..ac3f28e 100644 --- a/test/Java/rmic_not_in_PATH.py +++ b/test/Java/rmic_not_in_PATH.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,9 +22,6 @@ # 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__" """ Ensures that the Tool gets initialized, even when rmic is not directly diff --git a/test/Java/source-files.py b/test/Java/source-files.py index e5cb8b6..23e5ebc 100644 --- a/test/Java/source-files.py +++ b/test/Java/source-files.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,9 +22,6 @@ # 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 that we can pass the Java() builder explicit lists of .java @@ -31,8 +30,6 @@ files as sources. import TestSCons -_python_ = TestSCons._python_ - test = TestSCons.TestSCons() # Keep this logic because it skips the test if javac or jar not found. @@ -40,10 +37,10 @@ where_javac, java_version = test.java_where_javac() where_jar = test.java_where_jar() test.write('SConstruct', """ -env = Environment(tools = ['javac', 'javah']) -env.Java(target = 'class1', source = 'com/Example1.java') -env.Java(target = 'class2', source = ['com/Example2.java', 'com/Example3.java']) -""" % locals()) +env = Environment(tools=['javac']) +env.Java(target='class1', source='com/Example1.java') +env.Java(target='class2', source=['com/Example2.java', 'com/Example3.java']) +""") test.subdir('com', 'src') diff --git a/test/Java/swig-dependencies.py b/test/Java/swig-dependencies.py index c1821f8..48010ad 100644 --- a/test/Java/swig-dependencies.py +++ b/test/Java/swig-dependencies.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,9 +22,6 @@ # 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 that dependencies on SWIG-generated .java files work correctly. @@ -39,8 +38,6 @@ if not swig: test.skip_test('Can not find installed "swig", skipping test.\n') where_javac, java_version = test.java_where_javac() -where_javah = test.java_where_javah() - where_java_include=test.java_where_includes() test.subdir(['foo'], @@ -50,11 +47,11 @@ test.subdir(['foo'], test.write(['SConstruct'], """\ import os -env = Environment(ENV = os.environ) +env = Environment(ENV=os.environ) if env['PLATFORM'] != 'win32': - env.Append(CPPFLAGS = ' -g -Wall') -env['CPPPATH'] ='$JAVAINCLUDES' - + env.Append(CPPFLAGS=' -g -Wall') +env['CPPPATH'] = '$JAVAINCLUDES' + Export('env') SConscript('#foo/SConscript') -- cgit v0.12 From c8a32bbade10418eb613ac5c4be90ea6494d6aa8 Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Sun, 31 Oct 2021 12:34:13 -0600 Subject: Skip unusable javah tests For the three tests which fail, skip if the command finder (WhereIs), which is much less aggressive than the java_where_j* routines, doesn't find javah. Split the JAVAH test file into two files, so that the part which doesn't call javah can run even if the rest is skipped. Did the header cleanup and partial reformats on those. Leave a comment in the Repository/JavaH test, and do some reformatting there as well. Test needs rework, but for now doesn't fail so leave alone. Signed-off-by: Mats Wichmann --- CHANGES.txt | 3 +- test/Java/JAVACLASSPATH.py | 15 ++++-- test/Java/JAVAH-mock.py | 100 ++++++++++++++++++++++++++++++++++ test/Java/JAVAH.py | 69 +++--------------------- test/Java/multi-step.py | 132 ++++++++++++++++++++++++--------------------- test/Repository/JavaH.py | 41 +++++++------- 6 files changed, 214 insertions(+), 146 deletions(-) create mode 100644 test/Java/JAVAH-mock.py diff --git a/CHANGES.txt b/CHANGES.txt index f6dbf5f..b4cde3d 100755 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -80,7 +80,8 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER if doing SUBST_RAW (issue #4037) - Update Util/NodeList implementation to get rid of a workaround for early Python 3 slicing issue that is no longer a problem. - + - Rework some Java tests to skip rather than fail on CI systems, where + the working java is > v9, but a 1.8 or 9 was also found. From Brian Quistorff: - Fix crash when scons is run from a python environement where a signal diff --git a/test/Java/JAVACLASSPATH.py b/test/Java/JAVACLASSPATH.py index aefacca..6f062db 100644 --- a/test/Java/JAVACLASSPATH.py +++ b/test/Java/JAVACLASSPATH.py @@ -38,11 +38,18 @@ test = TestSCons.TestSCons() where_javac, java_version = test.java_where_javac() where_javah = test.java_where_javah() +# TODO rework for 'javac -h', for now skip +# The logical test would be: +# if float(java_version) > 9: +# but java_where_javac() lies on a multi-java system +if not test.Environment().WhereIs('javah'): + test.skip_test("No Java javah for version > 9, skipping test.\n") + test.write('SConstruct', """ -env = Environment(tools = ['javac', 'javah']) -j1 = env.Java(target = 'class1', source = 'com.1/Example1.java') -j2 = env.Java(target = 'class2', source = 'com.2/Example2.java') -env.JavaH(target = 'outdir', source = [j1, j2], JAVACLASSPATH = 'class2') +env = Environment(tools=['javac', 'javah']) +j1 = env.Java(target='class1', source='com.1/Example1.java') +j2 = env.Java(target='class2', source='com.2/Example2.java') +env.JavaH(target='outdir', source=[j1, j2], JAVACLASSPATH='class2') """ % locals()) test.subdir('com.1', 'com.2') diff --git a/test/Java/JAVAH-mock.py b/test/Java/JAVAH-mock.py new file mode 100644 index 0000000..e44f533 --- /dev/null +++ b/test/Java/JAVAH-mock.py @@ -0,0 +1,100 @@ +#!/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 JavaH without calling the tool +Split from rest of test to allow these to run if real javah skipped. +""" + +import os + +import TestSCons + +_python_ = TestSCons._python_ + +test = TestSCons.TestSCons() + +test.write('myjavah.py', r""" +import sys +args = sys.argv[1:] +while args: + a = args[0] + if a == '-d': + outdir = args[1] + args = args[1:] + elif a == '-o': + outfile = open(args[1], 'w') + args = args[1:] + elif a == '-classpath': + args = args[1:] + elif a == '-sourcepath': + args = args[1:] + else: + break + args = args[1:] +for file in args: + infile = open(file, 'r') + for l in infile.readlines(): + if l[:9] != '/*javah*/': + outfile.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(tools=['javah'], JAVAH=r'%(_python_)s myjavah.py') +env.JavaH(target=File('test1.h'), source='test1.java') +""" % locals()) + +test.write('test1.java', """\ +test1.java +/*javah*/ +line 3 +""") + +test.run(arguments='.', stderr=None) +test.must_match('test1.h', "test1.java\nline 3\n", mode='r') + +if os.path.normcase('.java') == os.path.normcase('.JAVA'): + test.write('SConstruct', """\ +env = Environment(tools=['javah'], JAVAH=r'%(_python_)s myjavah.py') +env.JavaH(target=File('test2.h'), source='test2.JAVA') +""" % locals()) + + test.write('test2.JAVA', """\ +test2.JAVA +/*javah*/ +line 3 +""") + + test.run(arguments='.', stderr=None) + test.must_match('test2.h', "test2.JAVA\nline 3\n", mode='r') + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Java/JAVAH.py b/test/Java/JAVAH.py index 853b2da..bd05e56 100644 --- a/test/Java/JAVAH.py +++ b/test/Java/JAVAH.py @@ -31,70 +31,8 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() -test.write('myjavah.py', r""" -import sys -args = sys.argv[1:] -while args: - a = args[0] - if a == '-d': - outdir = args[1] - args = args[1:] - elif a == '-o': - outfile = open(args[1], 'w') - args = args[1:] - elif a == '-classpath': - args = args[1:] - elif a == '-sourcepath': - args = args[1:] - else: - break - args = args[1:] -for file in args: - infile = open(file, 'r') - for l in infile.readlines(): - if l[:9] != '/*javah*/': - outfile.write(l) -sys.exit(0) -""") - -test.write('SConstruct', """ -env = Environment(tools = ['javah'], - JAVAH = r'%(_python_)s myjavah.py') -env.JavaH(target = File('test1.h'), source = 'test1.java') -""" % locals()) - -test.write('test1.java', """\ -test1.java -/*javah*/ -line 3 -""") - -test.run(arguments='.', stderr=None) - -test.must_match('test1.h', "test1.java\nline 3\n", mode='r') - -if os.path.normcase('.java') == os.path.normcase('.JAVA'): - - test.write('SConstruct', """\ -env = Environment(tools = ['javah'], - JAVAH = r'%(_python_)s myjavah.py') -env.JavaH(target = File('test2.h'), source = 'test2.JAVA') -""" % locals()) - - test.write('test2.JAVA', """\ -test2.JAVA -/*javah*/ -line 3 -""") - - test.run(arguments='.', stderr=None) - - test.must_match('test2.h', "test2.JAVA\nline 3\n", mode='r') - - where_javac, java_version = test.java_where_javac() where_javah = test.java_where_javah() - if java_version: java_version = repr(java_version) @@ -104,6 +42,13 @@ if java_version: if test.javac_is_gcj: test.skip_test('Test not valid for gcj (gnu java); skipping test(s).\n') +# TODO rework for 'javac -h', for now skip +# The logical test would be: +# if float(java_version) > 9: +# but java_where_javac() lies on a multi-java system +if not test.Environment().WhereIs('javah'): + test.skip_test("No Java javah for version > 9, skipping test.\n") + test.file_fixture('wrapper_with_args.py') test.write('SConstruct', """ diff --git a/test/Java/multi-step.py b/test/Java/multi-step.py index 37656b8..f3eec18 100644 --- a/test/Java/multi-step.py +++ b/test/Java/multi-step.py @@ -26,6 +26,8 @@ """ Real-world test (courtesy Leanid Nazdrynau) of the multi-step capabilities of the various Java Builders. + +TODO: the whole Applet facility is deprecated, need a new test. """ import os @@ -50,27 +52,36 @@ if not swig: if test.javac_is_gcj: test.skip_test('Test not valid for gcj (gnu java); skipping test(s).\n') -test.subdir(['src'], - ['src', 'HelloApplet'], - ['src', 'HelloApplet', 'com'], - ['src', 'javah'], - ['src', 'jni'], - ['src', 'server'], - ['src', 'server', 'JavaSource'], - ['src', 'server', 'JavaSource', 'com'], - ['src', 'server', 'JavaSource', 'com', 'gnu'], - ['src', 'server', 'JavaSource', 'com', 'gnu', 'scons'], - ['src', 'server', 'JavaSource', 'com', 'gnu', 'scons', 'web'], - ['src', 'server', 'JavaSource', 'com', 'gnu', 'scons', 'web', 'tools'], - ['src', 'server', 'WebContent'], - ['src', 'server', 'WebContent', 'META-INF'], - ['src', 'server', 'WebContent', 'WEB-INF'], - ['src', 'server', 'WebContent', 'WEB-INF', 'conf'], - ['src', 'server', 'WebContent', 'WEB-INF', 'lib'], - ['src', 'server', 'WebContent', 'theme']) +# TODO rework for 'javac -h', for now skip +# The logical test would be: +# if float(java_version) > 9: +# but java_where_javac() lies on a multi-java system +if not test.Environment().WhereIs('javah'): + test.skip_test("No Java javah for version > 9, skipping test.\n") + +test.subdir( + ['src'], + ['src', 'HelloApplet'], + ['src', 'HelloApplet', 'com'], + ['src', 'javah'], + ['src', 'jni'], + ['src', 'server'], + ['src', 'server', 'JavaSource'], + ['src', 'server', 'JavaSource', 'com'], + ['src', 'server', 'JavaSource', 'com', 'gnu'], + ['src', 'server', 'JavaSource', 'com', 'gnu', 'scons'], + ['src', 'server', 'JavaSource', 'com', 'gnu', 'scons', 'web'], + ['src', 'server', 'JavaSource', 'com', 'gnu', 'scons', 'web', 'tools'], + ['src', 'server', 'WebContent'], + ['src', 'server', 'WebContent', 'META-INF'], + ['src', 'server', 'WebContent', 'WEB-INF'], + ['src', 'server', 'WebContent', 'WEB-INF', 'conf'], + ['src', 'server', 'WebContent', 'WEB-INF', 'lib'], + ['src', 'server', 'WebContent', 'theme'], +) test.write(['SConstruct'], """\ -import os,sys +import os, sys if sys.platform == 'win32': # Ensure tests don't pick up link from mingw or cygwin @@ -78,31 +89,35 @@ if sys.platform == 'win32': else: tools = ['default', 'javac', 'javah', 'swig'] -env=Environment(tools = tools, - CPPPATH=["$JAVAINCLUDES"]) +env = Environment(tools=tools, CPPPATH=["$JAVAINCLUDES"]) Export('env') # env.PrependENVPath('PATH',os.environ.get('PATH',[])) -env['INCPREFIX']='-I' -env.Append(SWIGFLAGS=['-c++','$_CPPINCFLAGS']) +env['INCPREFIX'] = '-I' +env.Append(SWIGFLAGS=['-c++', '$_CPPINCFLAGS']) -#this is for JNI -#env.Append(CCFLAGS=['/IN:/jdk/v1.3.1/include','/IN:/jdk/v1.3.1/include/win32']) +# this is for JNI +# env.Append(CCFLAGS=['/IN:/jdk/v1.3.1/include','/IN:/jdk/v1.3.1/include/win32']) -#this for windows only C++ build -#env.Append(CXXFLAGS='-GX') +# this for windows only C++ build +# env.Append(CXXFLAGS='-GX') env.Append(CPPPATH='.') env.VariantDir('buildout', 'src', duplicate=0) -if sys.platform[:6]=='darwin': - env.Append(CPPPATH=['/System/Library/Frameworks/JavaVM.framework/Headers']) - -#If you do not have swig on your system please remove 'buildout/jni/SConscript' line from next call -env.SConscript(['buildout/server/JavaSource/SConscript', - 'buildout/HelloApplet/SConscript', - 'buildout/jni/SConscript', - 'buildout/javah/SConscript']) +if sys.platform[:6] == 'darwin': + env.Append(CPPPATH=['/System/Library/Frameworks/JavaVM.framework/Headers']) + +# If you do not have swig on your system please remove +# 'buildout/jni/SConscript' line from next call +env.SConscript( + [ + 'buildout/server/JavaSource/SConscript', + 'buildout/HelloApplet/SConscript', + 'buildout/jni/SConscript', + 'buildout/javah/SConscript', + ] +) """ % locals()) test.write(['src', 'HelloApplet', 'Hello.html'], """\ @@ -123,21 +138,20 @@ test.write(['src', 'HelloApplet', 'Hello.html'], """\ test.write(['src', 'HelloApplet', 'SConscript'], """\ import os -Import ("env") -denv=env.Clone() -classes=denv.Java(target='classes',source=['com']) -#set correct path for jar -denv['JARCHDIR']=os.path.join(denv.Dir('.').get_abspath(),'classes') -denv.Jar('HelloApplet',classes) +Import("env") +denv = env.Clone() +classes = denv.Java(target='classes', source=['com']) +# set correct path for jar +denv['JARCHDIR'] = os.path.join(denv.Dir('.').get_abspath(), 'classes') +denv.Jar('HelloApplet', classes) -#To sign applet you have to create keystore before and made a calls like this - -#keystore='/path/to/jarsignkey' -#denv['JARSIGNFLAGS']='-keystore '+keystore+' -storepass pass -keypass passkey' -#denv['JARSIGNALIAS']='ALIAS' -#denv['JARCOM']=[denv['JARCOM'],'$JARSIGNCOM'] +# To sign applet you have to create keystore before and made a calls like this +# keystore='/path/to/jarsignkey' +# denv['JARSIGNFLAGS']='-keystore '+keystore+' -storepass pass -keypass passkey' +# denv['JARSIGNALIAS']='ALIAS' +# denv['JARCOM']=[denv['JARCOM'],'$JARSIGNCOM'] """) test.write(['src', 'HelloApplet', 'com', 'Hello.java'], """\ @@ -179,12 +193,11 @@ public class MyID test.write(['src', 'javah', 'SConscript'], """\ Import('env') -denv=env.Clone() -denv['JARCHDIR']=denv.Dir('.').get_abspath() -denv.Jar('myid','MyID.java') -denv.JavaH(denv.Dir('.').get_abspath(),'MyID.java') -denv.SharedLibrary('myid','MyID.cc') - +denv = env.Clone() +denv['JARCHDIR'] = denv.Dir('.').get_abspath() +denv.Jar('myid', 'MyID.java') +denv.JavaH(denv.Dir('.').get_abspath(), 'MyID.java') +denv.SharedLibrary('myid', 'MyID.cc') """) test.write(['src', 'jni', 'A.java'], """\ @@ -225,8 +238,6 @@ test.write(['src', 'jni', 'JniWrapper.cc'], """\ #include "JniWrapper.h" - - JniWrapper::JniWrapper( JNIEnv *pEnv ) : mpEnv( pEnv ) { @@ -239,7 +250,6 @@ JniWrapper::JniWrapper( const JniWrapper& rJniWrapper ) JniWrapper::~JniWrapper() { - } JniWrapper& JniWrapper::operator=( const JniWrapper& rJniWrapper ) @@ -373,13 +383,13 @@ private: """) test.write(['src', 'jni', 'SConscript'], """\ -Import ("env") -denv=env.Clone() +Import("env") +denv = env.Clone() denv.Append(SWIGFLAGS=['-java']) -denv.SharedLibrary('scons',['JniWrapper.cc','Sample.i']) -denv['JARCHDIR']=denv.Dir('.').get_abspath() -denv.Jar(['Sample.i','A.java']) +denv.SharedLibrary('scons', ['JniWrapper.cc', 'Sample.i']) +denv['JARCHDIR'] = denv.Dir('.').get_abspath() +denv.Jar(['Sample.i', 'A.java']) """) test.write(['src', 'jni', 'Sample.h'], """\ diff --git a/test/Repository/JavaH.py b/test/Repository/JavaH.py index 1cb5078..77f097d 100644 --- a/test/Repository/JavaH.py +++ b/test/Repository/JavaH.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,9 +22,6 @@ # 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 building Java applications when using Repositories. @@ -44,13 +43,23 @@ java = where_java javac = where_javac javah = where_javah +# TODO: javah no longer exists for Java > 9. Other tests fail +# on certain systems because the java_where_* routines are very greedy +# and may indicate it's found even if the working java is > 9 if there +# was a 1.8 insallation present - and then at runtime it's not found. +# In this case we actually pass the javac/javah that's found by those, +# which means the test will seem to work. We still need to rework this. + ############################################################################### # -test.subdir('rep1', ['rep1', 'src'], - 'work1', - 'work2', - 'work3') +test.subdir( + 'rep1', + ['rep1', 'src'], + 'work1', + 'work2', + 'work3' +) # rep1_classes = test.workpath('rep1', 'classes') @@ -62,11 +71,9 @@ opts = '-Y ' + test.workpath('rep1') # test.write(['rep1', 'SConstruct'], """ -env = Environment(tools = ['javac', 'javah'], - JAVAC = r'"%s"', - JAVAH = r'"%s"') -classes = env.Java(target = 'classes', source = 'src') -env.JavaH(target = 'outdir', source = classes) +env = Environment(tools=['javac', 'javah'], JAVAC=r'"%s"', JAVAH=r'"%s"') +classes = env.Java(target='classes', source='src') +env.JavaH(target='outdir', source=classes) """ % (javac, javah)) test.write(['rep1', 'src', 'Foo1.java'], """\ @@ -206,11 +213,9 @@ test.up_to_date(chdir = 'work2', options = opts, arguments = ".") # test.write(['work3', 'SConstruct'], """ -env = Environment(tools = ['javac', 'javah'], - JAVAC = r'"%s"', - JAVAH = r'"%s"') -classes = env.Java(target = 'classes', source = 'src') -hfiles = env.JavaH(target = 'outdir', source = classes) +env = Environment(tools=['javac', 'javah'], JAVAC=r'"%s"', JAVAH=r'"%s"') +classes = env.Java(target='classes', source='src') +hfiles = env.JavaH(target='outdir', source=classes) Local(hfiles) """ % (javac, javah)) -- cgit v0.12 From 4fc7d2a63b0e0aad569d4218e8b8b28a68db8520 Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Mon, 1 Nov 2021 10:59:18 -0600 Subject: Add an extra check for javah The previous sanity check was to see if the less-optimistic WhereIs could find javah, and skip if not, since java_where_javah looks many more places than SCons will actually look. This was insufficient - some openjdk packages don't clean up the alternatives link to javah even if a java version which doesn't have it becomes the selected version. Add a check on found paths to detect a mismatch. Signed-off-by: Mats Wichmann --- test/Java/JAVACLASSPATH.py | 14 ++++++++-- test/Java/JAVAH.py | 69 +++++++++++++++++++++++++++++----------------- test/Java/multi-step.py | 13 +++++++-- 3 files changed, 65 insertions(+), 31 deletions(-) diff --git a/test/Java/JAVACLASSPATH.py b/test/Java/JAVACLASSPATH.py index 6f062db..aff3a90 100644 --- a/test/Java/JAVACLASSPATH.py +++ b/test/Java/JAVACLASSPATH.py @@ -29,6 +29,8 @@ files in alternate locations by adding the -classpath option to the javac command line. """ +import pathlib + import TestSCons _python_ = TestSCons._python_ @@ -39,12 +41,18 @@ where_javac, java_version = test.java_where_javac() where_javah = test.java_where_javah() # TODO rework for 'javac -h', for now skip -# The logical test would be: -# if float(java_version) > 9: -# but java_where_javac() lies on a multi-java system +# The logical test would be: if java_version > 9: +# but java_where_javah() roots around and will find from an older version if not test.Environment().WhereIs('javah'): test.skip_test("No Java javah for version > 9, skipping test.\n") +# On some systems, the alternatives system does not remove javah even if the +# preferred Java doesn't have it, so try another check +javacdir = pathlib.Path(where_javac).parent +javahdir = pathlib.Path(where_javah).parent +if javacdir != javahdir: + test.skip_test("Cannot find Java javah matching javac, skipping test.\n") + test.write('SConstruct', """ env = Environment(tools=['javac', 'javah']) j1 = env.Java(target='class1', source='com.1/Example1.java') diff --git a/test/Java/JAVAH.py b/test/Java/JAVAH.py index bd05e56..8be3196 100644 --- a/test/Java/JAVAH.py +++ b/test/Java/JAVAH.py @@ -24,6 +24,7 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. import os +import pathlib import TestSCons @@ -43,42 +44,56 @@ if test.javac_is_gcj: test.skip_test('Test not valid for gcj (gnu java); skipping test(s).\n') # TODO rework for 'javac -h', for now skip -# The logical test would be: -# if float(java_version) > 9: -# but java_where_javac() lies on a multi-java system +# The logical test would be: if java_version > 9: +# but java_where_javah() roots around and will find from an older version if not test.Environment().WhereIs('javah'): test.skip_test("No Java javah for version > 9, skipping test.\n") +# On some systems, the alternatives system does not remove javah even if the +# preferred Java doesn't have it, so try another check +javacdir = pathlib.Path(where_javac).parent +javahdir = pathlib.Path(where_javah).parent +if javacdir != javahdir: + test.skip_test("Cannot find Java javah matching javac, skipping test.\n") + test.file_fixture('wrapper_with_args.py') test.write('SConstruct', """ -foo = Environment(tools = ['javac', 'javah', 'install']) +foo = Environment(tools=['javac', 'javah', 'install']) jv = %(java_version)s if jv: foo['JAVAVERSION'] = jv javah = foo.Dictionary('JAVAH') -bar = foo.Clone(JAVAH = r'%(_python_)s wrapper_with_args.py ' + javah) -foo.Java(target = 'class1', source = 'com/sub/foo') -bar_classes = bar.Java(target = 'class2', source = 'com/sub/bar') -foo_classes = foo.Java(target = 'class3', source = 'src') -foo.JavaH(target = 'outdir1', - source = ['class1/com/sub/foo/Example1.class', - 'class1/com/other/Example2', - 'class1/com/sub/foo/Example3'], - JAVACLASSDIR = 'class1') -bar.JavaH(target = 'outdir2', source = bar_classes) -foo.JavaH(target = File('output.h'), source = foo_classes) +bar = foo.Clone(JAVAH=r'%(_python_)s wrapper_with_args.py ' + javah) +foo.Java(target='class1', source='com/sub/foo') +bar_classes = bar.Java(target='class2', source='com/sub/bar') +foo_classes = foo.Java(target='class3', source='src') +foo.JavaH( + target='outdir1', + source=[ + 'class1/com/sub/foo/Example1.class', + 'class1/com/other/Example2', + 'class1/com/sub/foo/Example3', + ], + JAVACLASSDIR='class1', +) +bar.JavaH(target='outdir2', source=bar_classes) +foo.JavaH(target=File('output.h'), source=foo_classes) foo.Install('class4/com/sub/foo', 'class1/com/sub/foo/Example1.class') -foo.JavaH(target = 'outdir4', - source = ['class4/com/sub/foo/Example1.class'], - JAVACLASSDIR = 'class4') +foo.JavaH( + target='outdir4', + source=['class4/com/sub/foo/Example1.class'], + JAVACLASSDIR='class4', +) """ % locals()) -test.subdir('com', - ['com', 'sub'], - ['com', 'sub', 'foo'], - ['com', 'sub', 'bar'], - 'src') +test.subdir( + 'com', + ['com', 'sub'], + ['com', 'sub', 'foo'], + ['com', 'sub', 'bar'], + 'src', +) test.write(['com', 'sub', 'foo', 'Example1.java'], """\ package com.sub.foo; @@ -224,8 +239,12 @@ class Private { test.run(arguments = '.') -test.must_match('wrapper.out', "wrapper_with_args.py javah -d outdir2 -classpath class2 com.sub.bar.Example4 com.other.Example5 com.sub.bar.Example6\n" % locals(), - mode='r') +test.must_match( + 'wrapper.out', + "wrapper_with_args.py javah -d outdir2 -classpath class2 com.sub.bar.Example4 com.other.Example5 com.sub.bar.Example6\n" + % locals(), + mode='r', +) test.must_exist(['outdir1', 'com_sub_foo_Example1.h']) test.must_exist(['outdir1', 'com_other_Example2.h']) diff --git a/test/Java/multi-step.py b/test/Java/multi-step.py index f3eec18..ab627cb 100644 --- a/test/Java/multi-step.py +++ b/test/Java/multi-step.py @@ -31,6 +31,7 @@ TODO: the whole Applet facility is deprecated, need a new test. """ import os +import pathlib import TestSCons @@ -53,12 +54,18 @@ if test.javac_is_gcj: test.skip_test('Test not valid for gcj (gnu java); skipping test(s).\n') # TODO rework for 'javac -h', for now skip -# The logical test would be: -# if float(java_version) > 9: -# but java_where_javac() lies on a multi-java system +# The logical test would be: if java_version > 9: +# but java_where_javah() roots around and will find from an older version if not test.Environment().WhereIs('javah'): test.skip_test("No Java javah for version > 9, skipping test.\n") +# On some systems, the alternatives system does not remove javah even if the +# preferred Java doesn't have it, so try another check +javacdir = pathlib.Path(where_javac).parent +javahdir = pathlib.Path(where_javah).parent +if javacdir != javahdir: + test.skip_test("Cannot find Java javah matching javac, skipping test.\n") + test.subdir( ['src'], ['src', 'HelloApplet'], -- cgit v0.12 From 850bc69d26d078008e750b1a6c096655499bb1ca Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Mon, 1 Nov 2021 11:53:11 -0600 Subject: Also make Repository/JavaH test skip if mismatched javah Signed-off-by: Mats Wichmann --- test/Repository/JavaH.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/test/Repository/JavaH.py b/test/Repository/JavaH.py index 77f097d..fea5f5b 100644 --- a/test/Repository/JavaH.py +++ b/test/Repository/JavaH.py @@ -28,6 +28,7 @@ Test building Java applications when using Repositories. """ import os +import pathlib import TestSCons @@ -39,6 +40,13 @@ where_javac, java_version = test.java_where_javac() where_java = test.java_where_java() where_javah = test.java_where_javah() +# On some systems, the alternatives system does not remove javah even if the +# preferred Java doesn't have it, check the paths just in case. +javacdir = pathlib.Path(where_javac).parent +javahdir = pathlib.Path(where_javah).parent +if javacdir != javahdir: + test.skip_test("Cannot find Java javah matching javac, skipping test.\n") + java = where_java javac = where_javac javah = where_javah @@ -58,7 +66,7 @@ test.subdir( ['rep1', 'src'], 'work1', 'work2', - 'work3' + 'work3', ) # -- cgit v0.12 From e7450cae60e8eb4ca7cb08fb8878c3a7224699b0 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 1 Nov 2021 11:13:35 -0700 Subject: Update copyright text --- SCons/Tool/javac.py | 24 ++++++++++++------------ SCons/Tool/javah.py | 24 +++++++++++------------- 2 files changed, 23 insertions(+), 25 deletions(-) diff --git a/SCons/Tool/javac.py b/SCons/Tool/javac.py index fd007eb..ff206c3 100644 --- a/SCons/Tool/javac.py +++ b/SCons/Tool/javac.py @@ -1,15 +1,6 @@ -"""SCons.Tool.javac - -Tool-specific initialization for javac. - -There normally shouldn't be any need to import this module directly. -It will usually be imported through the generic SCons.Tool.Tool() -selection method. - -""" - +# MIT License # -# __COPYRIGHT__ +# 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 @@ -30,7 +21,16 @@ selection method. # 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__" +"""SCons.Tool.javac + +Tool-specific initialization for javac. + +There normally shouldn't be any need to import this module directly. +It will usually be imported through the generic SCons.Tool.Tool() +selection method. + +""" + import os import os.path diff --git a/SCons/Tool/javah.py b/SCons/Tool/javah.py index fbfcbe2..ca5bca3 100644 --- a/SCons/Tool/javah.py +++ b/SCons/Tool/javah.py @@ -1,15 +1,6 @@ -"""SCons.Tool.javah - -Tool-specific initialization for javah. - -There normally shouldn't be any need to import this module directly. -It will usually be imported through the generic SCons.Tool.Tool() -selection method. - -""" - +# MIT License # -# __COPYRIGHT__ +# 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 @@ -29,9 +20,16 @@ selection method. # 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. -# +"""SCons.Tool.javah + +Tool-specific initialization for javah. + +There normally shouldn't be any need to import this module directly. +It will usually be imported through the generic SCons.Tool.Tool() +selection method. + +""" -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import os.path -- cgit v0.12 From 506850e230c6d9346fbad25f5957e4cbc3c09040 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 1 Nov 2021 11:16:42 -0700 Subject: Added --no-ignore-skips and changed default to only exit status 2 if this flag is specified to runtest.py and some tests are skipped. Otherwise assuming no failures will exit 0 --- CHANGES.txt | 3 +++ RELEASE.txt | 4 +++- runtest.py | 7 ++++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index b4cde3d..197efa4 100755 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -24,6 +24,9 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER introduced by Aaron Franke (listed below) were merged. - Further PCH updates. It's now recommended that env['PCH'] should always be a File node. Either via return value from env.PCH() or by explicitly using File('StdAfx.pch'). + - Added --no-ignore-skips to runtest.py. Changed default to ignore skips when setting + runtest.py's exit status. Previously would exit 2 if any tests were skipped. + Now will only exit 2 if user specifies --no-ignore-skips and some tests were skipped. From Ryan Egesdahl: - Small fix to ensure CLVar default value is an empty list. diff --git a/RELEASE.txt b/RELEASE.txt index 95ee4eb..86f5bff 100755 --- a/RELEASE.txt +++ b/RELEASE.txt @@ -71,7 +71,9 @@ DOCUMENTATION DEVELOPMENT ----------- -- List visible changes in the way SCons is developed +- Added --no-ignore-skips to runtest.py. Changed default to ignore skips when setting + runtest.py's exit status. Previously would exit 2 if any tests were skipped. + Now will only exit 2 if user specifies --no-ignore-skips and some tests were skipped. Thanks to the following contributors listed below for their contributions to this release. ========================================================================================== diff --git a/runtest.py b/runtest.py index 52ceea4..79dce48 100755 --- a/runtest.py +++ b/runtest.py @@ -110,6 +110,11 @@ parser.add_argument('--no-faillog', dest='error_log', default='failed_tests.log', help="Do not log failed tests to a file") +parser.add_argument('--no-ignore-skips', dest='ignore_skips', + action='store_false', + default=True, + help="If any tests are skipped, exit status 2") + outctl = parser.add_argument_group(description='Output control options:') outctl.add_argument('-k', '--no-progress', action='store_false', dest='print_progress', @@ -855,7 +860,7 @@ if args.output: if fail: sys.exit(1) -elif no_result: +elif no_result and args.ignore_skips: # if no fails, but skips were found sys.exit(2) else: -- cgit v0.12 From c90a47623fefb3787b737c014df7392fe325795b Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 1 Nov 2021 12:05:34 -0700 Subject: fix --no-ignore-skips --- runtest.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/runtest.py b/runtest.py index 79dce48..741b256 100755 --- a/runtest.py +++ b/runtest.py @@ -110,9 +110,9 @@ parser.add_argument('--no-faillog', dest='error_log', default='failed_tests.log', help="Do not log failed tests to a file") -parser.add_argument('--no-ignore-skips', dest='ignore_skips', - action='store_false', - default=True, +parser.add_argument('--no-ignore-skips', dest='dont_ignore_skips', + action='store_true', + default=False, help="If any tests are skipped, exit status 2") outctl = parser.add_argument_group(description='Output control options:') @@ -858,9 +858,10 @@ if args.output: if isinstance(sys.stderr, Tee): sys.stderr.file.close() +import pdb; pdb.set_trace() if fail: sys.exit(1) -elif no_result and args.ignore_skips: +elif no_result and args.dont_ignore_skips: # if no fails, but skips were found sys.exit(2) else: -- cgit v0.12 From a2a6c9c333b245530b3ec34c7c8d88fca8d700c4 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 1 Nov 2021 12:10:30 -0700 Subject: fix --no-ignore-skips --- runtest.py | 1 - 1 file changed, 1 deletion(-) diff --git a/runtest.py b/runtest.py index 741b256..1d93b0c 100755 --- a/runtest.py +++ b/runtest.py @@ -858,7 +858,6 @@ if args.output: if isinstance(sys.stderr, Tee): sys.stderr.file.close() -import pdb; pdb.set_trace() if fail: sys.exit(1) elif no_result and args.dont_ignore_skips: -- cgit v0.12 From 5c0d91c3a38effd1ce4305e71168ea9e924437cb Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 1 Nov 2021 12:28:12 -0700 Subject: fixed tests to test --no-ignore-skips, and updated their copyright text --- test/runtest/baseline/no_result.py | 8 +++++++- test/runtest/simple/no_result.py | 15 ++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/test/runtest/baseline/no_result.py b/test/runtest/baseline/no_result.py index b63d0c6..d00f536 100644 --- a/test/runtest/baseline/no_result.py +++ b/test/runtest/baseline/no_result.py @@ -48,11 +48,17 @@ expect_stderr = """\ NO RESULT TEST STDERR """ -test.run(arguments='-k -b . test/no_result.py', +test.run(arguments='--no-ignore-skips -k -b . test/no_result.py', status=2, stdout=expect_stdout, stderr=expect_stderr) +test.run(arguments='-k -b . test/no_result.py', + status=0, + stdout=expect_stdout, + stderr=expect_stderr) + + test.pass_test() # Local Variables: diff --git a/test/runtest/simple/no_result.py b/test/runtest/simple/no_result.py index 2fd40b4..33f28e4 100644 --- a/test/runtest/simple/no_result.py +++ b/test/runtest/simple/no_result.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,9 +22,6 @@ # 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 how we handle a no-results test specified on the command line. @@ -48,11 +47,17 @@ expect_stderr = """\ NO RESULT TEST STDERR """ -test.run(arguments='-k test/no_result.py', +test.run(arguments='--no-ignore-skips -k test/no_result.py', status=2, stdout=expect_stdout, stderr=expect_stderr) +test.run(arguments='-k test/no_result.py', + status=0, + stdout=expect_stdout, + stderr=expect_stderr) + + test.pass_test() # Local Variables: -- cgit v0.12