added release.txt blurb. Fixed spelling typo in Defaults.xml
[scons.git] / test / Fortran / F03.py
blob0d4b9461c24fd15c9eaab5308afce25e665532a3
1 #!/usr/bin/env python
3 # MIT License
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.
26 import TestSCons
28 _python_ = TestSCons._python_
29 _exe = TestSCons._exe
31 test = TestSCons.TestSCons()
33 test.file_fixture('mylink.py')
34 test.file_fixture(['fixture', 'myfortran.py'])
36 test.write('SConstruct', """
37 env = Environment(LINK = r'%(_python_)s mylink.py',
38 LINKFLAGS = [],
39 F03 = r'%(_python_)s myfortran.py f03',
40 FORTRAN = r'%(_python_)s myfortran.py fortran')
41 env.Program(target = 'test01', source = 'test01.f')
42 env.Program(target = 'test02', source = 'test02.F')
43 env.Program(target = 'test03', source = 'test03.for')
44 env.Program(target = 'test04', source = 'test04.FOR')
45 env.Program(target = 'test05', source = 'test05.ftn')
46 env.Program(target = 'test06', source = 'test06.FTN')
47 env.Program(target = 'test07', source = 'test07.fpp')
48 env.Program(target = 'test08', source = 'test08.FPP')
49 env.Program(target = 'test13', source = 'test13.f03')
50 env.Program(target = 'test14', source = 'test14.F03')
51 """ % locals())
53 test.write('test01.f', "This is a .f file.\n#link\n#fortran\n")
54 test.write('test02.F', "This is a .F file.\n#link\n#fortran\n")
55 test.write('test03.for', "This is a .for file.\n#link\n#fortran\n")
56 test.write('test04.FOR', "This is a .FOR file.\n#link\n#fortran\n")
57 test.write('test05.ftn', "This is a .ftn file.\n#link\n#fortran\n")
58 test.write('test06.FTN', "This is a .FTN file.\n#link\n#fortran\n")
59 test.write('test07.fpp', "This is a .fpp file.\n#link\n#fortran\n")
60 test.write('test08.FPP', "This is a .FPP file.\n#link\n#fortran\n")
61 test.write('test13.f03', "This is a .f03 file.\n#link\n#f03\n")
62 test.write('test14.F03', "This is a .F03 file.\n#link\n#f03\n")
64 test.run(arguments = '.', stderr = None)
66 test.must_match('test01' + _exe, "This is a .f file.\n")
67 test.must_match('test02' + _exe, "This is a .F file.\n")
68 test.must_match('test03' + _exe, "This is a .for file.\n")
69 test.must_match('test04' + _exe, "This is a .FOR file.\n")
70 test.must_match('test05' + _exe, "This is a .ftn file.\n")
71 test.must_match('test06' + _exe, "This is a .FTN file.\n")
72 test.must_match('test07' + _exe, "This is a .fpp file.\n")
73 test.must_match('test08' + _exe, "This is a .FPP file.\n")
74 test.must_match('test13' + _exe, "This is a .f03 file.\n")
75 test.must_match('test14' + _exe, "This is a .F03 file.\n")
78 fc = 'f03'
79 g03 = test.detect_tool(fc)
81 if g03:
82 test.file_fixture('wrapper.py')
84 test.write('SConstruct', """
85 foo = Environment(F03 = '%(fc)s')
86 f03 = foo.Dictionary('F03')
87 bar = foo.Clone(F03 = r'%(_python_)s wrapper.py ' + f03)
88 foo.Program(target = 'foo', source = 'foo.f03')
89 bar.Program(target = 'bar', source = 'bar.f03')
90 """ % locals())
92 test.write('foo.f03', r"""
93 PROGRAM FOO
94 PRINT *,'foo.f03'
95 STOP
96 END
97 """)
99 test.write('bar.f03', r"""
100 PROGRAM BAR
101 PRINT *,'bar.f03'
102 STOP
104 """)
107 test.run(arguments = 'foo' + _exe, stderr = None)
109 test.run(program = test.workpath('foo'), stdout = " foo.f03\n")
111 test.must_not_exist('wrapper.out')
113 import sys
114 if sys.platform[:5] == 'sunos':
115 test.run(arguments = 'bar' + _exe, stderr = None)
116 else:
117 test.run(arguments = 'bar' + _exe)
119 test.run(program = test.workpath('bar'), stdout = " bar.f03\n")
121 test.must_match('wrapper.out', "wrapper.py\n")
123 test.pass_test()
125 # Local Variables:
126 # tab-width:4
127 # indent-tabs-mode:nil
128 # End:
129 # vim: set expandtab tabstop=4 shiftwidth=4: