Updated tigris page for 0.97.0d20070918 checkpoint release.
[scons.git] / test / changed-node.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 that we don't throw an exception if a stored implicit
29 dependency has changed
30 """
31
32 import TestSCons
33
34 test = TestSCons.TestSCons()
35
36
37
38 test.subdir('d',
39             ['d', '1'],
40             ['d', '2'],
41             ['d', '3'])
42
43 test.write('SConstruct', """\
44 SetOption('implicit_cache', 1)
45 SetOption('max_drift', 1)
46 SourceCode('.', None)
47
48 def lister(target, source, env):
49     import os
50     fp = open(str(target[0]), 'w')
51     s = str(source[0])
52     if os.path.isdir(s):
53         for l in os.listdir(str(source[0])):
54             fp.write(l + '\\n')
55     else:
56         fp.write(s + '\\n')
57     fp.close()
58
59 builder = Builder(action=lister,
60                   source_factory=Dir,
61                   source_scanner=DirScanner)
62 env = Environment(tools=[])
63 env['BUILDERS']['builder'] = builder
64 env.builder('d/xfactor', 'd/1')
65 env.builder('a', 'd')
66 """)
67
68 test.write(['d', '1', 'x'], "d/1/x\n")
69 test.write(['d', '1', 'y'], "d/1/y\n")
70 test.write(['d', '1', 'z'], "d/1/z\n")
71 test.write(['d', '2', 'x'], "d/2/x\n")
72 test.write(['d', '2', 'y'], "d/2/y\n")
73 test.write(['d', '2', 'z'], "d/2/x\n")
74 test.write(['d', '3', 'x'], "d/3/x\n")
75 test.write(['d', '3', 'y'], "d/3/y\n")
76 test.write(['d', '3', 'z'], "d/3/z\n")
77
78 test.run('--debug=stacktrace')
79
80
81
82 test.write('SConstruct', """\
83 SetOption('implicit_cache', 1)
84 SetOption('max_drift', 1)
85 SourceCode('.', None)
86
87 def lister(target, source, env):
88     import os.path
89     fp = open(str(target[0]), 'w')
90     s = str(source[0])
91     if os.path.isdir(s):
92         for l in os.listdir(str(source[0])):
93             fp.write(l + '\\n')
94     else:
95         fp.write(s + '\\n')
96     fp.close()
97
98 builder = Builder(action=lister,
99                   source_factory=File)
100 env = Environment(tools=[])
101 env['BUILDERS']['builder'] = builder
102
103 env.builder('a', 'SConstruct')
104 """)
105
106 test.run('--debug=stacktrace')
107
108 test.pass_test()
109
110
111
112
113 #from os import system, rmdir, remove, mkdir, listdir
114 #from os.path import exists, isdir
115 #import sys
116 #
117 #
118 #def setfile(f, content):
119 #    f = open(f, 'w')
120 #    try: f.write(content)
121 #    finally: f.close()
122 #
123 #def checkfile(f, content):
124 #    assert open(f).read().strip() == content
125 #
126 #def rm(f):
127 #    if exists(f):
128 #        if isdir(f):
129 #            for name in listdir(f):
130 #                rm(f+'/'+name)
131 #            rmdir(f)
132 #        else: remove(f)
133 #def clean(full=0):
134 #    for f in ('d','b','a','SConstruct'):
135 #        rm(f)
136 #    if full:
137 #        for f in ('.sconsign.dblite', 'build.py'):
138 #            rm(f)
139 #
140 #clean(1)
141 #
142 #clean(1)