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__"
28 This test tests directories as source files. The correct behavior is that
29 any file under a directory acts like a source file of that directory.
30 In other words, if a build has a directory as a source file, any
31 change in any file under that directory should trigger a rebuild.
37 test = TestSCons.TestSCons()
39 test.subdir('tstamp', [ 'tstamp', 'subdir' ],
40 'content', [ 'content', 'subdir' ],
41 'cmd-tstamp', [ 'cmd-tstamp', 'subdir' ],
42 'cmd-content', [ 'cmd-content', 'subdir' ])
44 test.write('SConstruct', """\
45 def writeTarget(target, source, env):
46 f=open(str(target[0]), 'wb')
51 test_bld_dir = Builder(action=writeTarget,
53 source_scanner=DirScanner)
54 test_bld_file = Builder(action=writeTarget)
56 env['BUILDERS']['TestDir'] = test_bld_dir
57 env['BUILDERS']['TestFile'] = test_bld_file
59 env_tstamp = env.Clone()
60 env_tstamp.Decider('timestamp-newer')
61 env_tstamp.TestFile(source='junk.txt', target='tstamp/junk.out')
62 env_tstamp.TestDir(source='tstamp', target='tstamp.out')
63 env_tstamp.Command('cmd-tstamp-noscan.out', 'cmd-tstamp', writeTarget)
64 env_tstamp.Command('cmd-tstamp.out', 'cmd-tstamp', writeTarget,
65 source_scanner=DirScanner)
67 env_content = env.Clone()
68 env_content.Decider('content')
69 env_content.TestFile(source='junk.txt', target='content/junk.out')
70 env_content.TestDir(source='content', target='content.out')
71 env_content.Command('cmd-content-noscan.out', 'cmd-content', writeTarget)
72 env_content.Command('cmd-content.out', 'cmd-content', writeTarget,
73 source_scanner=DirScanner)
76 test.write([ 'tstamp', 'foo.txt' ], 'foo.txt 1\n')
77 test.write([ 'tstamp', '#hash.txt' ], 'hash.txt 1\n')
78 test.write([ 'tstamp', 'subdir', 'bar.txt'], 'bar.txt 1\n')
79 test.write([ 'tstamp', 'subdir', '#hash.txt'], 'hash.txt 1\n')
80 test.write([ 'content', 'foo.txt' ], 'foo.txt 1\n')
81 test.write([ 'content', '#hash.txt' ], 'hash.txt 1\n')
82 test.write([ 'content', 'subdir', 'bar.txt' ], 'bar.txt 1\n')
83 test.write([ 'content', 'subdir', '#hash.txt' ], 'hash.txt 1\n')
84 test.write([ 'cmd-tstamp', 'foo.txt' ], 'foo.txt 1\n')
85 test.write([ 'cmd-tstamp', '#hash.txt' ], 'hash.txt 1\n')
86 test.write([ 'cmd-tstamp', 'subdir', 'bar.txt' ], 'bar.txt 1\n')
87 test.write([ 'cmd-tstamp', 'subdir', '#hash.txt' ], 'hash.txt 1\n')
88 test.write([ 'cmd-content', 'foo.txt' ], 'foo.txt 1\n')
89 test.write([ 'cmd-content', '#hash.txt' ], '#hash.txt 1\n')
90 test.write([ 'cmd-content', 'subdir', 'bar.txt' ], 'bar.txt 1\n')
91 test.write([ 'cmd-content', 'subdir', '#hash.txt' ], 'hash.txt 1\n')
92 test.write('junk.txt', 'junk.txt\n')
94 test.run(arguments=".", stderr=None)
95 test.must_match('tstamp.out', 'stuff\n')
96 test.must_match('content.out', 'stuff\n')
97 test.must_match('cmd-tstamp.out', 'stuff\n')
98 test.must_match('cmd-content.out', 'stuff\n')
99 test.must_match('cmd-tstamp-noscan.out', 'stuff\n')
100 test.must_match('cmd-content-noscan.out', 'stuff\n')
102 test.up_to_date(arguments='tstamp.out')
103 test.up_to_date(arguments='content.out')
104 test.up_to_date(arguments='cmd-tstamp.out')
105 test.up_to_date(arguments='cmd-content.out')
106 test.up_to_date(arguments='cmd-tstamp-noscan.out')
107 test.up_to_date(arguments='cmd-content-noscan.out')
109 test.write([ 'tstamp', 'foo.txt' ], 'foo.txt 2\n')
110 test.not_up_to_date(arguments='tstamp.out')
112 test.write([ 'tstamp', 'new.txt' ], 'new.txt\n')
113 test.not_up_to_date(arguments='tstamp.out')
115 test.write([ 'content', 'foo.txt' ], 'foo.txt 2\n')
116 test.not_up_to_date(arguments='content.out')
118 test.write([ 'content', 'new.txt' ], 'new.txt\n')
119 test.not_up_to_date(arguments='content.out')
121 test.write([ 'cmd-tstamp', 'foo.txt' ], 'foo.txt 2\n')
122 test.not_up_to_date(arguments='cmd-tstamp.out')
123 test.up_to_date(arguments='cmd-tstamp-noscan.out')
125 test.write([ 'cmd-tstamp', 'new.txt' ], 'new.txt\n')
126 test.not_up_to_date(arguments='cmd-tstamp.out')
127 test.up_to_date(arguments='cmd-tstamp-noscan.out')
129 test.write([ 'cmd-content', 'foo.txt' ], 'foo.txt 2\n')
130 test.not_up_to_date(arguments='cmd-content.out')
131 test.up_to_date(arguments='cmd-content-noscan.out')
133 test.write([ 'cmd-content', 'new.txt' ], 'new.txt\n')
134 test.not_up_to_date(arguments='cmd-content.out')
135 test.up_to_date(arguments='cmd-content-noscan.out')
137 test.write([ 'tstamp', 'subdir', 'bar.txt' ], 'bar.txt 2\n')
138 test.not_up_to_date(arguments='tstamp.out')
140 test.write([ 'tstamp', 'subdir', 'new.txt' ], 'new.txt\n')
141 test.not_up_to_date(arguments='tstamp.out')
143 test.write([ 'content', 'subdir', 'bar.txt' ], 'bar.txt 2\n')
144 test.not_up_to_date(arguments='content.out')
146 test.write([ 'content', 'subdir', 'new.txt' ], 'new.txt\n')
147 test.not_up_to_date(arguments='content.out')
149 test.write([ 'cmd-tstamp', 'subdir', 'bar.txt' ], 'bar.txt 2\n')
150 test.not_up_to_date(arguments='cmd-tstamp.out')
151 test.up_to_date(arguments='cmd-tstamp-noscan.out')
153 test.write([ 'cmd-tstamp', 'subdir', 'new.txt' ], 'new.txt\n')
154 test.not_up_to_date(arguments='cmd-tstamp.out')
155 test.up_to_date(arguments='cmd-tstamp-noscan.out')
157 test.write([ 'cmd-content', 'subdir', 'bar.txt' ], 'bar.txt 2\n')
158 test.not_up_to_date(arguments='cmd-content.out')
159 test.up_to_date(arguments='cmd-content-noscan.out')
161 test.write([ 'cmd-content', 'subdir', 'new.txt' ], 'new.txt\n')
162 test.not_up_to_date(arguments='cmd-content.out')
163 test.up_to_date(arguments='cmd-content-noscan.out')
165 test.write('junk.txt', 'junk.txt 2\n')
166 test.not_up_to_date(arguments='tstamp.out')
167 test.not_up_to_date(arguments='content.out')
173 # indent-tabs-mode:nil
175 # vim: set expandtab tabstop=4 shiftwidth=4: