added release.txt blurb. Fixed spelling typo in Defaults.xml
[scons.git] / test / ExecuteInvalidateCache.py
blobf6ed391bf05fe938f5390a65c195b0069632faf0
1 #!/usr/bin/env python
3 # __COPYRIGHT__
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__"
27 """
28 Test the Execute() functions clears the memoized values of affected target Nodes
29 when used with Delete(). Derived from
30 https://github.com/SCons/scons/issues/1307
31 """
33 import TestSCons
34 import os.path
36 test = TestSCons.TestSCons()
38 subfn = os.path.join('sub', 'foo')
40 test.write('SConstruct', """\
41 def exists(node):
42 if node.exists():
43 print(str(node)+" exists")
44 else:
45 print(str(node)+" does not exist")
47 Execute(Delete('abc'))
48 n1 = File('abc')
49 exists( n1 )
50 Execute(Touch('abc'))
51 exists( n1 )
52 Execute(Delete('abc'))
53 exists( n1 )
55 env = Environment()
56 env.Execute(Delete('def'))
57 n2 = env.File('def')
58 exists( n2 )
59 env.Execute(Touch('def'))
60 exists( n2 )
61 env.Execute(Delete(n2))
62 exists( n2 )
64 Execute(Touch('abc'))
65 exists( n1 )
66 Execute(Move('def', 'abc'))
67 exists( n1 )
68 exists( n2 )
70 Execute(Copy('abc', 'def'))
71 exists( n1 )
73 n3 = File(r"%(subfn)s")
74 exists( n3 )
75 Execute(Mkdir('sub'))
76 Execute(Touch(r"%(subfn)s"))
77 exists( n3 )
78 """ % locals())
81 expect = test.wrap_stdout(read_str="""\
82 Delete("abc")
83 abc does not exist
84 Touch("abc")
85 abc exists
86 Delete("abc")
87 abc does not exist
88 Delete("def")
89 def does not exist
90 Touch("def")
91 def exists
92 Delete("def")
93 def does not exist
94 Touch("abc")
95 abc exists
96 Move("def", "abc")
97 abc does not exist
98 def exists
99 Copy("abc", "def")
100 abc exists
101 %(subfn)s does not exist
102 Mkdir("sub")
103 Touch("%(subfn)s")
104 %(subfn)s exists
105 """ % locals(), build_str = "scons: `.' is up to date.\n")
107 test.run(arguments = '.', stdout = expect)
109 test.pass_test()
111 # Local Variables:
112 # tab-width:4
113 # indent-tabs-mode:nil
114 # End:
115 # vim: set expandtab tabstop=4 shiftwidth=4: