[ci skip] update generated files
[scons.git] / test / Decider / mixed.py
blob711bd2bce0f14d1710fa363d5b184f16d258d194
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 Verify use of an up-to-date Decider method through a construction
29 environment.
30 """
32 import TestSCons
34 test = TestSCons.TestSCons()
36 test.write('SConstruct', """
37 DefaultEnvironment(tools=[])
38 import os.path
39 denv = Environment(tools=[])
40 env = Environment(tools=[])
41 n1_in = File('n1.in')
42 n2_in = File('n2.in')
43 n3_in = File('n3.in')
44 Command( 'ccc.out', 'ccc.in', Copy('$TARGET', '$SOURCE'))
45 Command( 'n1.out', n1_in, Copy('$TARGET', '$SOURCE'))
46 denv.Command('ddd.out', 'ddd.in', Copy('$TARGET', '$SOURCE'))
47 denv.Command('n2.out', n2_in, Copy('$TARGET', '$SOURCE'))
48 env.Command( 'eee.out', 'eee.in', Copy('$TARGET', '$SOURCE'))
49 env.Command( 'n3.out', n3_in, Copy('$TARGET', '$SOURCE'))
50 def default_decider(dependency, target, prev_ni, repo_node=None):
51 return os.path.exists('default-has-changed')
52 def env_decider(dependency, target, prev_ni, repo_node=None):
53 return os.path.exists('env-has-changed')
54 def node_decider(dependency, target, prev_ni, repo_node=None):
55 return os.path.exists('node-has-changed')
56 Decider(default_decider)
57 env.Decider(env_decider)
58 n1_in.Decider(node_decider)
59 n2_in.Decider(node_decider)
60 n3_in.Decider(node_decider)
61 """)
63 test.write('ccc.in', "ccc.in\n")
64 test.write('ddd.in', "ddd.in\n")
65 test.write('eee.in', "eee.in\n")
66 test.write('n1.in', "n1.in\n")
67 test.write('n2.in', "n2.in\n")
68 test.write('n3.in', "n3.in\n")
72 test.run(arguments = '.')
74 test.up_to_date(arguments = '.')
78 test.write('env-has-changed', "\n")
80 test.not_up_to_date(arguments = 'eee.out')
81 test.up_to_date(arguments = 'ccc.out ddd.out n1.out n2.out n3.out')
83 test.not_up_to_date(arguments = 'eee.out')
84 test.up_to_date(arguments = 'ccc.out ddd.out n1.out n2.out n3.out')
86 test.unlink('env-has-changed')
90 test.write('default-has-changed', "\n")
92 test.not_up_to_date(arguments = 'ccc.out ddd.out')
93 test.up_to_date(arguments = 'eee.out n1.out n2.out n3.out')
95 test.not_up_to_date(arguments = 'ccc.out ddd.out')
96 test.up_to_date(arguments = 'eee.out n1.out n2.out n3.out')
98 test.unlink('default-has-changed')
102 test.up_to_date(arguments = '.')
104 test.write('node-has-changed', "\n")
106 test.not_up_to_date(arguments = 'n1.out n2.out n3.out')
107 test.up_to_date(arguments = 'ccc.out ddd.out eee.out')
109 test.not_up_to_date(arguments = 'n1.out n2.out n3.out')
110 test.up_to_date(arguments = 'ccc.out ddd.out eee.out')
112 test.unlink('node-has-changed')
116 test.pass_test()
118 # Local Variables:
119 # tab-width:4
120 # indent-tabs-mode:nil
121 # End:
122 # vim: set expandtab tabstop=4 shiftwidth=4: