diff options
author | William Deegan <bill@baddogconsulting.com> | 2021-11-01 20:06:32 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-01 20:06:32 (GMT) |
commit | 1a04e66fdbe9dd5b088c337fa04f66f403dde2ad (patch) | |
tree | 248b1056793aef62a1193691cc389a36ae9a7c7c /test | |
parent | 86e06a8a2cdbd487e685bb51b64979fadbcd5694 (diff) | |
parent | 5c0d91c3a38effd1ce4305e71168ea9e924437cb (diff) | |
download | SCons-1a04e66fdbe9dd5b088c337fa04f66f403dde2ad.zip SCons-1a04e66fdbe9dd5b088c337fa04f66f403dde2ad.tar.gz SCons-1a04e66fdbe9dd5b088c337fa04f66f403dde2ad.tar.bz2 |
Merge pull request #4046 from mwichmann/java-tests
Skip unusable javah tests
Diffstat (limited to 'test')
34 files changed, 412 insertions, 329 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..aff3a90 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 @@ -30,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,11 +40,24 @@ 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 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') -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 c7ac334..8be3196 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,11 +22,9 @@ # 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 pathlib import TestSCons @@ -32,70 +32,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) @@ -105,36 +43,57 @@ 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 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; @@ -280,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/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..ab627cb 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 @@ -24,11 +26,12 @@ """ Real-world test (courtesy Leanid Nazdrynau) of the multi-step capabilities of the various Java Builders. -""" -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +TODO: the whole Applet facility is deprecated, need a new test. +""" import os +import pathlib import TestSCons @@ -50,27 +53,42 @@ 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 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'], + ['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 +96,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 +145,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) - -#To sign applet you have to create keystore before and made a calls like this +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) -#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 +200,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 +245,6 @@ test.write(['src', 'jni', 'JniWrapper.cc'], """\ #include "JniWrapper.h" - - JniWrapper::JniWrapper( JNIEnv *pEnv ) : mpEnv( pEnv ) { @@ -239,7 +257,6 @@ JniWrapper::JniWrapper( const JniWrapper& rJniWrapper ) JniWrapper::~JniWrapper() { - } JniWrapper& JniWrapper::operator=( const JniWrapper& rJniWrapper ) @@ -373,13 +390,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/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') diff --git a/test/Repository/JavaH.py b/test/Repository/JavaH.py index 1cb5078..fea5f5b 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,15 +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 building Java applications when using Repositories. """ import os +import pathlib import TestSCons @@ -40,17 +40,34 @@ 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 +# 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 +79,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 +221,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)) 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: |