Issue 2168: Mac OS X fixes for SWIG tests. (Greg Noel)
[scons.git] / test / SConsignFile.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 import TestSCons
28 import os.path
29
30 _python_ = TestSCons._python_
31
32 test = TestSCons.TestSCons()
33
34 test.subdir('work1', ['work1', 'subdir'])
35 test.subdir('work2', ['work2', 'subdir'])
36
37 test.write('build.py', r"""
38 import sys
39 contents = open(sys.argv[2], 'rb').read()
40 file = open(sys.argv[1], 'wb')
41 file.write(contents)
42 file.close()
43 """)
44
45 #
46 test.write(['work1', 'SConstruct'], """
47 SConsignFile()
48 B = Builder(action = '%(_python_)s ../build.py $TARGETS $SOURCES')
49 env = Environment(BUILDERS = { 'B' : B })
50 env.B(target = 'f1.out', source = 'f1.in')
51 env.B(target = 'f2.out', source = 'f2.in')
52 env.B(target = 'subdir/f3.out', source = 'subdir/f3.in')
53 env.B(target = 'subdir/f4.out', source = 'subdir/f4.in')
54 """ % locals())
55
56 test.write(['work1', 'f1.in'], "work1/f1.in\n")
57 test.write(['work1', 'f2.in'], "work1/f2.in\n")
58 test.write(['work1', 'subdir', 'f3.in'], "work1/subdir/f3.in\n")
59 test.write(['work1', 'subdir', 'f4.in'], "work1/subdir/f4.in\n")
60
61 test.run(chdir = 'work1')
62
63 test.must_exist(test.workpath('work1', '.sconsign.dblite'))
64 test.must_not_exist(test.workpath('work1', '.sconsign'))
65 test.must_not_exist(test.workpath('work1', 'subdir', '.sconsign'))
66   
67 test.must_match(['work1', 'f1.out'], "work1/f1.in\n")
68 test.must_match(['work1', 'f2.out'], "work1/f2.in\n")
69 test.must_match(['work1', 'subdir', 'f3.out'], "work1/subdir/f3.in\n")
70 test.must_match(['work1', 'subdir', 'f4.out'], "work1/subdir/f4.in\n")
71
72 test.up_to_date(chdir = 'work1', arguments = '.')
73
74 test.must_exist(test.workpath('work1', '.sconsign.dblite'))
75 test.must_not_exist(test.workpath('work1', '.sconsign'))
76 test.must_not_exist(test.workpath('work1', 'subdir', '.sconsign'))
77
78 #
79 test.write(['work2', 'SConstruct'], """
80 e = Environment(XXX = 'scons')
81 e.SConsignFile('my_${XXX}ign')
82 B = Builder(action = '%(_python_)s ../build.py $TARGETS $SOURCES')
83 env = Environment(BUILDERS = { 'B' : B })
84 env.B(target = 'f5.out', source = 'f5.in')
85 env.B(target = 'f6.out', source = 'f6.in')
86 env.B(target = 'subdir/f7.out', source = 'subdir/f7.in')
87 env.B(target = 'subdir/f8.out', source = 'subdir/f8.in')
88 """ % locals())
89
90 test.write(['work2', 'f5.in'], "work2/f5.in\n")
91 test.write(['work2', 'f6.in'], "work2/f6.in\n")
92 test.write(['work2', 'subdir', 'f7.in'], "work2/subdir/f7.in\n")
93 test.write(['work2', 'subdir', 'f8.in'], "work2/subdir/f8.in\n")
94
95 test.run(chdir = 'work2')
96
97 test.must_exist(test.workpath('work2', 'my_sconsign.dblite'))
98 test.must_not_exist(test.workpath('work2', '.sconsign'))
99 test.must_not_exist(test.workpath('work2', 'subdir', '.sconsign'))
100
101 test.must_match(['work2', 'f5.out'], "work2/f5.in\n")
102 test.must_match(['work2', 'f6.out'], "work2/f6.in\n")
103 test.must_match(['work2', 'subdir', 'f7.out'], "work2/subdir/f7.in\n")
104 test.must_match(['work2', 'subdir', 'f8.out'], "work2/subdir/f8.in\n")
105
106 test.up_to_date(chdir = 'work2', arguments = '.')
107
108 test.must_exist(test.workpath('work2', 'my_sconsign.dblite'))
109 test.must_not_exist(test.workpath('work2', '.sconsign'))
110 test.must_not_exist(test.workpath('work2', 'subdir', '.sconsign'))
111
112 test.pass_test()