[ci skip] Add note that this change may break SetOption() + ninja usage with fix
[scons.git] / test / Fortran / SHF03.py
blob1c3fb1b1e0e6fa6147508ca62535516c9e779138
1 #!/usr/bin/env python
3 # __COPYRIGHT__
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__"
27 import TestSCons
29 _python_ = TestSCons._python_
30 _obj = TestSCons._shobj
31 obj_ = TestSCons.shobj_
33 test = TestSCons.TestSCons()
35 test.file_fixture(['fixture', 'myfortran.py'])
37 test.write('SConstruct', """
38 env = Environment(SHF03 = r'%(_python_)s myfortran.py g03',
39 SHFORTRAN = r'%(_python_)s myfortran.py fortran')
40 env.SharedObject(target = 'test01', source = 'test01.f')
41 env.SharedObject(target = 'test02', source = 'test02.F')
42 env.SharedObject(target = 'test03', source = 'test03.for')
43 env.SharedObject(target = 'test04', source = 'test04.FOR')
44 env.SharedObject(target = 'test05', source = 'test05.ftn')
45 env.SharedObject(target = 'test06', source = 'test06.FTN')
46 env.SharedObject(target = 'test07', source = 'test07.fpp')
47 env.SharedObject(target = 'test08', source = 'test08.FPP')
48 env.SharedObject(target = 'test13', source = 'test13.f03')
49 env.SharedObject(target = 'test14', source = 'test14.F03')
50 """ % locals())
52 test.write('test01.f', "This is a .f file.\n#fortran\n")
53 test.write('test02.F', "This is a .F file.\n#fortran\n")
54 test.write('test03.for', "This is a .for file.\n#fortran\n")
55 test.write('test04.FOR', "This is a .FOR file.\n#fortran\n")
56 test.write('test05.ftn', "This is a .ftn file.\n#fortran\n")
57 test.write('test06.FTN', "This is a .FTN file.\n#fortran\n")
58 test.write('test07.fpp', "This is a .fpp file.\n#fortran\n")
59 test.write('test08.FPP', "This is a .FPP file.\n#fortran\n")
60 test.write('test13.f03', "This is a .f03 file.\n#g03\n")
61 test.write('test14.F03', "This is a .F03 file.\n#g03\n")
63 test.run(arguments = '.', stderr = None)
65 test.must_match(obj_ + 'test01' + _obj, "This is a .f file.\n")
66 test.must_match(obj_ + 'test02' + _obj, "This is a .F file.\n")
67 test.must_match(obj_ + 'test03' + _obj, "This is a .for file.\n")
68 test.must_match(obj_ + 'test04' + _obj, "This is a .FOR file.\n")
69 test.must_match(obj_ + 'test05' + _obj, "This is a .ftn file.\n")
70 test.must_match(obj_ + 'test06' + _obj, "This is a .FTN file.\n")
71 test.must_match(obj_ + 'test07' + _obj, "This is a .fpp file.\n")
72 test.must_match(obj_ + 'test08' + _obj, "This is a .FPP file.\n")
73 test.must_match(obj_ + 'test13' + _obj, "This is a .f03 file.\n")
74 test.must_match(obj_ + 'test14' + _obj, "This is a .F03 file.\n")
76 fc = 'f03'
77 g03 = test.detect_tool(fc)
79 if g03:
81 test.file_fixture('wrapper.py')
83 test.write('SConstruct', """
84 foo = Environment(SHF03 = '%(fc)s')
85 shf03 = foo.Dictionary('SHF03')
86 bar = foo.Clone(SHF03 = r'%(_python_)s wrapper.py ' + shf03)
87 foo.SharedObject(target = 'foo/foo', source = 'foo.f03')
88 bar.SharedObject(target = 'bar/bar', source = 'bar.f03')
89 """ % locals())
91 test.write('foo.f03', r"""
92 PROGRAM FOO
93 PRINT *,'foo.f03'
94 STOP
95 END
96 """)
98 test.write('bar.f03', r"""
99 PROGRAM BAR
100 PRINT *,'bar.f03'
101 STOP
103 """)
106 test.run(arguments = 'foo', stderr = None)
108 test.must_not_exist('wrapper.out')
110 import sys
111 if sys.platform[:5] == 'sunos':
112 test.run(arguments = 'bar', stderr = None)
113 else:
114 test.run(arguments = 'bar')
116 test.must_match('wrapper.out', "wrapper.py\n")
118 test.pass_test()
120 # Local Variables:
121 # tab-width:4
122 # indent-tabs-mode:nil
123 # End:
124 # vim: set expandtab tabstop=4 shiftwidth=4: