added release.txt blurb. Fixed spelling typo in Defaults.xml
[scons.git] / test / Fortran / F95FLAGS.py
blobe7062641978a5ee38f3401c239ae0a088760ac16
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_
30 test = TestSCons.TestSCons()
31 _exe = TestSCons._exe
33 # ref: test/fixture/mylink.py
34 test.file_fixture('mylink.py')
35 # ref: test/Fortran/fixture/myfortran_flags.py
36 test.file_fixture(['fixture', 'myfortran_flags.py'])
38 test.write('SConstruct', """
39 env = Environment(
40 LINK=r'%(_python_)s mylink.py',
41 LINKFLAGS=[],
42 F95=r'%(_python_)s myfortran_flags.py g95',
43 F95FLAGS='-x',
44 FORTRAN=r'%(_python_)s myfortran_flags.py fortran',
45 FORTRANFLAGS='-y',
47 env.Program(target='test01', source='test01.f')
48 env.Program(target='test02', source='test02.F')
49 env.Program(target='test03', source='test03.for')
50 env.Program(target='test04', source='test04.FOR')
51 env.Program(target='test05', source='test05.ftn')
52 env.Program(target='test06', source='test06.FTN')
53 env.Program(target='test07', source='test07.fpp')
54 env.Program(target='test08', source='test08.FPP')
55 env.Program(target='test13', source='test13.f95')
56 env.Program(target='test14', source='test14.F95')
57 """ % locals())
59 test.write('test01.f', "This is a .f file.\n#link\n#fortran\n")
60 test.write('test02.F', "This is a .F file.\n#link\n#fortran\n")
61 test.write('test03.for', "This is a .for file.\n#link\n#fortran\n")
62 test.write('test04.FOR', "This is a .FOR file.\n#link\n#fortran\n")
63 test.write('test05.ftn', "This is a .ftn file.\n#link\n#fortran\n")
64 test.write('test06.FTN', "This is a .FTN file.\n#link\n#fortran\n")
65 test.write('test07.fpp', "This is a .fpp file.\n#link\n#fortran\n")
66 test.write('test08.FPP', "This is a .FPP file.\n#link\n#fortran\n")
67 test.write('test13.f95', "This is a .f95 file.\n#link\n#g95\n")
68 test.write('test14.F95', "This is a .F95 file.\n#link\n#g95\n")
70 test.run(arguments = '.', stderr = None)
72 test.must_match('test01' + _exe, " -c -y\nThis is a .f file.\n")
73 test.must_match('test02' + _exe, " -c -y\nThis is a .F file.\n")
74 test.must_match('test03' + _exe, " -c -y\nThis is a .for file.\n")
75 test.must_match('test04' + _exe, " -c -y\nThis is a .FOR file.\n")
76 test.must_match('test05' + _exe, " -c -y\nThis is a .ftn file.\n")
77 test.must_match('test06' + _exe, " -c -y\nThis is a .FTN file.\n")
78 test.must_match('test07' + _exe, " -c -y\nThis is a .fpp file.\n")
79 test.must_match('test08' + _exe, " -c -y\nThis is a .FPP file.\n")
80 test.must_match('test13' + _exe, " -c -x\nThis is a .f95 file.\n")
81 test.must_match('test14' + _exe, " -c -x\nThis is a .F95 file.\n")
84 fc = 'f95'
85 g95 = test.detect_tool(fc)
86 if g95:
87 test.subdir('x')
88 test.write(['x','dummy.i'],
89 """
90 # Exists only such that -Ix finds the directory...
91 """)
93 # ref: test/fixture/wrapper.py
94 test.file_fixture('wrapper.py')
96 test.write('SConstruct', """
97 foo = Environment(F95='%(fc)s')
98 f95 = foo.Dictionary('F95')
99 bar = foo.Clone(F95=r'%(_python_)s wrapper.py ' + f95, F95FLAGS='-Ix')
100 foo.Program(target='foo', source='foo.f95')
101 bar.Program(target='bar', source='bar.f95')
102 """ % locals())
104 test.write('foo.f95', r"""
105 PROGRAM FOO
106 PRINT *,'foo.f95'
107 STOP
109 """)
111 test.write('bar.f95', r"""
112 PROGRAM BAR
113 PRINT *,'bar.f95'
114 STOP
116 """)
118 test.run(arguments='foo' + _exe, stderr=None)
119 test.run(program=test.workpath('foo'), stdout=" foo.f95\n")
120 test.must_not_exist('wrapper.out')
122 import sys
124 if sys.platform.startswith('sunos'):
125 test.run(arguments='bar' + _exe, stderr=None)
126 else:
127 test.run(arguments='bar' + _exe)
129 test.run(program=test.workpath('bar'), stdout=" bar.f95\n")
130 test.must_match('wrapper.out', "wrapper.py\n")
132 test.pass_test()
134 # Local Variables:
135 # tab-width:4
136 # indent-tabs-mode:nil
137 # End:
138 # vim: set expandtab tabstop=4 shiftwidth=4: