Added fix for TeX includes with same name as subdirs.
[scons.git] / test / Java / no-JARCHDIR.py
1 #!/usr/bin/env python
2 #
3 # __COPYRIGHT__
4 #
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:
12 #
13 # The above copyright notice and this permission notice shall be included
14 # in all copies or substantial portions of the Software.
15 #
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.
23 #
24
25 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
26
27 """
28 Verify the Jar() behavior when we have no JARCHDIR set (it should
29 automatically use the classdir that was deduced from the Java() call)
30 and when we explicity set it to None (it should not use the Java()
31 classdir attribute at all).
32 """
33
34 import TestSCons
35
36 test = TestSCons.TestSCons()
37
38 where_javac, java_version = test.java_where_javac()
39 where_jar = test.java_where_jar()
40
41 test.subdir('src')
42
43
44
45 test.write(['src', 'a.java'], """\
46 package foo.bar;
47 public class a {}
48 """)
49
50 test.write(['src', 'b.java'], """\
51 package foo.bar;
52 public class b {}
53 """)
54
55
56
57 test.write('SConstruct', """\
58 env = Environment(tools    = ['javac', 'jar'],
59                   JAVAC = r'%(where_javac)s',
60                   JAR = r'%(where_jar)s')
61
62 jar = env.Jar('x.jar', env.Java(target = 'classes', source = 'src'))
63 """ % locals())
64
65 test.run(arguments = '.')
66
67
68
69 test.run(program = where_jar, arguments = 'tf x.jar')
70
71 expect = """\
72 foo/bar/a.class
73 foo/bar/b.class
74 """
75
76 test.must_contain_all_lines(test.stdout(), [expect])
77
78
79
80 test.run(arguments = '-c')
81
82
83
84 test.write('SConstruct', """\
85 env = Environment(tools    = ['javac', 'jar'],
86                   JAVAC = r'%(where_javac)s',
87                   JAR = r'%(where_jar)s',
88                   JARCHDIR = None)
89
90 jar = env.Jar('x.jar', env.Java(target = 'classes', source = 'src'))
91 """ % locals())
92
93 test.run(arguments = '.')
94
95
96
97 test.run(program = where_jar, arguments = 'tf x.jar')
98
99 expect = """\
100 classes/foo/bar/a.class
101 classes/foo/bar/b.class
102 """
103
104 test.must_contain_all_lines(test.stdout(), [expect])
105
106
107
108 test.pass_test()
109
110 # Local Variables:
111 # tab-width:4
112 # indent-tabs-mode:nil
113 # End:
114 # vim: set expandtab tabstop=4 shiftwidth=4: