diff options
Diffstat (limited to 'test/Java')
-rw-r--r-- | test/Java/JAVABOOTCLASSPATH.py | 108 | ||||
-rw-r--r-- | test/Java/multi-step.py | 22 | ||||
-rw-r--r-- | test/Java/swig-dependencies.py | 19 |
3 files changed, 143 insertions, 6 deletions
diff --git a/test/Java/JAVABOOTCLASSPATH.py b/test/Java/JAVABOOTCLASSPATH.py new file mode 100644 index 0000000..7723224 --- /dev/null +++ b/test/Java/JAVABOOTCLASSPATH.py @@ -0,0 +1,108 @@ +#!/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__" + +""" +Verify that use of $JAVABOOTCLASSPATH sets the -bootclasspath option +on javac compilations. +""" + +import os +import string + +import TestSCons + +_python_ = TestSCons._python_ + +test = TestSCons.TestSCons() + +ENV = test.java_ENV() + +if test.detect_tool('javac', ENV=ENV): + where_javac = test.detect('JAVAC', 'javac', ENV=ENV) +else: + where_javac = test.where_is('javac') +if not where_javac: + test.skip_test("Could not find Java javac, skipping test(s).\n") + +if test.detect_tool('javah', ENV=ENV): + where_javah = test.detect('JAVAH', 'javah', ENV=ENV) +else: + where_javah = test.where_is('javah') +if not where_javah: + test.skip_test("Could not find Java javah, skipping test(s).\n") + +test.write('SConstruct', """ +env = Environment(tools = ['javac', 'javah'], + JAVAC = r'%(where_javac)s', + JAVABOOTCLASSPATH = ['dir1', 'dir2']) +j1 = env.Java(target = 'class', source = 'com/Example1.java') +j2 = env.Java(target = 'class', source = 'com/Example2.java') +""" % locals()) + +test.subdir('com') + +test.write(['com', 'Example1.java'], """\ +package com; + +public class Example1 +{ + + public static void main(String[] args) + { + + } + +} +""") + +test.write(['com', 'Example2.java'], """\ +package com; + +public class Example2 +{ + + public static void main(String[] args) + { + + } + +} +""") + +# Setting -bootclasspath messes with the Java runtime environment, so +# we'll just take the easy way out and examine the -n output to see if +# the expected option shows up on the command line. + +bootclasspath = string.join(['dir1', 'dir2'], os.pathsep) + +expect = """\ +%(where_javac)s -bootclasspath %(bootclasspath)s -d class -sourcepath com com/Example1.java +%(where_javac)s -bootclasspath %(bootclasspath)s -d class -sourcepath com com/Example2.java +""" % locals() + +test.run(arguments = '-Q -n .', stdout = expect) + +test.pass_test() diff --git a/test/Java/multi-step.py b/test/Java/multi-step.py index 1b69838..d185b4d 100644 --- a/test/Java/multi-step.py +++ b/test/Java/multi-step.py @@ -43,6 +43,13 @@ else: if not where_javac: test.skip_test("Could not find Java javac, skipping test(s).\n") +if test.detect_tool('javah', ENV=ENV): + where_javah = test.detect('JAVAH', 'javah', ENV=ENV) +else: + where_javah = test.where_is('javah') +if not where_javah: + test.skip_test("Could not find Java javah, skipping test(s).\n") + swig = test.where_is('swig') if not swig: test.skip_test('Can not find installed "swig", skipping test.\n') @@ -70,7 +77,9 @@ test.subdir(['src'], test.write(['SConstruct'], """\ import os,sys -env=Environment(tools = ['default', 'javac', 'javah']) +env=Environment(tools = ['default', 'javac', 'javah'], + JAVAC = r'%(where_javac)s', + JAVAH = r'%(where_javah)s') Export('env') env.PrependENVPath('PATH',os.environ.get('PATH',[])) env['INCPREFIX']='-I' @@ -94,7 +103,7 @@ env.SConscript(['buildout/server/JavaSource/SConscript', 'buildout/HelloApplet/SConscript', 'buildout/jni/SConscript', 'buildout/javah/SConscript']) -""") +""" % locals()) test.write(['src', 'HelloApplet', 'Hello.html'], """\ <HTML> @@ -559,9 +568,16 @@ test.must_exist(['buildout', 'jni', 'Sample.class']) test.must_exist(['buildout', 'jni', 'Sample.java']) test.must_exist(['buildout', 'jni', 'SampleJNI.class']) test.must_exist(['buildout', 'jni', 'SampleJNI.java']) -test.must_exist(['buildout', 'jni', 'SampleTest.class']) test.must_exist(['buildout', 'jni', 'SampleTest.java']) +# Some combinations of Java + SWIG apparently don't actually generate +# a SampleTest.class file, while others do. Only issue a warning if +# it doesn't exist. +p = test.workpath('buildout', 'jni', 'SampleTest.class') +import os.path +if not os.path.exists(p): + print 'Warning: %s does not exist' % p + test.up_to_date(arguments = '.') test.pass_test() diff --git a/test/Java/swig-dependencies.py b/test/Java/swig-dependencies.py index c6961f2..8df5e09 100644 --- a/test/Java/swig-dependencies.py +++ b/test/Java/swig-dependencies.py @@ -35,6 +35,7 @@ import TestSCons test = TestSCons.TestSCons() ENV = test.java_ENV() + if test.detect_tool('javac', ENV=ENV): where_javac = test.detect('JAVAC', 'javac', ENV=ENV) else: @@ -42,6 +43,13 @@ else: if not where_javac: test.skip_test("Could not find Java javac, skipping test(s).\n") +if test.detect_tool('javah', ENV=ENV): + where_javah = test.detect('JAVAH', 'javah', ENV=ENV) +else: + where_javah = test.where_is('javah') +if not where_javah: + test.skip_test("Could not find Java javah, skipping test(s).\n") + if test.detect_tool('jar', ENV=ENV): where_jar = test.detect('JAR', 'jar', ENV=ENV) else: @@ -57,7 +65,9 @@ test.subdir(['foo'], test.write(['SConstruct'], """\ import os -env = Environment(ENV = os.environ) +env = Environment(ENV = os.environ, + JAVAC = r'%(where_javac)s', + JAVAH = r'%(where_javah)s') env.Append(CPPFLAGS = ' -g -Wall') @@ -65,7 +75,7 @@ Export('env') SConscript('#foo/SConscript') SConscript('#java/SConscript') -""") +""" % locals()) test.write(['foo', 'SConscript'], """\ Import('env') @@ -123,7 +133,10 @@ env['JARCHDIR'] = 'java/classes' foopack_jar = env.Jar(target = 'foopack.jar', source = 'classes') """) -test.run(arguments = '.') +# Disable looking at stderr because some combinations of SWIG/gcc +# generate a warning about the sWIG_JavaThrowException() function +# being defined but not used. +test.run(arguments = '.', stderr=None) #test.must_exist(['java', 'classes', 'foopack', 'foopack.class']) #test.must_exist(['java', 'classes', 'foopack', 'foopackJNI.class']) |