diff options
| author | Steven Knight <knight@baldmt.com> | 2004-07-29 13:22:43 (GMT) |
|---|---|---|
| committer | Steven Knight <knight@baldmt.com> | 2004-07-29 13:22:43 (GMT) |
| commit | 39c71db4a22f03bf17a39fa84ff6abe84e4f0d51 (patch) | |
| tree | 26e7f0319f29604b9c80df73009b768d1f0067a6 /test | |
| parent | 6a1ff461cdea7e26330ebcdce821ae5a95e415ce (diff) | |
| download | SCons-39c71db4a22f03bf17a39fa84ff6abe84e4f0d51.zip SCons-39c71db4a22f03bf17a39fa84ff6abe84e4f0d51.tar.gz SCons-39c71db4a22f03bf17a39fa84ff6abe84e4f0d51.tar.bz2 | |
Add Fortran 90/95 support. (Chris Murray)
Diffstat (limited to 'test')
| -rw-r--r-- | test/BuildDir.py | 16 | ||||
| -rw-r--r-- | test/CPPFLAGS.py | 4 | ||||
| -rw-r--r-- | test/F77.py | 195 | ||||
| -rw-r--r-- | test/F77FLAGS.py | 198 | ||||
| -rw-r--r-- | test/F77PATH.py | 203 | ||||
| -rw-r--r-- | test/FORTRANSUFFIXES.py | 160 | ||||
| -rw-r--r-- | test/SHF77.py | 148 | ||||
| -rw-r--r-- | test/SHF77FLAGS.py | 160 |
8 files changed, 10 insertions, 1074 deletions
diff --git a/test/BuildDir.py b/test/BuildDir.py index 6d5289f..4e2871a 100644 --- a/test/BuildDir.py +++ b/test/BuildDir.py @@ -35,7 +35,7 @@ fortran_runtime = TestSCons.fortran_lib test = TestSCons.TestSCons() -f77 = test.detect('F77') +fortran = test.detect('FORTRAN') foo11 = test.workpath('work1', 'build', 'var1', 'foo1' + _exe) foo12 = test.workpath('work1', 'build', 'var1', 'foo2' + _exe) @@ -78,15 +78,15 @@ env.BuildDir("$BUILD/var4", "$SRC", duplicate=0) BuildDir(var5, src, duplicate=0) BuildDir(var6, src) -env = Environment(CPPPATH='#src', F77PATH='#src') +env = Environment(CPPPATH='#src', FORTRANPATH='#src') SConscript('build/var1/SConscript', "env") SConscript('build/var2/SConscript', "env") -env = Environment(CPPPATH=src, F77PATH=src) +env = Environment(CPPPATH=src, FORTRANPATH=src) SConscript('build/var3/SConscript', "env") SConscript(File('SConscript', var4), "env") -env = Environment(CPPPATH='.', F77PATH='.') +env = Environment(CPPPATH='.', FORTRANPATH='.') SConscript('../build/var5/SConscript', "env") SConscript('../build/var6/SConscript', "env") """) @@ -118,11 +118,11 @@ env2.Program(target='foo3', source='f3.c') env2.Program(target='foo4', source='f4.c') try: - f77 = env['F77'] + fortran = env.subst('$FORTRAN') except: - f77 = None + fortran = None -if f77 and env.Detect(env['F77']): +if fortran and env.Detect(fortran): env.Command(target='b2.f', source='b2.in', action=buildIt) env.Copy(LIBS = %s).Program(target='bar2', source='b2.f') env.Copy(LIBS = %s).Program(target='bar1', source='b1.f') @@ -241,7 +241,7 @@ test.run(program = foo42, stdout = "f2.c\n") test.run(program = foo51, stdout = "f1.c\n") test.run(program = foo52, stdout = "f2.c\n") -if f77: +if fortran: test.run(program = bar11, stdout = " b1.for\n") test.run(program = bar12, stdout = " b2.for\n") test.run(program = bar21, stdout = " b1.for\n") diff --git a/test/CPPFLAGS.py b/test/CPPFLAGS.py index 357a241..92c7d7c 100644 --- a/test/CPPFLAGS.py +++ b/test/CPPFLAGS.py @@ -107,7 +107,7 @@ env = Environment(CPPFLAGS = '-x', CC = r'%s mygcc.py cc', CXX = r'%s mygcc.py c++', CXXFLAGS = [], - F77 = r'%s mygcc.py g77') + FORTRAN = r'%s mygcc.py g77') env.Program(target = 'foo', source = Split('test1.c test2.cpp test3.F')) """ % (python, python, python, python)) @@ -144,7 +144,7 @@ env = Environment(CPPFLAGS = '-x', CC = r'%s mygcc.py cc', CXX = r'%s mygcc.py c++', CXXFLAGS = [], - F77 = r'%s mygcc.py g77') + FORTRAN = r'%s mygcc.py g77') env.SharedLibrary(target = File('foo.bar'), source = Split('test1.c test2.cpp test3.F')) """ % (python, python, python, python)) diff --git a/test/F77.py b/test/F77.py deleted file mode 100644 index 94c7c77..0000000 --- a/test/F77.py +++ /dev/null @@ -1,195 +0,0 @@ -#!/usr/bin/env python -# -# __COPYRIGHT__ -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# - -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" - -import os -import string -import sys -import TestSCons - -python = TestSCons.python -_exe = TestSCons._exe - -test = TestSCons.TestSCons() - - - -if sys.platform == 'win32': - - test.write('mylink.py', r""" -import string -import sys -args = sys.argv[1:] -while args: - a = args[0] - if a[0] != '/': - break - args = args[1:] - if string.lower(a[:5]) == '/out:': out = a[5:] -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:5] != '#link': - outfile.write(l) -sys.exit(0) -""") - -else: - - test.write('mylink.py', r""" -import getopt -import sys -opts, args = getopt.getopt(sys.argv[1:], 'o:') -for opt, arg in opts: - if opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:5] != '#link': - outfile.write(l) -sys.exit(0) -""") - -test.write('myg77.py', r""" -import getopt -import sys -opts, args = getopt.getopt(sys.argv[1:], 'co:') -for opt, arg in opts: - if opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:4] != '#g77': - outfile.write(l) -sys.exit(0) -""") - -test.write('SConstruct', """ -env = Environment(LINK = r'%s mylink.py', - LINKFLAGS = [], - F77 = r'%s myg77.py') -env.Program(target = 'test1', source = 'test1.f') -env.Program(target = 'test2', source = 'test2.for') -env.Program(target = 'test3', source = 'test3.FOR') -env.Program(target = 'test4', source = 'test4.F') -env.Program(target = 'test5', source = 'test5.fpp') -env.Program(target = 'test6', source = 'test6.FPP') -""" % (python, python)) - -test.write('test1.f', r"""This is a .f file. -#g77 -#link -""") - -test.write('test2.for', r"""This is a .for file. -#g77 -#link -""") - -test.write('test3.FOR', r"""This is a .FOR file. -#g77 -#link -""") - -test.write('test4.F', r"""This is a .F file. -#g77 -#link -""") - -test.write('test5.fpp', r"""This is a .fpp file. -#g77 -#link -""") - -test.write('test6.FPP', r"""This is a .FPP file. -#g77 -#link -""") - -test.run(arguments = '.', stderr = None) - -test.fail_test(test.read('test1' + _exe) != "This is a .f file.\n") - -test.fail_test(test.read('test2' + _exe) != "This is a .for file.\n") - -test.fail_test(test.read('test3' + _exe) != "This is a .FOR file.\n") - -test.fail_test(test.read('test4' + _exe) != "This is a .F file.\n") - -test.fail_test(test.read('test5' + _exe) != "This is a .fpp file.\n") - -test.fail_test(test.read('test6' + _exe) != "This is a .FPP file.\n") - - - -g77 = test.detect('F77', 'g77') -FTN_LIB = TestSCons.fortran_lib - -if g77: - - test.write("wrapper.py", -"""import os -import string -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(string.join(sys.argv[1:], " ")) -""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\')) - - test.write('SConstruct', """ -foo = Environment(LIBS = %s) -f77 = foo.Dictionary('F77') -bar = foo.Copy(F77 = r'%s wrapper.py ' + f77) -foo.Program(target = 'foo', source = 'foo.f') -bar.Program(target = 'bar', source = 'bar.f') -""" % (FTN_LIB, python)) - - test.write('foo.f', r""" - PROGRAM FOO - PRINT *,'foo.f' - STOP - END -""") - - test.write('bar.f', r""" - PROGRAM BAR - PRINT *,'bar.f' - STOP - END -""") - - - test.run(arguments = 'foo' + _exe, stderr = None) - - test.run(program = test.workpath('foo'), stdout = " foo.f\n") - - test.fail_test(os.path.exists(test.workpath('wrapper.out'))) - - test.run(arguments = 'bar' + _exe) - - test.run(program = test.workpath('bar'), stdout = " bar.f\n") - - test.fail_test(test.read('wrapper.out') != "wrapper.py\n") - -test.pass_test() diff --git a/test/F77FLAGS.py b/test/F77FLAGS.py deleted file mode 100644 index 027a02f..0000000 --- a/test/F77FLAGS.py +++ /dev/null @@ -1,198 +0,0 @@ -#!/usr/bin/env python -# -# __COPYRIGHT__ -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# - -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" - -import os -import string -import sys -import TestSCons - -python = TestSCons.python - -test = TestSCons.TestSCons() -_exe = TestSCons._exe - -if sys.platform == 'win32': - - test.write('mylink.py', r""" -import string -import sys -args = sys.argv[1:] -while args: - a = args[0] - if a[0] != '/': - break - args = args[1:] - if string.lower(a[:5]) == '/out:': out = a[5:] -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:5] != '#link': - outfile.write(l) -sys.exit(0) -""") - -else: - - test.write('mylink.py', r""" -import getopt -import sys -opts, args = getopt.getopt(sys.argv[1:], 'o:') -for opt, arg in opts: - if opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:5] != '#link': - outfile.write(l) -sys.exit(0) -""") - -test.write('myg77.py', r""" -import getopt -import sys -opts, args = getopt.getopt(sys.argv[1:], 'co:x') -optstring = '' -for opt, arg in opts: - if opt == '-o': out = arg - else: optstring = optstring + ' ' + opt -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -outfile.write(optstring + "\n") -for l in infile.readlines(): - if l[:4] != '#g77': - outfile.write(l) -sys.exit(0) -""") - - - -test.write('SConstruct', """ -env = Environment(LINK = r'%s mylink.py', - LINKFLAGS = [], - F77 = r'%s myg77.py', F77FLAGS = '-x') -env.Program(target = 'test1', source = 'test1.f') -env.Program(target = 'test2', source = 'test2.for') -env.Program(target = 'test3', source = 'test3.FOR') -env.Program(target = 'test4', source = 'test4.F') -env.Program(target = 'test5', source = 'test5.fpp') -env.Program(target = 'test6', source = 'test6.FPP') -""" % (python, python)) - -test.write('test1.f', r"""This is a .f file. -#g77 -#link -""") - -test.write('test2.for', r"""This is a .for file. -#g77 -#link -""") - -test.write('test3.FOR', r"""This is a .FOR file. -#g77 -#link -""") - -test.write('test4.F', r"""This is a .F file. -#g77 -#link -""") - -test.write('test5.fpp', r"""This is a .fpp file. -#g77 -#link -""") - -test.write('test6.FPP', r"""This is a .FPP file. -#g77 -#link -""") - -test.run(arguments = '.', stderr = None) - -test.fail_test(test.read('test1' + _exe) != " -x -c\nThis is a .f file.\n") - -test.fail_test(test.read('test2' + _exe) != " -x -c\nThis is a .for file.\n") - -test.fail_test(test.read('test3' + _exe) != " -x -c\nThis is a .FOR file.\n") - -test.fail_test(test.read('test4' + _exe) != " -x -c\nThis is a .F file.\n") - -test.fail_test(test.read('test5' + _exe) != " -x -c\nThis is a .fpp file.\n") - -test.fail_test(test.read('test6' + _exe) != " -x -c\nThis is a .FPP file.\n") - - - -g77 = test.detect('F77', 'g77') -FTN_LIB = TestSCons.fortran_lib - -if g77: - - test.write("wrapper.py", -"""import os -import string -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(string.join(sys.argv[1:], " ")) -""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\')) - - test.write('SConstruct', """ -foo = Environment(LIBS = %s) -f77 = foo.Dictionary('F77') -bar = foo.Copy(F77 = r'%s wrapper.py ' + f77, F77FLAGS = '-Ix') -foo.Program(target = 'foo', source = 'foo.f') -bar.Program(target = 'bar', source = 'bar.f') -""" % (FTN_LIB, python)) - - test.write('foo.f', r""" - PROGRAM FOO - PRINT *,'foo.f' - STOP - END -""") - - test.write('bar.f', r""" - PROGRAM BAR - PRINT *,'bar.f' - STOP - END -""") - - - test.run(arguments = 'foo' + _exe, stderr = None) - - test.run(program = test.workpath('foo'), stdout = " foo.f\n") - - test.fail_test(os.path.exists(test.workpath('wrapper.out'))) - - test.run(arguments = 'bar' + _exe) - - test.run(program = test.workpath('bar'), stdout = " bar.f\n") - - test.fail_test(test.read('wrapper.out') != "wrapper.py\n") - -test.pass_test() diff --git a/test/F77PATH.py b/test/F77PATH.py deleted file mode 100644 index 340c321..0000000 --- a/test/F77PATH.py +++ /dev/null @@ -1,203 +0,0 @@ -#!/usr/bin/env python -# -# __COPYRIGHT__ -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# - -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" - -import os -import sys -import TestSCons - -_exe = TestSCons._exe -FTN_LIB = TestSCons.fortran_lib - -prog = 'prog' + _exe -subdir_prog = os.path.join('subdir', 'prog' + _exe) -variant_prog = os.path.join('variant', 'prog' + _exe) - -args = prog + ' ' + subdir_prog + ' ' + variant_prog - -test = TestSCons.TestSCons() - -if not test.detect('F77', 'g77'): - test.pass_test() - -test.subdir('include', 'subdir', ['subdir', 'include'], 'inc2') - -test.write('SConstruct', """ -env = Environment(F77PATH = ['$FOO'], LIBS = %s, FOO='include') -obj = env.Object(target='foobar/prog', source='subdir/prog.f') -env.Program(target='prog', source=obj) -SConscript('subdir/SConscript', "env") - -BuildDir('variant', 'subdir', 0) -include = Dir('include') -env = Environment(F77PATH=[include], LIBS = %s) -SConscript('variant/SConscript', "env") -""" % (FTN_LIB, FTN_LIB)) - -test.write(['subdir', 'SConscript'], -""" -Import("env") -env.Program(target='prog', source='prog.f') -""") - -test.write(['include', 'foo.f'], -r""" - PRINT *, 'include/foo.f 1' - INCLUDE 'bar.f' -""") - -test.write(['include', 'bar.f'], -r""" - PRINT *, 'include/bar.f 1' -""") - -test.write(['subdir', 'prog.f'], -r""" - PROGRAM PROG - PRINT *, 'subdir/prog.f' - include 'foo.f' - STOP - END -""") - -test.write(['subdir', 'include', 'foo.f'], -r""" - PRINT *, 'subdir/include/foo.f 1' - INCLUDE 'bar.f' -""") - -test.write(['subdir', 'include', 'bar.f'], -r""" - PRINT *, 'subdir/include/bar.f 1' -""") - - - -test.run(arguments = args) - -test.run(program = test.workpath(prog), - stdout = " subdir/prog.f\n include/foo.f 1\n include/bar.f 1\n") - -test.run(program = test.workpath(subdir_prog), - stdout = " subdir/prog.f\n subdir/include/foo.f 1\n subdir/include/bar.f 1\n") - -test.run(program = test.workpath(variant_prog), - stdout = " subdir/prog.f\n include/foo.f 1\n include/bar.f 1\n") - -# Make sure we didn't duplicate the source file in the variant subdirectory. -test.fail_test(os.path.exists(test.workpath('variant', 'prog.f'))) - -test.up_to_date(arguments = args) - -test.write(['include', 'foo.f'], -r""" - PRINT *, 'include/foo.f 2' - INCLUDE 'bar.f' -""") - -test.run(arguments = args) - -test.run(program = test.workpath(prog), - stdout = " subdir/prog.f\n include/foo.f 2\n include/bar.f 1\n") - -test.run(program = test.workpath(subdir_prog), - stdout = " subdir/prog.f\n subdir/include/foo.f 1\n subdir/include/bar.f 1\n") - -test.run(program = test.workpath(variant_prog), - stdout = " subdir/prog.f\n include/foo.f 2\n include/bar.f 1\n") - -# Make sure we didn't duplicate the source file in the variant subdirectory. -test.fail_test(os.path.exists(test.workpath('variant', 'prog.f'))) - -test.up_to_date(arguments = args) - -# -test.write(['include', 'bar.f'], -r""" - PRINT *, 'include/bar.f 2' -""") - -test.run(arguments = args) - -test.run(program = test.workpath(prog), - stdout = " subdir/prog.f\n include/foo.f 2\n include/bar.f 2\n") - -test.run(program = test.workpath(subdir_prog), - stdout = " subdir/prog.f\n subdir/include/foo.f 1\n subdir/include/bar.f 1\n") - -test.run(program = test.workpath(variant_prog), - stdout = " subdir/prog.f\n include/foo.f 2\n include/bar.f 2\n") - -# Make sure we didn't duplicate the source file in the variant subdirectory. -test.fail_test(os.path.exists(test.workpath('variant', 'prog.f'))) - -test.up_to_date(arguments = args) - -# Change F77PATH and make sure we don't rebuild because of it. -test.write('SConstruct', """ -env = Environment(F77PATH = Split('inc2 include'), LIBS = %s) -obj = env.Object(target='foobar/prog', source='subdir/prog.f') -env.Program(target='prog', source=obj) -SConscript('subdir/SConscript', "env") - -BuildDir('variant', 'subdir', 0) -include = Dir('include') -env = Environment(F77PATH=['inc2', include], LIBS = %s) -SConscript('variant/SConscript', "env") -""" % (FTN_LIB, FTN_LIB)) - -test.up_to_date(arguments = args) - -# -test.write(['inc2', 'foo.f'], -r""" - PRINT *, 'inc2/foo.f 1' - INCLUDE 'bar.f' -""") - -test.run(arguments = args) - -test.run(program = test.workpath(prog), - stdout = " subdir/prog.f\n inc2/foo.f 1\n include/bar.f 2\n") - -test.run(program = test.workpath(subdir_prog), - stdout = " subdir/prog.f\n subdir/include/foo.f 1\n subdir/include/bar.f 1\n") - -test.run(program = test.workpath(variant_prog), - stdout = " subdir/prog.f\n include/foo.f 2\n include/bar.f 2\n") - -test.up_to_date(arguments = args) - -# Check that a null-string F77PATH doesn't blow up. -test.write('SConstruct', """ -env = Environment(F77PATH = '', LIBS = %s) -env.Library('foo', source = 'empty.f') -""" % FTN_LIB) - -test.write('empty.f', '') - -test.run(arguments = '.') - -test.pass_test() diff --git a/test/FORTRANSUFFIXES.py b/test/FORTRANSUFFIXES.py deleted file mode 100644 index c5047f7..0000000 --- a/test/FORTRANSUFFIXES.py +++ /dev/null @@ -1,160 +0,0 @@ -#!/usr/bin/env python -# -# __COPYRIGHT__ -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# - -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" - -""" -Test the ability to scan additional filesuffixes added to $FORTRANSUFFIXES. -""" - -import TestSCons - -python = TestSCons.python - -test = TestSCons.TestSCons() - -test.write('myfc.py', r""" -import string -import sys -def do_file(outf, inf): - for line in open(inf, 'rb').readlines(): - if line[:15] == " INCLUDE '": - do_file(outf, line[15:-2]) - else: - outf.write(line) -outf = open(sys.argv[1], 'wb') -for f in sys.argv[2:]: - do_file(outf, f) -sys.exit(0) -""") - -test.write('SConstruct', """ -env = Environment(F77PATH = ['.'], - F77 = r'%s myfc.py', - F77FLAGS = [], - F77COM = '$F77 $TARGET $SOURCES', - OBJSUFFIX = '.o') -env.Append(FORTRANSUFFIXES = ['.x']) -env.Object(target = 'test1', source = 'test1.f') -env.InstallAs('test1_f', 'test1.f') -env.InstallAs('test1_h', 'test1.h') -env.InstallAs('test1_x', 'test1.x') -""" % (python,)) - -test.write('test1.f', """\ - test1.f 1 - INCLUDE 'test1.h' - INCLUDE 'test1.x' -""") - -test.write('test1.h', """\ - test1.h 1 - INCLUDE 'foo.h' -""") - -test.write('test1.x', """\ - test1.x 1 - INCLUDE 'foo.h' -""") - -test.write('foo.h', """\ - foo.h 1 -""") - -test.run(arguments='.', stdout=test.wrap_stdout("""\ -%s myfc.py test1.o test1.f -Install file: "test1.f" as "test1_f" -Install file: "test1.h" as "test1_h" -Install file: "test1.x" as "test1_x" -""" % (python,))) - -test.must_match('test1.o', """\ - test1.f 1 - test1.h 1 - foo.h 1 - test1.x 1 - foo.h 1 -""") - -test.up_to_date(arguments='.') - -test.write('foo.h', """\ - foo.h 2 -""") - -test.run(arguments='.', stdout=test.wrap_stdout("""\ -%s myfc.py test1.o test1.f -""" % (python,))) - -test.must_match('test1.o', """\ - test1.f 1 - test1.h 1 - foo.h 2 - test1.x 1 - foo.h 2 -""") - -test.up_to_date(arguments='.') - -test.write('test1.x', """\ - test1.x 2 - INCLUDE 'foo.h' -""") - -test.run(arguments='.', stdout=test.wrap_stdout("""\ -%s myfc.py test1.o test1.f -Install file: "test1.x" as "test1_x" -""" % (python,))) - -test.must_match('test1.o', """\ - test1.f 1 - test1.h 1 - foo.h 2 - test1.x 2 - foo.h 2 -""") - -test.up_to_date(arguments='.') - -test.write('test1.h', """\ - test1.h 2 - INCLUDE 'foo.h' -""") - -test.run(arguments='.', stdout=test.wrap_stdout("""\ -%s myfc.py test1.o test1.f -Install file: "test1.h" as "test1_h" -""" % (python,))) - -test.must_match('test1.o', """\ - test1.f 1 - test1.h 2 - foo.h 2 - test1.x 2 - foo.h 2 -""") - -test.up_to_date(arguments='.') - -test.pass_test() diff --git a/test/SHF77.py b/test/SHF77.py deleted file mode 100644 index 24ab0ec..0000000 --- a/test/SHF77.py +++ /dev/null @@ -1,148 +0,0 @@ -#!/usr/bin/env python -# -# __COPYRIGHT__ -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# - -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" - -import os -import string -import sys -import TestSCons - -python = TestSCons.python -_obj = TestSCons._shobj - -test = TestSCons.TestSCons() - - - -test.write('myg77.py', r""" -import getopt -import sys -opts, args = getopt.getopt(sys.argv[1:], 'cf:o:') -for opt, arg in opts: - if opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:4] != '#g77': - outfile.write(l) -sys.exit(0) -""") - - - -test.write('SConstruct', """ -env = Environment(SHF77 = r'%s myg77.py') -env.SharedObject(target = 'test1', source = 'test1.f') -env.SharedObject(target = 'test2', source = 'test2.for') -env.SharedObject(target = 'test3', source = 'test3.FOR') -env.SharedObject(target = 'test4', source = 'test4.F') -env.SharedObject(target = 'test5', source = 'test5.fpp') -env.SharedObject(target = 'test6', source = 'test6.FPP') -""" % python) - -test.write('test1.f', r"""This is a .f file. -#g77 -""") - -test.write('test2.for', r"""This is a .for file. -#g77 -""") - -test.write('test3.FOR', r"""This is a .FOR file. -#g77 -""") - -test.write('test4.F', r"""This is a .F file. -#g77 -""") - -test.write('test5.fpp', r"""This is a .fpp file. -#g77 -""") - -test.write('test6.FPP', r"""This is a .FPP file. -#g77 -""") - -test.run(arguments = '.', stderr = None) - -test.fail_test(test.read('test1' + _obj) != "This is a .f file.\n") - -test.fail_test(test.read('test2' + _obj) != "This is a .for file.\n") - -test.fail_test(test.read('test3' + _obj) != "This is a .FOR file.\n") - -test.fail_test(test.read('test4' + _obj) != "This is a .F file.\n") - -test.fail_test(test.read('test5' + _obj) != "This is a .fpp file.\n") - -test.fail_test(test.read('test6' + _obj) != "This is a .FPP file.\n") - - - -g77 = test.detect('F77', 'g77') - -if g77: - - test.write("wrapper.py", -"""import os -import string -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(string.join(sys.argv[1:], " ")) -""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\')) - - test.write('SConstruct', """ -foo = Environment(LIBS = 'g2c') -shf77 = foo.Dictionary('SHF77') -bar = foo.Copy(SHF77 = r'%s wrapper.py ' + shf77) -foo.SharedObject(target = 'foo/foo', source = 'foo.f') -bar.SharedObject(target = 'bar/bar', source = 'bar.f') -""" % python) - - test.write('foo.f', r""" - PROGRAM FOO - PRINT *,'foo.f' - STOP - END -""") - - test.write('bar.f', r""" - PROGRAM BAR - PRINT *,'bar.f' - STOP - END -""") - - - test.run(arguments = 'foo', stderr = None) - - test.fail_test(os.path.exists(test.workpath('wrapper.out'))) - - test.run(arguments = 'bar') - - test.fail_test(test.read('wrapper.out') != "wrapper.py\n") - -test.pass_test() diff --git a/test/SHF77FLAGS.py b/test/SHF77FLAGS.py deleted file mode 100644 index 261f638..0000000 --- a/test/SHF77FLAGS.py +++ /dev/null @@ -1,160 +0,0 @@ -#!/usr/bin/env python -# -# __COPYRIGHT__ -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# - -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" - -import os -import string -import sys -import TestSCons - -python = TestSCons.python - -if sys.platform == 'win32': - _obj = '.obj' -else: - if string.find(sys.platform, 'irix') > -1: - _obj = '.o' - else: - _obj = '.os' - -test = TestSCons.TestSCons() - - - -test.write('myg77.py', r""" -import getopt -import sys -opts, args = getopt.getopt(sys.argv[1:], 'co:x') -optstring = '' -for opt, arg in opts: - if opt == '-o': out = arg - else: optstring = optstring + ' ' + opt -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -outfile.write(optstring + "\n") -for l in infile.readlines(): - if l[:4] != '#g77': - outfile.write(l) -sys.exit(0) -""") - - - -test.write('SConstruct', """ -env = Environment(LINK = r'%s mylink.py', - SHF77 = r'%s myg77.py', SHF77FLAGS = '-x') -env.SharedObject(target = 'test1', source = 'test1.f') -env.SharedObject(target = 'test2', source = 'test2.for') -env.SharedObject(target = 'test3', source = 'test3.FOR') -env.SharedObject(target = 'test4', source = 'test4.F') -env.SharedObject(target = 'test5', source = 'test5.fpp') -env.SharedObject(target = 'test6', source = 'test6.FPP') -""" % (python, python)) - -test.write('test1.f', r"""This is a .f file. -#g77 -""") - -test.write('test2.for', r"""This is a .for file. -#g77 -""") - -test.write('test3.FOR', r"""This is a .FOR file. -#g77 -""") - -test.write('test4.F', r"""This is a .F file. -#g77 -""") - -test.write('test5.fpp', r"""This is a .fpp file. -#g77 -""") - -test.write('test6.FPP', r"""This is a .FPP file. -#g77 -""") - -test.run(arguments = '.', stderr = None) - -test.fail_test(test.read('test1' + _obj) != " -x -c\nThis is a .f file.\n") - -test.fail_test(test.read('test2' + _obj) != " -x -c\nThis is a .for file.\n") - -test.fail_test(test.read('test3' + _obj) != " -x -c\nThis is a .FOR file.\n") - -test.fail_test(test.read('test4' + _obj) != " -x -c\nThis is a .F file.\n") - -test.fail_test(test.read('test5' + _obj) != " -x -c\nThis is a .fpp file.\n") - -test.fail_test(test.read('test6' + _obj) != " -x -c\nThis is a .FPP file.\n") - - - -g77 = test.detect('F77', 'g77') -FTN_LIB = TestSCons.fortran_lib - -if g77: - - test.write("wrapper.py", -"""import os -import string -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(string.join(sys.argv[1:], " ")) -""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\')) - - test.write('SConstruct', """ -foo = Environment(LIBS = %s) -shf77 = foo.Dictionary('SHF77') -bar = foo.Copy(SHF77 = r'%s wrapper.py ' + shf77, SHF77FLAGS = '-Ix') -foo.SharedLibrary(target = 'foo/foo', source = 'foo.f') -bar.SharedLibrary(target = 'bar/bar', source = 'bar.f') -""" % (FTN_LIB, python)) - - test.write('foo.f', r""" - PROGRAM FOO - PRINT *,'foo.f' - STOP - END -""") - - test.write('bar.f', r""" - PROGRAM BAR - PRINT *,'bar.f' - STOP - END -""") - - - test.run(arguments = 'foo', stderr = None) - - test.fail_test(os.path.exists(test.workpath('wrapper.out'))) - - test.run(arguments = 'bar') - - test.fail_test(test.read('wrapper.out') != "wrapper.py\n") - -test.pass_test() |
