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__"
34 subdir_prog = os.path.join('subdir', 'prog' + _exe)
35 variant_prog = os.path.join('variant', 'prog' + _exe)
37 args = prog + ' ' + subdir_prog + ' ' + variant_prog
39 test = TestSCons.TestSCons()
42 if not test.detect_tool(fc):
43 test.skip_test('Could not find a f90 tool; skipping test.\n')
45 test.subdir('include',
47 ['subdir', 'include'],
53 test.write('SConstruct', """
54 env = Environment(F90 = r'%s',
55 F90PATH = ['$FOO', '${TARGET.dir}', '${SOURCE.dir}'],
58 obj = env.Object(target='foobar/prog', source='subdir/prog.f90')
59 env.Program(target='prog', source=obj)
60 SConscript('subdir/SConscript', "env")
62 VariantDir('variant', 'subdir', 0)
63 include = Dir('include')
64 env = Environment(F90 = r'%s',
65 F90PATH=[include, '#foobar', '#subdir'],
67 SConscript('variant/SConscript', "env")
70 test.write(['subdir', 'SConscript'],
73 env.Program(target='prog', source='prog.f90')
76 test.write(['include', 'foo.f90'],
78 PRINT *, 'include/foo.f90 1'
82 test.write(['include', 'bar.f90'],
84 PRINT *, 'include/bar.f90 1'
87 test.write(['subdir', 'prog.f90'],
90 PRINT *, 'subdir/prog.f90'
98 test.write(['subdir', 'include', 'foo.f90'],
100 PRINT *, 'subdir/include/foo.f90 1'
104 test.write(['subdir', 'include', 'bar.f90'],
106 PRINT *, 'subdir/include/bar.f90 1'
109 test.write(['subdir', 'sss.f90'],
111 PRINT *, 'subdir/sss.f90'
114 test.write(['subdir', 'ttt.f90'],
116 PRINT *, 'subdir/ttt.f90'
121 test.run(arguments = args)
123 test.run(program = test.workpath(prog),
132 test.run(program = test.workpath(subdir_prog),
135 subdir/include/foo.f90 1
136 subdir/include/bar.f90 1
141 test.run(program = test.workpath(variant_prog),
150 # Make sure we didn't duplicate the source file in the variant subdirectory.
151 test.must_not_exist(test.workpath('variant', 'prog.f90'))
153 test.up_to_date(arguments = args)
157 test.write(['include', 'foo.f90'],
159 PRINT *, 'include/foo.f90 2'
163 test.run(arguments = args)
165 test.run(program = test.workpath(prog),
174 test.run(program = test.workpath(subdir_prog),
177 subdir/include/foo.f90 1
178 subdir/include/bar.f90 1
183 test.run(program = test.workpath(variant_prog),
192 # Make sure we didn't duplicate the source file in the variant subdirectory.
193 test.must_not_exist(test.workpath('variant', 'prog.f90'))
195 test.up_to_date(arguments = args)
200 test.write(['include', 'bar.f90'],
202 PRINT *, 'include/bar.f90 2'
205 test.run(arguments = args)
207 test.run(program = test.workpath(prog),
216 test.run(program = test.workpath(subdir_prog),
219 subdir/include/foo.f90 1
220 subdir/include/bar.f90 1
225 test.run(program = test.workpath(variant_prog),
234 # Make sure we didn't duplicate the source file in the variant subdirectory.
235 test.must_not_exist(test.workpath('variant', 'prog.f90'))
237 test.up_to_date(arguments = args)
241 # Change F90PATH and make sure we don't rebuild because of it.
242 test.write('SConstruct', """
243 env = Environment(F90 = r'%s',
244 F90PATH = Split('inc2 include ${TARGET.dir} ${SOURCE.dir}'),
246 obj = env.Object(target='foobar/prog', source='subdir/prog.f90')
247 env.Program(target='prog', source=obj)
248 SConscript('subdir/SConscript', "env")
250 VariantDir('variant', 'subdir', 0)
251 include = Dir('include')
252 env = Environment(F90 = r'%s',
253 F90PATH=['inc2', include, '#foobar', '#subdir'],
255 SConscript('variant/SConscript', "env")
258 test.up_to_date(arguments = args)
263 test.write(['inc2', 'foo.f90'],
265 PRINT *, 'inc2/foo.f90 1'
269 test.run(arguments = args)
271 test.run(program = test.workpath(prog),
280 test.run(program = test.workpath(subdir_prog),
283 subdir/include/foo.f90 1
284 subdir/include/bar.f90 1
289 test.run(program = test.workpath(variant_prog),
298 test.up_to_date(arguments = args)