summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorGary Oberbrunner <garyo@oberbrunner.com>2014-07-20 19:24:12 (GMT)
committerGary Oberbrunner <garyo@oberbrunner.com>2014-07-20 19:24:12 (GMT)
commit533f32d665f5bb3bffc19a503da2384fdb455ad6 (patch)
tree7270b1acfd095412de296e58b8341f55d92b6fe3 /test
parent2e28a4db2dcc711d8cd47784a91fc70d15c96a9f (diff)
parentc8baceb1525e31f4411249908a8e5c916f2f8a13 (diff)
downloadSCons-533f32d665f5bb3bffc19a503da2384fdb455ad6.zip
SCons-533f32d665f5bb3bffc19a503da2384fdb455ad6.tar.gz
SCons-533f32d665f5bb3bffc19a503da2384fdb455ad6.tar.bz2
Merging in pull request #152 from William Blevins (Java test)
Diffstat (limited to 'test')
-rw-r--r--test/Java/DerivedSourceTest.py120
1 files changed, 120 insertions, 0 deletions
diff --git a/test/Java/DerivedSourceTest.py b/test/Java/DerivedSourceTest.py
new file mode 100644
index 0000000..b4715a5
--- /dev/null
+++ b/test/Java/DerivedSourceTest.py
@@ -0,0 +1,120 @@
+#!/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 of javac.py when building java code from derived sources.
+
+Original issue definition:
+Java emitter for derived sources outputs bogus class files.
+
+Repeatable with any N-tier, with N > 1, Java derived-source builds where
+any of the following conditions are meet:
+1. The java class does not belong to the root package.
+2. A java source (*.java) creates N targets (*.class) where N > 1.
+"""
+
+import os
+import TestSCons
+import SCons.Node.FS
+import SCons.Defaults
+
+SCons.Defaults.DefaultEnvironment(tools = [])
+
+test = TestSCons.TestSCons()
+
+# No result if tools not available
+test.no_result( condition=(test.where_is( 'javac' ) is None) )
+test.no_result( condition=(test.where_is( 'jar' ) is None) )
+
+test.write(
+ ['Sample.java'],
+"""
+// Condition 1: class does not exist in the root package.
+package org.sample;
+
+public class Sample {
+ // Condition 2: inner class definition causes javac to create
+ // a second class file.
+ enum InnerEnum {
+ stuff,
+ and,
+ things
+ }
+}
+"""
+)
+
+test.write(
+ ['SConstruct'],
+"""
+import os
+
+env = Environment(
+ tools = [
+ 'javac',
+ 'jar',
+ ]
+)
+
+env.Command(
+ os.path.join( 'org', 'sample', 'Sample.java' ),
+ 'Sample.java',
+ Copy(
+ '$TARGET',
+ '$SOURCE'
+ )
+)
+
+# Copy operation makes the *.java file(s) under org derived-source.
+env.Java(
+ 'build',
+ 'org'
+)
+"""
+)
+
+expected = test.wrap_stdout(
+build_str =
+'''\
+Copy("org/sample/Sample.java", "Sample.java")
+javac -d build -sourcepath org/sample org/sample/Sample.java
++-.
+ +-build
+ | +-build/org
+ | +-build/org/sample
+ | +-build/org/sample/Sample$InnerEnum.class
+ | +-org/sample/Sample.java
+ | +-build/org/sample/Sample.class
+ | +-org/sample/Sample.java
+ +-org
+ +-org/sample
+ +-org/sample/Sample.java
+'''.replace( '/', os.sep )
+)
+
+test.run( arguments = '--tree=derived', stdout = expected )
+
+test.up_to_date(arguments = '.')