Add support for Visual Studio 2005 Professional. Windows portability fixes for vario...
[scons.git] / test / Java / RMICCOMSTR.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 Test that the $RMICCOMSTR construction variable allows you to configure
29 the rmic output.
30 """
31
32 import os.path
33
34 import TestSCons
35
36 python = TestSCons.python
37
38 test = TestSCons.TestSCons()
39
40 test.subdir('src')
41
42
43
44 out_file1 = os.path.join('out', 'file1', 'class_Skel.class')
45 out_file2 = os.path.join('out', 'file2', 'class_Skel.class')
46 out_file3 = os.path.join('out', 'file3', 'class_Skel.class')
47
48
49
50 test.write('myrmic.py', r"""
51 import sys
52 outfile = open(sys.argv[1], 'wb')
53 for f in sys.argv[2:]:
54     infile = open(f, 'rb')
55     for l in filter(lambda l: l != '/*rmic*/\n', infile.readlines()):
56         outfile.write(l)
57 sys.exit(0)
58 """)
59
60 test.write('SConstruct', """
61 env = Environment(TOOLS = ['default', 'rmic'],
62                   RMICCOM = r'%(python)s myrmic.py $TARGET $SOURCES',
63                   RMICCOMSTR = 'Building rmic $TARGET from $SOURCES')
64 env.RMIC(target = 'out', source = 'file1.class')
65 env.RMIC(target = 'out', source = 'file2.class')
66 env.RMIC(target = 'out', source = 'file3.class')
67 """ % locals())
68
69 test.write('file1.class', "file1.class\n/*rmic*/\n")
70 test.write('file2.class', "file2.class\n/*rmic*/\n")
71 test.write('file3.class', "file3.class\n/*rmic*/\n")
72
73 test.run(stdout = test.wrap_stdout("""\
74 Building rmic %(out_file1)s from file1.class
75 Building rmic %(out_file2)s from file2.class
76 Building rmic %(out_file3)s from file3.class
77 """ % locals()))
78
79 test.must_match(out_file1, "file1.class\n")
80 test.must_match(out_file2, "file2.class\n")
81 test.must_match(out_file3, "file3.class\n")
82
83
84
85 test.pass_test()