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__"
32 _python_ = TestSCons._python_
34 test = TestSCons.TestSCons()
38 test.write('myfc.py', r"""
40 fline = '#'+sys.argv[1]+'\n'
41 outfile = open(sys.argv[2], 'wb')
42 infile = open(sys.argv[3], 'rb')
43 for l in filter(lambda l, fl=fline: l != fl, infile.readlines()):
48 if os.path.normcase('.f') == os.path.normcase('.F'):
54 test.write('SConstruct', """
55 env = Environment(SHF77COM = r'%(_python_)s myfc.py f77 $TARGET $SOURCES',
56 SHF77COMSTR = 'Building f77 $TARGET from $SOURCES',
57 SHF77PPCOM = r'%(_python_)s myfc.py f77pp $TARGET $SOURCES',
58 SHF77PPCOMSTR = 'Building f77pp $TARGET from $SOURCES',
59 SHOBJPREFIX='', SHOBJSUFFIX='.shobj')
60 env.SharedObject(source = 'test01.f')
61 env.SharedObject(source = 'test02.F')
62 env.SharedObject(source = 'test03.for')
63 env.SharedObject(source = 'test04.FOR')
64 env.SharedObject(source = 'test05.ftn')
65 env.SharedObject(source = 'test06.FTN')
66 env.SharedObject(source = 'test07.fpp')
67 env.SharedObject(source = 'test08.FPP')
68 env.SharedObject(source = 'test09.f77')
69 env.SharedObject(source = 'test10.F77')
72 test.write('test01.f', "A .f file.\n#f77\n")
73 test.write('test02.F', "A .F file.\n#%s\n" % f77pp)
74 test.write('test03.for', "A .for file.\n#f77\n")
75 test.write('test04.FOR', "A .FOR file.\n#%s\n" % f77pp)
76 test.write('test05.ftn', "A .ftn file.\n#f77\n")
77 test.write('test06.FTN', "A .FTN file.\n#%s\n" % f77pp)
78 test.write('test07.fpp', "A .fpp file.\n#f77pp\n")
79 test.write('test08.FPP', "A .FPP file.\n#f77pp\n")
80 test.write('test09.f77', "A .f77 file.\n#f77\n")
81 test.write('test10.F77', "A .F77 file.\n#%s\n" % f77pp)
83 test.run(stdout = test.wrap_stdout("""\
84 Building f77 test01.shobj from test01.f
85 Building %(f77pp)s test02.shobj from test02.F
86 Building f77 test03.shobj from test03.for
87 Building %(f77pp)s test04.shobj from test04.FOR
88 Building f77 test05.shobj from test05.ftn
89 Building %(f77pp)s test06.shobj from test06.FTN
90 Building f77pp test07.shobj from test07.fpp
91 Building f77pp test08.shobj from test08.FPP
92 Building f77 test09.shobj from test09.f77
93 Building %(f77pp)s test10.shobj from test10.F77
96 test.must_match('test01.shobj', "A .f file.\n")
97 test.must_match('test02.shobj', "A .F file.\n")
98 test.must_match('test03.shobj', "A .for file.\n")
99 test.must_match('test04.shobj', "A .FOR file.\n")
100 test.must_match('test05.shobj', "A .ftn file.\n")
101 test.must_match('test06.shobj', "A .FTN file.\n")
102 test.must_match('test07.shobj', "A .fpp file.\n")
103 test.must_match('test08.shobj', "A .FPP file.\n")
104 test.must_match('test09.shobj', "A .f77 file.\n")
105 test.must_match('test10.shobj', "A .F77 file.\n")