5 # Copyright The SCons Foundation
7 # Permission is hereby granted, free of charge, to any person obtaining
8 # a copy of this software and associated documentation files (the
9 # "Software"), to deal in the Software without restriction, including
10 # without limitation the rights to use, copy, modify, merge, publish,
11 # distribute, sublicense, and/or sell copies of the Software, and to
12 # permit persons to whom the Software is furnished to do so, subject to
13 # the following conditions:
15 # The above copyright notice and this permission notice shall be included
16 # in all copies or substantial portions of the Software.
18 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
19 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
20 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 from TestSCons
import TestSCons
, _exe
32 test
.subdir('repository', 'work')
34 repository
= test
.workpath('repository')
35 work_foo
= test
.workpath('work', 'foo' + _exe
)
36 work_foo_h
= test
.workpath('work', 'foo.h')
38 test
.write(['work', 'SConstruct'], """
40 DefaultEnvironment(tools=[]) # test speedup
41 env = Environment(CPPPATH = ['.'])
42 env.Program(target = 'foo', source = 'foo.c')
45 test
.write(['repository', 'foo.h'], r
"""
46 #define STRING1 "repository/foo.h"
50 test
.write(['repository', 'bar.h'], r
"""
51 #define STRING2 "repository/bar.h"
54 test
.write(['repository', 'foo.c'], r
"""
59 main(int argc, char *argv[])
62 printf("%s\n", STRING1);
63 printf("%s\n", STRING2);
64 printf("repository/foo.c\n");
69 # Make the entire repository non-writable, so we'll detect
70 # if we try to write into it accidentally.
71 test
.writable('repository', 0)
73 test
.run(chdir
= 'work', arguments
= '.')
75 test
.run(program
= work_foo
, stdout
=
81 test
.up_to_date(chdir
= 'work', arguments
= '.')
84 test
.write(['work', 'foo.h'], r
"""
85 #define STRING1 "work/foo.h"
89 test
.run(chdir
= 'work', arguments
= '.')
91 test
.run(program
= work_foo
, stdout
=
97 test
.up_to_date(chdir
= 'work', arguments
= '.')
100 test
.write(['work', 'foo.c'], r
"""
105 main(int argc, char *argv[])
108 printf("%s\n", STRING1);
109 printf("%s\n", STRING2);
110 printf("work/foo.c\n");
115 test
.run(chdir
= 'work', arguments
= '.')
117 test
.run(program
= work_foo
, stdout
=
123 test
.up_to_date(chdir
= 'work', arguments
= '.')
126 test
.write(['work', 'bar.h'], r
"""
127 #define STRING2 "work/bar.h"
130 test
.run(chdir
= 'work', arguments
= '.')
132 test
.run(program
= work_foo
, stdout
=
138 test
.up_to_date(chdir
= 'work', arguments
= '.')
141 test
.writable('repository', 1)
142 test
.unlink(['work', 'foo.h'])
143 test
.writable('repository', 0)
145 test
.run(chdir
= 'work', arguments
= '.')
147 test
.run(program
= work_foo
, stdout
=
153 test
.up_to_date(chdir
= 'work', arguments
= '.')
156 test
.writable('repository', 1)
157 test
.unlink(['work', 'foo.c'])
158 test
.writable('repository', 0)
160 test
.run(chdir
= 'work', arguments
= '.')
162 test
.run(program
= work_foo
, stdout
=
168 test
.up_to_date(chdir
= 'work', arguments
= '.')
171 test
.writable('repository', 1)
172 test
.unlink(['work', 'bar.h'])
173 test
.writable('repository', 0)
175 test
.run(chdir
= 'work', arguments
= '.')
177 test
.run(program
= work_foo
, stdout
=
183 test
.up_to_date(chdir
= 'work', arguments
= '.')
190 # indent-tabs-mode:nil
192 # vim: set expandtab tabstop=4 shiftwidth=4: