3 # Copyright (c) 2001, 2002 Steven Knight
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 = sys.executable
34 if sys.platform == 'win32':
39 test = TestSCons.TestSCons()
43 if sys.platform == 'win32':
45 test.write('mylink.py', r"""
54 if string.lower(a[:5]) == '/out:': out = a[5:]
55 infile = open(args[0], 'rb')
56 outfile = open(out, 'wb')
57 for l in infile.readlines():
63 test.write('myg77.py', r"""
74 if a[:3] == '/Fo': out = a[3:]
75 infile = open(inf, 'rb')
76 outfile = open(out, 'wb')
77 for l in infile.readlines():
85 test.write('mylink.py', r"""
88 opts, args = getopt.getopt(sys.argv[1:], 'o:')
90 if opt == '-o': out = arg
91 infile = open(args[0], 'rb')
92 outfile = open(out, 'wb')
93 for l in infile.readlines():
99 test.write('myg77.py', r"""
102 opts, args = getopt.getopt(sys.argv[1:], 'co:')
103 for opt, arg in opts:
104 if opt == '-o': out = arg
105 infile = open(args[0], 'rb')
106 outfile = open(out, 'wb')
107 for l in infile.readlines():
113 test.write('SConstruct', """
114 env = Environment(LINK = r'%s mylink.py',
115 F77 = r'%s myg77.py')
116 env.Program(target = 'test1', source = 'test1.f')
117 env.Program(target = 'test2', source = 'test2.for')
118 env.Program(target = 'test3', source = 'test3.FOR')
119 env.Program(target = 'test4', source = 'test4.F')
120 env.Program(target = 'test5', source = 'test5.fpp')
121 env.Program(target = 'test6', source = 'test6.FPP')
122 """ % (python, python))
124 test.write('test1.f', r"""This is a .f file.
129 test.write('test2.for', r"""This is a .for file.
134 test.write('test3.FOR', r"""This is a .FOR file.
139 test.write('test4.F', r"""This is a .F file.
144 test.write('test5.fpp', r"""This is a .fpp file.
149 test.write('test6.FPP', r"""This is a .FPP file.
154 test.run(arguments = '.', stderr = None)
156 test.fail_test(test.read('test1' + _exe) != "This is a .f file.\n")
158 test.fail_test(test.read('test2' + _exe) != "This is a .for file.\n")
160 test.fail_test(test.read('test3' + _exe) != "This is a .FOR file.\n")
162 test.fail_test(test.read('test4' + _exe) != "This is a .F file.\n")
164 test.fail_test(test.read('test5' + _exe) != "This is a .fpp file.\n")
166 test.fail_test(test.read('test6' + _exe) != "This is a .FPP file.\n")
170 g77 = test.where_is('g77')
174 test.write("wrapper.py",
178 open('%s', 'wb').write("wrapper.py\\n")
179 os.system(string.join(sys.argv[1:], " "))
180 """ % string.replace(test.workpath('wrapper.out'), '\\', '\\\\'))
182 test.write('SConstruct', """
183 foo = Environment(LIBS = 'g2c')
184 f77 = foo.Dictionary('F77')
185 bar = foo.Copy(F77 = r'%s wrapper.py ' + f77)
186 foo.Program(target = 'foo', source = 'foo.f')
187 bar.Program(target = 'bar', source = 'bar.f')
190 test.write('foo.f', r"""
197 test.write('bar.f', r"""
205 test.run(arguments = 'foo' + _exe, stderr = None)
207 test.run(program = test.workpath('foo'), stdout = " foo.f\n")
209 test.fail_test(os.path.exists(test.workpath('wrapper.out')))
211 test.run(arguments = 'bar' + _exe)
213 test.run(program = test.workpath('bar'), stdout = " bar.f\n")
215 test.fail_test(test.read('wrapper.out') != "wrapper.py\n")