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()
37 if sys.platform == 'win32':
39 test.write('mylink.py', r"""
48 if string.lower(a[:5]) == '/out:': out = a[5:]
49 infile = open(args[0], 'rb')
50 outfile = open(out, 'wb')
51 for l in infile.readlines():
59 test.write('mylink.py', r"""
62 opts, args = getopt.getopt(sys.argv[1:], 'o:')
64 if opt == '-o': out = arg
65 infile = open(args[0], 'rb')
66 outfile = open(out, 'wb')
67 for l in infile.readlines():
73 test.write('myfortran.py', r"""
76 comment = '#' + sys.argv[1]
77 opts, args = getopt.getopt(sys.argv[2:], 'co:xy')
80 if opt == '-o': out = arg
81 else: optstring = optstring + ' ' + opt
82 infile = open(args[0], 'rb')
83 outfile = open(out, 'wb')
84 outfile.write(optstring + "\n")
85 for l in infile.readlines():
86 if l[:len(comment)] != comment:
93 test.write('SConstruct', """
94 env = Environment(LINK = r'%s mylink.py',
96 F95 = r'%s myfortran.py g95',
98 FORTRAN = r'%s myfortran.py fortran',
100 env.Program(target = 'test01', source = 'test01.f')
101 env.Program(target = 'test02', source = 'test02.F')
102 env.Program(target = 'test03', source = 'test03.for')
103 env.Program(target = 'test04', source = 'test04.FOR')
104 env.Program(target = 'test05', source = 'test05.ftn')
105 env.Program(target = 'test06', source = 'test06.FTN')
106 env.Program(target = 'test07', source = 'test07.fpp')
107 env.Program(target = 'test08', source = 'test08.FPP')
108 env.Program(target = 'test09', source = 'test09.f77')
109 env.Program(target = 'test10', source = 'test10.F77')
110 env.Program(target = 'test11', source = 'test11.f90')
111 env.Program(target = 'test12', source = 'test12.F90')
112 env.Program(target = 'test13', source = 'test13.f95')
113 env.Program(target = 'test14', source = 'test14.F95')
114 """ % (python, python, python))
116 test.write('test01.f', "This is a .f file.\n#link\n#fortran\n")
117 test.write('test02.F', "This is a .F file.\n#link\n#fortran\n")
118 test.write('test03.for', "This is a .for file.\n#link\n#fortran\n")
119 test.write('test04.FOR', "This is a .FOR file.\n#link\n#fortran\n")
120 test.write('test05.ftn', "This is a .ftn file.\n#link\n#fortran\n")
121 test.write('test06.FTN', "This is a .FTN file.\n#link\n#fortran\n")
122 test.write('test07.fpp', "This is a .fpp file.\n#link\n#fortran\n")
123 test.write('test08.FPP', "This is a .FPP file.\n#link\n#fortran\n")
124 test.write('test09.f77', "This is a .f77 file.\n#link\n#fortran\n")
125 test.write('test10.F77', "This is a .F77 file.\n#link\n#fortran\n")
126 test.write('test11.f90', "This is a .f90 file.\n#link\n#fortran\n")
127 test.write('test12.F90', "This is a .F90 file.\n#link\n#fortran\n")
128 test.write('test13.f95', "This is a .f95 file.\n#link\n#g95\n")
129 test.write('test14.F95', "This is a .F95 file.\n#link\n#g95\n")
131 test.run(arguments = '.', stderr = None)
133 test.must_match('test01' + _exe, " -y -c\nThis is a .f file.\n")
134 test.must_match('test02' + _exe, " -y -c\nThis is a .F file.\n")
135 test.must_match('test03' + _exe, " -y -c\nThis is a .for file.\n")
136 test.must_match('test04' + _exe, " -y -c\nThis is a .FOR file.\n")
137 test.must_match('test05' + _exe, " -y -c\nThis is a .ftn file.\n")
138 test.must_match('test06' + _exe, " -y -c\nThis is a .FTN file.\n")
139 test.must_match('test07' + _exe, " -y -c\nThis is a .fpp file.\n")
140 test.must_match('test08' + _exe, " -y -c\nThis is a .FPP file.\n")
141 test.must_match('test09' + _exe, " -y -c\nThis is a .f77 file.\n")
142 test.must_match('test10' + _exe, " -y -c\nThis is a .F77 file.\n")
143 test.must_match('test11' + _exe, " -y -c\nThis is a .f90 file.\n")
144 test.must_match('test12' + _exe, " -y -c\nThis is a .F90 file.\n")
145 test.must_match('test13' + _exe, " -x -c\nThis is a .f95 file.\n")
146 test.must_match('test14' + _exe, " -x -c\nThis is a .F95 file.\n")
150 g95 = test.detect('F95', 'g95')
151 FTN_LIB = TestSCons.fortran_lib
155 test.write("wrapper.py",
159 open('%s', 'wb').write("wrapper.py\\n")
160 os.system(string.join(sys.argv[1:], " "))
161 """ % string.replace(test.workpath('wrapper.out'), '\\', '\\\\'))
163 test.write('SConstruct', """
164 foo = Environment(LIBS = %s)
165 f95 = foo.Dictionary('F95')
166 bar = foo.Copy(F95 = r'%s wrapper.py ' + f95, F95FLAGS = '-Ix')
167 foo.Program(target = 'foo', source = 'foo.f')
168 bar.Program(target = 'bar', source = 'bar.f')
169 """ % (FTN_LIB, python))
171 test.write('foo.f', r"""
178 test.write('bar.f', r"""
186 test.run(arguments = 'foo' + _exe, stderr = None)
188 test.run(program = test.workpath('foo'), stdout = " foo.f\n")
190 test.must_not_exist('wrapper.out')
192 test.run(arguments = 'bar' + _exe)
194 test.run(program = test.workpath('bar'), stdout = " bar.f\n")
196 test.must_match('wrapper.out', "wrapper.py\n")