added release.txt blurb. Fixed spelling typo in Defaults.xml
[scons.git] / test / Java / DerivedSourceTest.py
blobadf9d50186d12ff09ec66d1a786c5c9c270813d7
1 #!/usr/bin/env python
3 # MIT License
5 # Copyright The SCons Foundation
7 # Permission is hereby granted, free of charge, to any person obtaining
8 # a copy of this software and associated documentation files (the
9 # "Software"), to deal in the Software without restriction, including
10 # without limitation the rights to use, copy, modify, merge, publish,
11 # distribute, sublicense, and/or sell copies of the Software, and to
12 # permit persons to whom the Software is furnished to do so, subject to
13 # the following conditions:
15 # The above copyright notice and this permission notice shall be included
16 # in all copies or substantial portions of the Software.
18 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
19 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
20 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 """
27 Test of javac.py when building java code from derived sources.
29 Original issue definition:
30 Java emitter for derived sources outputs bogus class files.
32 Repeatable with any N-tier, with N > 1, Java derived-source builds where
33 any of the following conditions are meet:
34 1. The java class does not belong to the root package.
35 2. A java source (*.java) creates N targets (*.class) where N > 1.
36 """
38 import os
39 import TestSCons
40 import SCons.Node.FS
41 import SCons.Defaults
43 SCons.Defaults.DefaultEnvironment(tools = [])
45 test = TestSCons.TestSCons()
47 # This test is known to fail as of July 2014; see Tigris issue 1771 and issue 2931.
48 # Once the underlying issue is corrected, this test should be re-enabled.
49 test.skip_test('Skipping derived-source test until issue 1771 is fixed.\n')
51 # No result if tools not available
52 test.no_result( condition=(test.where_is( 'javac' ) is None) )
53 test.no_result( condition=(test.where_is( 'jar' ) is None) )
55 test.write(
56 ['Sample.java'],
57 """
58 // Condition 1: class does not exist in the root package.
59 package org.sample;
61 public class Sample {
62 // Condition 2: inner class definition causes javac to create
63 // a second class file.
64 enum InnerEnum {
65 stuff,
66 and,
67 things
70 """
73 test.write(
74 ['SConstruct'],
75 """
76 import os
78 DefaultEnvironment(tools=[])
79 env = Environment(
80 tools = [
81 'javac',
82 'jar',
86 env.Command(
87 os.path.join( 'org', 'sample', 'Sample.java' ),
88 'Sample.java',
89 Copy(
90 '$TARGET',
91 '$SOURCE'
95 # Copy operation makes the *.java file(s) under org derived-source.
96 env.Java(
97 'build',
98 'org'
103 expected = test.wrap_stdout(
104 build_str =
105 '''\
106 Copy("org/sample/Sample.java", "Sample.java")
107 javac -d build -sourcepath org/sample org/sample/Sample.java
109 +-build
110 | +-build/org
111 | +-build/org/sample
112 | +-build/org/sample/Sample$InnerEnum.class
113 | +-org/sample/Sample.java
114 | +-build/org/sample/Sample.class
115 | +-org/sample/Sample.java
116 +-org
117 +-org/sample
118 +-org/sample/Sample.java
119 '''.replace( '/', os.sep )
122 test.run( arguments = '--tree=derived', stdout = expected )
123 test.up_to_date(arguments = '.')
125 test.pass_test()
127 # Local Variables:
128 # tab-width:4
129 # indent-tabs-mode:nil
130 # End:
131 # vim: set expandtab tabstop=4 shiftwidth=4: