5 # Permission is hereby granted, free of charge, to any person obtaining
6 # a copy of this software and associated documentation files (the
7 # "Software"), to deal in the Software without restriction, including
8 # without limitation the rights to use, copy, modify, merge, publish,
9 # distribute, sublicense, and/or sell copies of the Software, and to
10 # permit persons to whom the Software is furnished to do so, subject to
11 # the following conditions:
13 # The above copyright notice and this permission notice shall be included
14 # in all copies or substantial portions of the Software.
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
17 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
18 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
28 Test building Java applications when using Repositories.
36 python = TestSCons.python
38 test = TestSCons.TestSCons()
40 java = '/usr/local/j2sdk1.3.1/bin/java'
41 javac = '/usr/local/j2sdk1.3.1/bin/javac'
43 if not os.path.exists(javac):
44 print "Could not find Java, skipping test(s)."
47 ###############################################################################
50 test.subdir('rep1', ['rep1', 'src'],
55 rep1_classes = test.workpath('rep1', 'classes')
56 work1_classes = test.workpath('work1', 'classes')
59 opts = '-Y ' + test.workpath('rep1')
62 test.write(['rep1', 'SConstruct'], """
63 env = Environment(tools = ['javac'],
65 env.Java(target = 'classes', source = 'src')
68 test.write(['rep1', 'src', 'Foo1.java'], """\
71 public static void main(String[] args)
73 System.out.println("rep1/src/Foo1.java");
79 test.write(['rep1', 'src', 'Foo2.java'], """\
82 public static void main(String[] args)
84 System.out.println("rep1/src/Foo2.java");
90 test.write(['rep1', 'src', 'Foo3.java'], """\
93 public static void main(String[] args)
95 System.out.println("rep1/src/Foo3.java");
101 # Make the repository non-writable,
102 # so we'll detect if we try to write into it accidentally.
103 test.writable('repository', 0)
106 test.run(chdir = 'work1', options = opts, arguments = ".")
108 test.run(program = java,
109 arguments = "-cp %s Foo1" % work1_classes,
110 stdout = "rep1/src/Foo1.java\n")
112 test.run(program = java,
113 arguments = "-cp %s Foo2" % work1_classes,
114 stdout = "rep1/src/Foo2.java\n")
116 test.run(program = java,
117 arguments = "-cp %s Foo3" % work1_classes,
118 stdout = "rep1/src/Foo3.java\n")
120 test.up_to_date(chdir = 'work1', options = opts, arguments = ".")
123 test.subdir(['work1', 'src'])
125 test.write(['work1', 'src', 'Foo1.java'], """\
128 public static void main(String[] args)
130 System.out.println("work1/src/Foo1.java");
136 test.write(['work1', 'src', 'Foo2.java'], """\
139 public static void main(String[] args)
141 System.out.println("work1/src/Foo2.java");
147 test.write(['work1', 'src', 'Foo3.java'], """\
150 public static void main(String[] args)
152 System.out.println("work1/src/Foo3.java");
158 test.run(chdir = 'work1', options = opts, arguments = ".")
160 test.run(program = java,
161 arguments = "-cp %s Foo1" % work1_classes,
162 stdout = "work1/src/Foo1.java\n")
164 test.run(program = java,
165 arguments = "-cp %s Foo2" % work1_classes,
166 stdout = "work1/src/Foo2.java\n")
168 test.run(program = java,
169 arguments = "-cp %s Foo3" % work1_classes,
170 stdout = "work1/src/Foo3.java\n")
172 test.up_to_date(chdir = 'work1', options = opts, arguments = ".")
175 test.writable('rep1', 1)
177 test.run(chdir = 'rep1', options = opts, arguments = ".")
179 test.run(program = java,
180 arguments = "-cp %s Foo1" % rep1_classes,
181 stdout = "rep1/src/Foo1.java\n")
183 test.run(program = java,
184 arguments = "-cp %s Foo2" % rep1_classes,
185 stdout = "rep1/src/Foo2.java\n")
187 test.run(program = java,
188 arguments = "-cp %s Foo3" % rep1_classes,
189 stdout = "rep1/src/Foo3.java\n")
191 test.up_to_date(chdir = 'rep1', options = opts, arguments = ".")
194 test.writable('repository', 0)
197 # If the Java builder were to interact with Repositories like the
198 # other builders, then we'd uncomment the following test(s).
200 # This tests that, if the .class files are built in the repository,
201 # then a local build says that everything is up-to-date. However,
202 # because the destination target is a directory ("classes") not a
203 # file, we don't detect that the individual .class files are
204 # already there, and think things must be rebuilt.
206 #test.up_to_date(chdir = 'work2', options = opts, arguments = ".")
208 #test.subdir(['work2', 'src'])
210 #test.write(['work2', 'src', 'Foo1.java'], """\
213 # public static void main(String[] args)
215 # System.out.println("work2/src/Foo1.java");
221 #test.write(['work2', 'src', 'Foo2.java'], """\
224 # public static void main(String[] args)
226 # System.out.println("work2/src/Foo2.java");
232 #test.write(['work2', 'src', 'Foo3.java'], """\
235 # public static void main(String[] args)
237 # System.out.println("work2/src/Foo3.java");
243 #test.run(chdir = 'work2', options = opts, arguments = ".")
245 #test.run(program = java,
246 # arguments = "-cp %s Foo1" % work2_classes,
247 # stdout = "work2/src/Foo1.java\n")
249 #test.run(program = java,
250 # arguments = "-cp %s Foo2" % work2_classes,
251 # stdout = "work2/src/Foo2.java\n")
253 #test.run(program = java,
254 # arguments = "-cp %s Foo3" % work2_classes,
255 # stdout = "work2/src/Foo3.java\n")
257 #test.up_to_date(chdir = 'work2', options = opts, arguments = ".")