From 6ddc06eafa74e448a870dbb65461405709bef1ba Mon Sep 17 00:00:00 2001 From: William Blevins Date: Sat, 12 Jul 2014 13:14:28 -0400 Subject: Added a high-level test for issue 1771/2931. Shows that Java emitter for derived-sources is broken regardless of the source generation method. --- test/Java/DerivedSourceTest.py | 97 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 test/Java/DerivedSourceTest.py diff --git a/test/Java/DerivedSourceTest.py b/test/Java/DerivedSourceTest.py new file mode 100644 index 0000000..b700e1e --- /dev/null +++ b/test/Java/DerivedSourceTest.py @@ -0,0 +1,97 @@ +#!/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. + +@author William Blevins +@version 2 March 2014 +""" + +import os +import TestSCons +import SCons.Node.FS + +test = TestSCons.TestSCons() + +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' +) +""" +) + +test.run( arguments = '.' ) + +test.up_to_date(arguments = '.') -- cgit v0.12 From 3030945eeb2121acbccab9db8fdf72926bf90510 Mon Sep 17 00:00:00 2001 From: William Blevins Date: Sun, 13 Jul 2014 13:23:51 -0400 Subject: Set default toolchain. Other updates per code review. --- test/Java/DerivedSourceTest.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/Java/DerivedSourceTest.py b/test/Java/DerivedSourceTest.py index b700e1e..7478a1e 100644 --- a/test/Java/DerivedSourceTest.py +++ b/test/Java/DerivedSourceTest.py @@ -34,14 +34,14 @@ 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. - -@author William Blevins -@version 2 March 2014 """ import os import TestSCons import SCons.Node.FS +import SCons.Defaults + +SCons.Defaults.DefaultEnvironment(tools = []) test = TestSCons.TestSCons() -- cgit v0.12 From 01e5931750f54b3ed0e7d18e05f868d81c8ebed6 Mon Sep 17 00:00:00 2001 From: William Blevins Date: Tue, 15 Jul 2014 22:02:56 -0400 Subject: Updated DerivedSourceTest.py to test against a dependency tree. This was a best guess for the output. --- test/Java/DerivedSourceTest.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/test/Java/DerivedSourceTest.py b/test/Java/DerivedSourceTest.py index 7478a1e..5cf4af7 100644 --- a/test/Java/DerivedSourceTest.py +++ b/test/Java/DerivedSourceTest.py @@ -92,6 +92,25 @@ env.Java( """ ) -test.run( arguments = '.' ) +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 = '.') -- cgit v0.12 From 40b656483bc892ef47ff4751aef1e43c4449042d Mon Sep 17 00:00:00 2001 From: William Blevins Date: Tue, 15 Jul 2014 22:21:03 -0400 Subject: Added Issue 1771 test to CHANGES.TXT --- src/CHANGES.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index f20fd32..8ff593d 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -6,6 +6,8 @@ RELEASE 2.3.2.alpha.yyyymmdd - NEW DATE WILL BE INSERTED HERE + From William Blevins: + - Added test for Java derived-source dependency tree generation. RELEASE 2.3.2 -- cgit v0.12 From c8baceb1525e31f4411249908a8e5c916f2f8a13 Mon Sep 17 00:00:00 2001 From: William Blevins Date: Fri, 18 Jul 2014 01:33:06 -0400 Subject: Issue 1771/2931: Added no_result check for tools to validate initial test conditions. --- test/Java/DerivedSourceTest.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/Java/DerivedSourceTest.py b/test/Java/DerivedSourceTest.py index 5cf4af7..f5ba95c 100644 --- a/test/Java/DerivedSourceTest.py +++ b/test/Java/DerivedSourceTest.py @@ -45,6 +45,10 @@ 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'], """ -- cgit v0.12