diff options
author | Steven Knight <knight@baldmt.com> | 2008-04-19 02:11:31 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2008-04-19 02:11:31 (GMT) |
commit | 4cfc36d83282c18477cab0a5fbb1e01a5be13769 (patch) | |
tree | 6b0dbeb7be16e532a3ac980cd848458fd02dbe8b /test/Fortran | |
parent | 12ced93c8d443babcf3ba0c0a3503ed6a8fed2d9 (diff) | |
download | SCons-4cfc36d83282c18477cab0a5fbb1e01a5be13769.zip SCons-4cfc36d83282c18477cab0a5fbb1e01a5be13769.tar.gz SCons-4cfc36d83282c18477cab0a5fbb1e01a5be13769.tar.bz2 |
Merged revisions 2867-2879 via svnmerge from
http://scons.tigris.org/svn/scons/branches/core
................
r2875 | stevenknight | 2008-04-17 21:33:00 -0700 (Thu, 17 Apr 2008) | 4 lines
Fix the script that looks for uncaught KeyboardInterrupt exceptions to
expect specific numbers of these from the modules that were recently
modified to handle KeyboardInterrupt exceptions differently.
................
r2877 | stevenknight | 2008-04-18 17:31:14 -0700 (Fri, 18 Apr 2008) | 3 lines
Fix how the packaging tests look for the build packages (I hope,
we'll know once it gets through buildbot).
................
r2879 | stevenknight | 2008-04-18 18:43:56 -0700 (Fri, 18 Apr 2008) | 352 lines
Merged revisions 2777,2779-2873,2875 via svnmerge from
http://scons.tigris.org/svn/scons/branches/fortran_refactor
........
r2779 | cournape | 2008-04-14 20:52:08 -0700 (Mon, 14 Apr 2008) | 1 line
Fix tool detection in unit tests for F77 dialect.
........
r2780 | cournape | 2008-04-14 21:02:25 -0700 (Mon, 14 Apr 2008) | 1 line
Fix tool detection in unit tests for FORTRAN dialect.
........
r2781 | cournape | 2008-04-14 21:18:40 -0700 (Mon, 14 Apr 2008) | 1 line
Fix tool detection in unit tests for F90 dialect.
........
r2782 | cournape | 2008-04-14 21:32:49 -0700 (Mon, 14 Apr 2008) | 1 line
Fix tool detection in unit tests for F95 dialect.
........
r2783 | cournape | 2008-04-14 21:34:31 -0700 (Mon, 14 Apr 2008) | 1 line
Fix *F77FLAGS tool detection.
........
r2784 | cournape | 2008-04-14 21:35:15 -0700 (Mon, 14 Apr 2008) | 1 line
Do not harcode F77 compiler for unit test.
........
r2785 | cournape | 2008-04-14 21:35:48 -0700 (Mon, 14 Apr 2008) | 1 line
Do not harcode FORTRAN compiler for unit test.
........
r2786 | cournape | 2008-04-14 21:39:33 -0700 (Mon, 14 Apr 2008) | 1 line
Fix tool detection for *FORTRANFLAGS unit test.
........
r2787 | cournape | 2008-04-14 21:40:17 -0700 (Mon, 14 Apr 2008) | 1 line
Fix escaping of fc in F95 unit test.
........
r2791 | cournape | 2008-04-14 22:34:52 -0700 (Mon, 14 Apr 2008) | 1 line
Refactor emitter for all fortran dialects, such as the same function is used everywhere.
........
r2792 | cournape | 2008-04-14 22:37:20 -0700 (Mon, 14 Apr 2008) | 1 line
Add new FortranCommon python module in Tools to MANIFEST.in.
........
r2793 | cournape | 2008-04-14 22:44:28 -0700 (Mon, 14 Apr 2008) | 1 line
Add a function to create all function list generator in a dialect independant way.
........
r2794 | cournape | 2008-04-14 22:47:45 -0700 (Mon, 14 Apr 2008) | 1 line
Use dialect independant vlg creation in all fortran dialect tools.
........
r2795 | cournape | 2008-04-14 22:49:50 -0700 (Mon, 14 Apr 2008) | 1 line
Add a dialect independant function to create actions vlg.
........
r2796 | cournape | 2008-04-14 22:50:21 -0700 (Mon, 14 Apr 2008) | 1 line
Use dialect independant action vlg creator in FORTRAN dialect.
........
r2797 | cournape | 2008-04-14 22:51:44 -0700 (Mon, 14 Apr 2008) | 1 line
Use dialect independant action vlg creator in F77 dialect.
........
r2798 | cournape | 2008-04-14 22:52:00 -0700 (Mon, 14 Apr 2008) | 1 line
Use dialect independant action vlg creator in F90 dialect.
........
r2799 | cournape | 2008-04-14 22:52:20 -0700 (Mon, 14 Apr 2008) | 1 line
Use dialect independant action vlg creator in F95 dialect.
........
r2800 | cournape | 2008-04-14 22:54:18 -0700 (Mon, 14 Apr 2008) | 1 line
Add function to create all construction variables for every dialect.
........
r2801 | cournape | 2008-04-14 22:56:05 -0700 (Mon, 14 Apr 2008) | 1 line
f77 tool now uses common implementation for add_to_env.
........
r2802 | cournape | 2008-04-14 22:57:30 -0700 (Mon, 14 Apr 2008) | 1 line
f90 tool now uses common implementation for add_to_env.
........
r2803 | cournape | 2008-04-14 22:58:13 -0700 (Mon, 14 Apr 2008) | 1 line
f95 tool now uses common implementation for add_to_env.
........
r2804 | cournape | 2008-04-14 23:00:35 -0700 (Mon, 14 Apr 2008) | 1 line
fortran tool now uses common implementation for add_to_env.
........
r2805 | cournape | 2008-04-14 23:10:41 -0700 (Mon, 14 Apr 2008) | 1 line
Handle fortran sources in smart_link in a way similar to C++; we launch an exception if both C++ and fortran sources are used, because this cannot be handled easily in this scheme.
........
r2806 | cournape | 2008-04-14 23:17:54 -0700 (Mon, 14 Apr 2008) | 1 line
Use f95 specific suffix for F95 compiled unit tests (.f95 instead of .f), plus minor typo to make all F95* tests pass.
........
r2807 | cournape | 2008-04-15 00:47:59 -0700 (Tue, 15 Apr 2008) | 1 line
Refactor mylink.py generation in fortran tests.
........
r2808 | cournape | 2008-04-15 00:51:11 -0700 (Tue, 15 Apr 2008) | 1 line
Forgot to add new common.py for code shared by all fortran tests.
........
r2809 | cournape | 2008-04-15 02:08:44 -0700 (Tue, 15 Apr 2008) | 1 line
Add a F77FILESUFFIXES and F77PPFILESUFFIXES construction variable to control F77 dialect file extension.
........
r2810 | cournape | 2008-04-15 02:22:26 -0700 (Tue, 15 Apr 2008) | 1 line
Add a FORTRANFILESUFFIXES and FORTRANPPFILESUFFIXES construction variable to control FORTRAN dialect file extension.
........
r2811 | cournape | 2008-04-15 02:38:11 -0700 (Tue, 15 Apr 2008) | 1 line
Add a F90FILESUFFIXES and F90PPFILESUFFIXES construction variable to control F90 dialect file extension.
........
r2812 | cournape | 2008-04-15 02:46:31 -0700 (Tue, 15 Apr 2008) | 1 line
Add a F95FILESUFFIXES and F95PPFILESUFFIXES construction variable to control F95 dialect file extension.
........
r2813 | cournape | 2008-04-15 04:23:25 -0700 (Tue, 15 Apr 2008) | 1 line
Add tool list initialization for unit test.
........
r2814 | cournape | 2008-04-15 05:16:28 -0700 (Tue, 15 Apr 2008) | 1 line
Remove use of variable list generator in fortran support. FORTRAN is the default dialect, and its cvar are created by every dialect tool.
........
r2815 | cournape | 2008-04-15 05:18:00 -0700 (Tue, 15 Apr 2008) | 1 line
Fix FORTRAN* and SHFORTRAN* tests.
........
r2816 | cournape | 2008-04-15 05:38:46 -0700 (Tue, 15 Apr 2008) | 1 line
Forgot to generate F95* cvar in f95 tool.
........
r2819 | cournape | 2008-04-15 15:14:58 -0700 (Tue, 15 Apr 2008) | 1 line
Put cvar construction add_to_env func in FortranCommon for all dialect; all dialect cvar are always created for all tools.
........
r2820 | cournape | 2008-04-15 15:34:32 -0700 (Tue, 15 Apr 2008) | 1 line
Fix unit tests for F77* and SHF77* cvar.
........
r2821 | cournape | 2008-04-15 15:38:26 -0700 (Tue, 15 Apr 2008) | 1 line
Fix unit tests for F90* and SHF90* cvar.
........
r2822 | cournape | 2008-04-15 15:43:47 -0700 (Tue, 15 Apr 2008) | 1 line
Fix unit tests for F95* and SHF95* cvar.
........
r2823 | cournape | 2008-04-15 15:50:41 -0700 (Tue, 15 Apr 2008) | 1 line
Fix compiler name setting in dialect fortran tools.
........
r2824 | cournape | 2008-04-15 15:56:57 -0700 (Tue, 15 Apr 2008) | 1 line
Fix -fPIC for g77 tool.
........
r2825 | cournape | 2008-04-15 16:07:03 -0700 (Tue, 15 Apr 2008) | 1 line
Set compiler name in g77 tool for supported dialects.
........
r2826 | cournape | 2008-04-15 18:10:18 -0700 (Tue, 15 Apr 2008) | 1 line
Fix F77PATH unit test.
........
r2827 | cournape | 2008-04-15 18:11:58 -0700 (Tue, 15 Apr 2008) | 1 line
Fix typo in f90.py tool.
........
r2828 | cournape | 2008-04-15 18:16:22 -0700 (Tue, 15 Apr 2008) | 1 line
Adapt gfortran tool to new fortran support.
........
r2829 | cournape | 2008-04-15 18:22:44 -0700 (Tue, 15 Apr 2008) | 1 line
Adapt ifort tool to new fortran support.
........
r2830 | cournape | 2008-04-15 18:28:50 -0700 (Tue, 15 Apr 2008) | 1 line
Update cvar set by gfortran tool in xml doc.
........
r2831 | cournape | 2008-04-15 18:31:43 -0700 (Tue, 15 Apr 2008) | 1 line
Update ifort tool, and add cvar doc in xml doc.
........
r2832 | cournape | 2008-04-15 18:40:51 -0700 (Tue, 15 Apr 2008) | 1 line
Change fortran tool search order on gnu platforms: first search gfortran, then g77, etc...
........
r2833 | cournape | 2008-04-15 18:42:04 -0700 (Tue, 15 Apr 2008) | 1 line
Add Sun f77 tool sunf77.
........
r2834 | cournape | 2008-04-15 18:43:40 -0700 (Tue, 15 Apr 2008) | 1 line
Fix typo in sunf77 doc.
........
r2835 | cournape | 2008-04-15 18:46:38 -0700 (Tue, 15 Apr 2008) | 1 line
Add Sun f90 tool sunf90.
........
r2836 | cournape | 2008-04-15 18:47:39 -0700 (Tue, 15 Apr 2008) | 1 line
Add Sun f95 tool sunf95.
........
r2837 | cournape | 2008-04-15 18:50:04 -0700 (Tue, 15 Apr 2008) | 1 line
Change tool order for fortran compilers on sun OS: use sun specific compilers first, and add gfortran to the list.
........
r2838 | cournape | 2008-04-15 18:50:48 -0700 (Tue, 15 Apr 2008) | 1 line
Change tool order on win32 for fortran compilers: use gfortran before g77.
........
r2839 | cournape | 2008-04-15 18:51:23 -0700 (Tue, 15 Apr 2008) | 1 line
Use gfortran first if available on mac os X.
........
r2840 | cournape | 2008-04-15 18:52:09 -0700 (Tue, 15 Apr 2008) | 1 line
Add sun fortran compilers to the tool list in the manpage.
........
r2841 | cournape | 2008-04-15 18:58:55 -0700 (Tue, 15 Apr 2008) | 1 line
Add new sun fortran compilers tools to the MANIFEST.in
........
r2842 | cournape | 2008-04-15 19:07:18 -0700 (Tue, 15 Apr 2008) | 1 line
Fix typo for sun fortran compiler pic flags.
........
r2843 | cournape | 2008-04-15 20:07:32 -0700 (Tue, 15 Apr 2008) | 1 line
Fix order issue in one f90 unit test.
........
r2844 | cournape | 2008-04-15 20:16:21 -0700 (Tue, 15 Apr 2008) | 1 line
Fix order issues in one f95 unit test.
........
r2845 | cournape | 2008-04-15 23:47:07 -0700 (Tue, 15 Apr 2008) | 1 line
Add fortran specific prefix/suffix include flags: this is useful when e.g. mixing VS and mingw fortran compiler.
........
r2846 | cournape | 2008-04-16 00:27:38 -0700 (Wed, 16 Apr 2008) | 1 line
Set stderr=None on solaris for fortran unit tests because f77 always put junk on stderr.
........
r2847 | cournape | 2008-04-16 00:47:04 -0700 (Wed, 16 Apr 2008) | 1 line
Do not use fortran_lib anymore in FORTRANPATH unit test.
........
r2848 | cournape | 2008-04-16 01:16:23 -0700 (Wed, 16 Apr 2008) | 1 line
Set stderr to None on solaris for FORTRANPATH test.
........
r2849 | cournape | 2008-04-16 03:50:35 -0700 (Wed, 16 Apr 2008) | 1 line
Fix sun fortran compilers detection.
........
r2852 | cournape | 2008-04-16 16:57:44 -0700 (Wed, 16 Apr 2008) | 1 line
Add a shobj_ variable for shared object preffix (needed for tests on solaris).
........
r2853 | cournape | 2008-04-16 17:15:52 -0700 (Wed, 16 Apr 2008) | 1 line
Fix some typo for shobj_ in qmtest.
........
r2854 | cournape | 2008-04-16 17:17:43 -0700 (Wed, 16 Apr 2008) | 1 line
Handle shared object prefix in SHFORTRAN test + KPIC flag for solaris.
........
r2855 | cournape | 2008-04-16 17:28:59 -0700 (Wed, 16 Apr 2008) | 1 line
Add shobj_prefix for all platforms.
........
r2856 | cournape | 2008-04-16 17:33:15 -0700 (Wed, 16 Apr 2008) | 1 line
Fix shared object fortran unit test for solaris.
........
r2857 | cournape | 2008-04-16 17:37:14 -0700 (Wed, 16 Apr 2008) | 1 line
Fix shared object prefix to make fortran unit test pass on solaris.
........
r2858 | cournape | 2008-04-16 17:38:28 -0700 (Wed, 16 Apr 2008) | 1 line
Use TestSCons facility to get shared object suffix.
........
r2859 | cournape | 2008-04-16 17:42:50 -0700 (Wed, 16 Apr 2008) | 1 line
Handl shared object prefix in fortran unit test for solaris.
........
r2860 | cournape | 2008-04-16 17:54:27 -0700 (Wed, 16 Apr 2008) | 1 line
Handle shared object prefix in some fortran unit test.
........
r2861 | cournape | 2008-04-16 17:55:58 -0700 (Wed, 16 Apr 2008) | 1 line
Fix typo: put shared object prefix at wrong place.
........
r2862 | cournape | 2008-04-16 18:00:42 -0700 (Wed, 16 Apr 2008) | 1 line
More fix for fortran unit tests on solaris: handle -KPIC flag in wrappers.
........
r2863 | cournape | 2008-04-16 18:03:00 -0700 (Wed, 16 Apr 2008) | 1 line
Fix SHF77FLAGS test on solaris.
........
r2864 | cournape | 2008-04-16 18:07:39 -0700 (Wed, 16 Apr 2008) | 1 line
More fix for f90 unit test on solaris.
........
r2865 | cournape | 2008-04-16 18:08:58 -0700 (Wed, 16 Apr 2008) | 1 line
Fix f95 unit test on solaris.
........
r2867 | cournape | 2008-04-16 18:38:17 -0700 (Wed, 16 Apr 2008) | 1 line
More fortran unit test fixes for solaris.
........
r2869 | cournape | 2008-04-17 06:42:25 -0700 (Thu, 17 Apr 2008) | 1 line
Fix SHFORTRAN definition issues for g77, gfortran, ifort and ifl.
........
r2870 | cournape | 2008-04-17 06:43:24 -0700 (Thu, 17 Apr 2008) | 1 line
Fix SHFORTRAN definition issues for sun fortran compilers.
........
r2871 | stevenknight | 2008-04-17 18:16:55 -0700 (Thu, 17 Apr 2008) | 3 lines
Test SH{F77,FORTRAN}FLAGS.py by appending the custom test flags,
not overwriting the -fPIC value that the tools now initialize.
........
r2872 | stevenknight | 2008-04-17 18:22:24 -0700 (Thu, 17 Apr 2008) | 4 lines
Fix the SH{F90,F95}FLAGS.py test scripts as well by appending our custom
values to the SH*FLAGS values, so we don't overwrite the -fPIC value
necessary for building on 64-bit Linux systems.
........
r2873 | stevenknight | 2008-04-17 19:08:43 -0700 (Thu, 17 Apr 2008) | 2 lines
Remove left-over fortran.* lines.
........
................
Diffstat (limited to 'test/Fortran')
41 files changed, 1249 insertions, 1445 deletions
diff --git a/test/Fortran/F77.py b/test/Fortran/F77.py index 536483d..0f28b7e 100644 --- a/test/Fortran/F77.py +++ b/test/Fortran/F77.py @@ -29,48 +29,14 @@ import string import sys import TestSCons +from common import write_fake_link + _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) -""") +write_fake_link(test) test.write('myfortran.py', r""" import getopt @@ -102,23 +68,6 @@ env.Program(target = 'test07', source = 'test07.fpp') env.Program(target = 'test08', source = 'test08.FPP') env.Program(target = 'test09', source = 'test09.f77') env.Program(target = 'test10', source = 'test10.F77') -env.Program(target = 'test11', source = 'test11.f90') -env.Program(target = 'test12', source = 'test12.F90') -env.Program(target = 'test13', source = 'test13.f95') -env.Program(target = 'test14', source = 'test14.F95') -env2 = Environment(LINK = r'%(_python_)s mylink.py', - LINKFLAGS = [], - F77 = r'%(_python_)s myfortran.py g77') -env2.Program(target = 'test21', source = 'test21.f') -env2.Program(target = 'test22', source = 'test22.F') -env2.Program(target = 'test23', source = 'test23.for') -env2.Program(target = 'test24', source = 'test24.FOR') -env2.Program(target = 'test25', source = 'test25.ftn') -env2.Program(target = 'test26', source = 'test26.FTN') -env2.Program(target = 'test27', source = 'test27.fpp') -env2.Program(target = 'test28', source = 'test28.FPP') -env2.Program(target = 'test29', source = 'test29.f77') -env2.Program(target = 'test30', source = 'test30.F77') """ % locals()) test.write('test01.f', "This is a .f file.\n#link\n#fortran\n") @@ -131,21 +80,6 @@ test.write('test07.fpp', "This is a .fpp file.\n#link\n#fortran\n") test.write('test08.FPP', "This is a .FPP file.\n#link\n#fortran\n") test.write('test09.f77', "This is a .f77 file.\n#link\n#g77\n") test.write('test10.F77', "This is a .F77 file.\n#link\n#g77\n") -test.write('test11.f90', "This is a .f90 file.\n#link\n#fortran\n") -test.write('test12.F90', "This is a .F90 file.\n#link\n#fortran\n") -test.write('test13.f95', "This is a .f95 file.\n#link\n#fortran\n") -test.write('test14.F95', "This is a .F95 file.\n#link\n#fortran\n") - -test.write('test21.f', "This is a .f file.\n#link\n#g77\n") -test.write('test22.F', "This is a .F file.\n#link\n#g77\n") -test.write('test23.for', "This is a .for file.\n#link\n#g77\n") -test.write('test24.FOR', "This is a .FOR file.\n#link\n#g77\n") -test.write('test25.ftn', "This is a .ftn file.\n#link\n#g77\n") -test.write('test26.FTN', "This is a .FTN file.\n#link\n#g77\n") -test.write('test27.fpp', "This is a .fpp file.\n#link\n#g77\n") -test.write('test28.FPP', "This is a .FPP file.\n#link\n#g77\n") -test.write('test29.f77', "This is a .f77 file.\n#link\n#g77\n") -test.write('test30.F77', "This is a .F77 file.\n#link\n#g77\n") test.run(arguments = '.', stderr = None) @@ -159,28 +93,11 @@ test.must_match('test07' + _exe, "This is a .fpp file.\n") test.must_match('test08' + _exe, "This is a .FPP file.\n") test.must_match('test09' + _exe, "This is a .f77 file.\n") test.must_match('test10' + _exe, "This is a .F77 file.\n") -test.must_match('test11' + _exe, "This is a .f90 file.\n") -test.must_match('test12' + _exe, "This is a .F90 file.\n") -test.must_match('test13' + _exe, "This is a .f95 file.\n") -test.must_match('test14' + _exe, "This is a .F95 file.\n") - -test.must_match('test21' + _exe, "This is a .f file.\n") -test.must_match('test22' + _exe, "This is a .F file.\n") -test.must_match('test23' + _exe, "This is a .for file.\n") -test.must_match('test24' + _exe, "This is a .FOR file.\n") -test.must_match('test25' + _exe, "This is a .ftn file.\n") -test.must_match('test26' + _exe, "This is a .FTN file.\n") -test.must_match('test27' + _exe, "This is a .fpp file.\n") -test.must_match('test28' + _exe, "This is a .FPP file.\n") -test.must_match('test29' + _exe, "This is a .f77 file.\n") -test.must_match('test30' + _exe, "This is a .F77 file.\n") - - -g77 = test.detect('F77', 'g77') -FTN_LIB = TestSCons.fortran_lib +fc = 'f77' +f77 = test.detect_tool(fc) -if g77: +if f77: test.write("wrapper.py", """import os @@ -191,7 +108,7 @@ os.system(string.join(sys.argv[1:], " ")) """ % string.replace(test.workpath('wrapper.out'), '\\', '\\\\')) test.write('SConstruct', """ -foo = Environment(LIBS = %(FTN_LIB)s) +foo = Environment(F77 = '%(fc)s', tools = ['default', 'f77'], F77FILESUFFIXES = ['.f']) f77 = foo.Dictionary('F77') bar = foo.Clone(F77 = r'%(_python_)s wrapper.py ' + f77) foo.Program(target = 'foo', source = 'foo.f') @@ -219,7 +136,11 @@ bar.Program(target = 'bar', source = 'bar.f') test.must_not_exist('wrapper.out') - test.run(arguments = 'bar' + _exe) + import sys + if sys.platform[:5] == 'sunos': + test.run(arguments = 'bar' + _exe, stderr = None) + else: + test.run(arguments = 'bar' + _exe) test.run(program = test.workpath('bar'), stdout = " bar.f\n") diff --git a/test/Fortran/F77COM.py b/test/Fortran/F77COM.py index c566d88..5456502 100644 --- a/test/Fortran/F77COM.py +++ b/test/Fortran/F77COM.py @@ -29,48 +29,14 @@ import string import sys import TestSCons +from common import write_fake_link + _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) -""") +write_fake_link(test) test.write('myfortran.py', r""" import sys @@ -100,24 +66,6 @@ env.Program(target = 'test07', source = 'test07.fpp') env.Program(target = 'test08', source = 'test08.FPP') env.Program(target = 'test09', source = 'test09.f77') env.Program(target = 'test10', source = 'test10.F77') -env.Program(target = 'test11', source = 'test11.f90') -env.Program(target = 'test12', source = 'test12.F90') -env.Program(target = 'test13', source = 'test13.f95') -env.Program(target = 'test14', source = 'test14.F95') -env2 = Environment(LINK = r'%(_python_)s mylink.py', - LINKFLAGS = [], - F77COM = r'%(_python_)s myfortran.py f77 $TARGET $SOURCES', - F77PPCOM = r'%(_python_)s myfortran.py f77pp $TARGET $SOURCES') -env2.Program(target = 'test21', source = 'test21.f') -env2.Program(target = 'test22', source = 'test22.F') -env2.Program(target = 'test23', source = 'test23.for') -env2.Program(target = 'test24', source = 'test24.FOR') -env2.Program(target = 'test25', source = 'test25.ftn') -env2.Program(target = 'test26', source = 'test26.FTN') -env2.Program(target = 'test27', source = 'test27.fpp') -env2.Program(target = 'test28', source = 'test28.FPP') -env2.Program(target = 'test29', source = 'test29.f77') -env2.Program(target = 'test30', source = 'test30.F77') """ % locals()) test.write('test01.f', "This is a .f file.\n#link\n#fortran\n") @@ -130,21 +78,6 @@ test.write('test07.fpp', "This is a .fpp file.\n#link\n#fortranpp\n") test.write('test08.FPP', "This is a .FPP file.\n#link\n#fortranpp\n") test.write('test09.f77', "This is a .f77 file.\n#link\n#f77\n") test.write('test10.F77', "This is a .F77 file.\n#link\n#f77pp\n") -test.write('test11.f90', "This is a .f90 file.\n#link\n#fortran\n") -test.write('test12.F90', "This is a .F90 file.\n#link\n#fortranpp\n") -test.write('test13.f95', "This is a .f95 file.\n#link\n#fortran\n") -test.write('test14.F95', "This is a .F95 file.\n#link\n#fortranpp\n") - -test.write('test21.f', "This is a .f file.\n#link\n#f77\n") -test.write('test22.F', "This is a .F file.\n#link\n#f77pp\n") -test.write('test23.for', "This is a .for file.\n#link\n#f77\n") -test.write('test24.FOR', "This is a .FOR file.\n#link\n#f77pp\n") -test.write('test25.ftn', "This is a .ftn file.\n#link\n#f77\n") -test.write('test26.FTN', "This is a .FTN file.\n#link\n#f77pp\n") -test.write('test27.fpp', "This is a .fpp file.\n#link\n#f77pp\n") -test.write('test28.FPP', "This is a .FPP file.\n#link\n#f77pp\n") -test.write('test29.f77', "This is a .f77 file.\n#link\n#f77\n") -test.write('test30.F77', "This is a .F77 file.\n#link\n#f77pp\n") test.run(arguments = '.', stderr = None) @@ -158,20 +91,5 @@ test.must_match('test07' + _exe, "This is a .fpp file.\n") test.must_match('test08' + _exe, "This is a .FPP file.\n") test.must_match('test09' + _exe, "This is a .f77 file.\n") test.must_match('test10' + _exe, "This is a .F77 file.\n") -test.must_match('test11' + _exe, "This is a .f90 file.\n") -test.must_match('test12' + _exe, "This is a .F90 file.\n") -test.must_match('test13' + _exe, "This is a .f95 file.\n") -test.must_match('test14' + _exe, "This is a .F95 file.\n") - -test.must_match('test21' + _exe, "This is a .f file.\n") -test.must_match('test22' + _exe, "This is a .F file.\n") -test.must_match('test23' + _exe, "This is a .for file.\n") -test.must_match('test24' + _exe, "This is a .FOR file.\n") -test.must_match('test25' + _exe, "This is a .ftn file.\n") -test.must_match('test26' + _exe, "This is a .FTN file.\n") -test.must_match('test27' + _exe, "This is a .fpp file.\n") -test.must_match('test28' + _exe, "This is a .FPP file.\n") -test.must_match('test29' + _exe, "This is a .f77 file.\n") -test.must_match('test30' + _exe, "This is a .F77 file.\n") test.pass_test() diff --git a/test/Fortran/F77COMSTR.py b/test/Fortran/F77COMSTR.py index b8a5e44..af0cb4d 100644 --- a/test/Fortran/F77COMSTR.py +++ b/test/Fortran/F77COMSTR.py @@ -57,50 +57,18 @@ env = Environment(F77COM = r'%(_python_)s myfc.py f77 $TARGET $SOURCES', F77PPCOM = r'%(_python_)s myfc.py f77pp $TARGET $SOURCES', F77PPCOMSTR = 'Building f77pp $TARGET from $SOURCES', OBJSUFFIX='.obj') -env.Object(source = 'test01.f') -env.Object(source = 'test02.F') -env.Object(source = 'test03.for') -env.Object(source = 'test04.FOR') -env.Object(source = 'test05.ftn') -env.Object(source = 'test06.FTN') -env.Object(source = 'test07.fpp') -env.Object(source = 'test08.FPP') env.Object(source = 'test09.f77') env.Object(source = 'test10.F77') """ % locals()) -test.write('test01.f', "A .f file.\n#f77\n") -test.write('test02.F', "A .F file.\n#%s\n" % f77pp) -test.write('test03.for', "A .for file.\n#f77\n") -test.write('test04.FOR', "A .FOR file.\n#%s\n" % f77pp) -test.write('test05.ftn', "A .ftn file.\n#f77\n") -test.write('test06.FTN', "A .FTN file.\n#%s\n" % f77pp) -test.write('test07.fpp', "A .fpp file.\n#f77pp\n") -test.write('test08.FPP', "A .FPP file.\n#f77pp\n") test.write('test09.f77', "A .f77 file.\n#f77\n") test.write('test10.F77', "A .F77 file.\n#%s\n" % f77pp) test.run(stdout = test.wrap_stdout("""\ -Building f77 test01.obj from test01.f -Building %(f77pp)s test02.obj from test02.F -Building f77 test03.obj from test03.for -Building %(f77pp)s test04.obj from test04.FOR -Building f77 test05.obj from test05.ftn -Building %(f77pp)s test06.obj from test06.FTN -Building f77pp test07.obj from test07.fpp -Building f77pp test08.obj from test08.FPP Building f77 test09.obj from test09.f77 Building %(f77pp)s test10.obj from test10.F77 """ % locals())) -test.must_match('test01.obj', "A .f file.\n") -test.must_match('test02.obj', "A .F file.\n") -test.must_match('test03.obj', "A .for file.\n") -test.must_match('test04.obj', "A .FOR file.\n") -test.must_match('test05.obj', "A .ftn file.\n") -test.must_match('test06.obj', "A .FTN file.\n") -test.must_match('test07.obj', "A .fpp file.\n") -test.must_match('test08.obj', "A .FPP file.\n") test.must_match('test09.obj', "A .f77 file.\n") test.must_match('test10.obj', "A .F77 file.\n") diff --git a/test/Fortran/F77FILESUFFIXES.py b/test/Fortran/F77FILESUFFIXES.py new file mode 100644 index 0000000..fedbb53 --- /dev/null +++ b/test/Fortran/F77FILESUFFIXES.py @@ -0,0 +1,98 @@ +#!/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 + +from common import write_fake_link + +_python_ = TestSCons._python_ +_exe = TestSCons._exe + +test = TestSCons.TestSCons() + +write_fake_link(test) + +test.write('myfortran.py', r""" +import getopt +import sys +comment = '#' + sys.argv[1] +opts, args = getopt.getopt(sys.argv[2:], '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[:len(comment)] != comment: + outfile.write(l) +sys.exit(0) +""") + +# Test default file suffix: .f77/.F77 for F77 +test.write('SConstruct', """ +env = Environment(LINK = r'%(_python_)s mylink.py', + LINKFLAGS = [], + F77 = r'%(_python_)s myfortran.py g77', + FORTRAN = r'%(_python_)s myfortran.py fortran') +env.Program(target = 'test01', source = 'test01.f') +env.Program(target = 'test02', source = 'test02.F') +env.Program(target = 'test03', source = 'test03.for') +env.Program(target = 'test04', source = 'test04.FOR') +env.Program(target = 'test05', source = 'test05.ftn') +env.Program(target = 'test06', source = 'test06.FTN') +env.Program(target = 'test07', source = 'test07.fpp') +env.Program(target = 'test08', source = 'test08.FPP') +env.Program(target = 'test09', source = 'test09.f77') +env.Program(target = 'test10', source = 'test10.F77') +""" % locals()) + +test.write('test01.f', "This is a .f file.\n#link\n#fortran\n") +test.write('test02.F', "This is a .F file.\n#link\n#fortran\n") +test.write('test03.for', "This is a .for file.\n#link\n#fortran\n") +test.write('test04.FOR', "This is a .FOR file.\n#link\n#fortran\n") +test.write('test05.ftn', "This is a .ftn file.\n#link\n#fortran\n") +test.write('test06.FTN', "This is a .FTN file.\n#link\n#fortran\n") +test.write('test07.fpp', "This is a .fpp file.\n#link\n#fortran\n") +test.write('test08.FPP', "This is a .FPP file.\n#link\n#fortran\n") +test.write('test09.f77', "This is a .f77 file.\n#link\n#g77\n") +test.write('test10.F77', "This is a .F77 file.\n#link\n#g77\n") + +test.run(arguments = '.', stderr = None) + +test.must_match('test01' + _exe, "This is a .f file.\n") +test.must_match('test02' + _exe, "This is a .F file.\n") +test.must_match('test03' + _exe, "This is a .for file.\n") +test.must_match('test04' + _exe, "This is a .FOR file.\n") +test.must_match('test05' + _exe, "This is a .ftn file.\n") +test.must_match('test06' + _exe, "This is a .FTN file.\n") +test.must_match('test07' + _exe, "This is a .fpp file.\n") +test.must_match('test08' + _exe, "This is a .FPP file.\n") +test.must_match('test09' + _exe, "This is a .f77 file.\n") +test.must_match('test10' + _exe, "This is a .F77 file.\n") + +test.pass_test() diff --git a/test/Fortran/F77FILESUFFIXES2.py b/test/Fortran/F77FILESUFFIXES2.py new file mode 100644 index 0000000..bde1200 --- /dev/null +++ b/test/Fortran/F77FILESUFFIXES2.py @@ -0,0 +1,82 @@ +#!/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 + +from common import write_fake_link + +_python_ = TestSCons._python_ +_exe = TestSCons._exe + +test = TestSCons.TestSCons() + +write_fake_link(test) + +test.write('myfortran.py', r""" +import getopt +import sys +comment = '#' + sys.argv[1] +opts, args = getopt.getopt(sys.argv[2:], '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[:len(comment)] != comment: + outfile.write(l) +sys.exit(0) +""") + +# Test non-default file suffix: .f/.F for F77 +test.write('SConstruct', """ +env = Environment(LINK = r'%(_python_)s mylink.py', + LINKFLAGS = [], + F77 = r'%(_python_)s myfortran.py g77', + F95 = r'%(_python_)s myfortran.py f95', + F77FILESUFFIXES = ['.f', '.F'], + tools = ['default', 'f77']) +env.Program(target = 'test01', source = 'test01.f') +env.Program(target = 'test02', source = 'test02.F') +env.Program(target = 'test05', source = 'test05.f95') +env.Program(target = 'test06', source = 'test06.F95') +""" % locals()) + +test.write('test01.f', "This is a .f file.\n#link\n#g77\n") +test.write('test02.F', "This is a .F file.\n#link\n#g77\n") +test.write('test05.f95', "This is a .f95 file.\n#link\n#f95\n") +test.write('test06.F95', "This is a .F95 file.\n#link\n#f95\n") + +test.run(arguments = '.', stderr = None) + +test.must_match('test01' + _exe, "This is a .f file.\n") +test.must_match('test02' + _exe, "This is a .F file.\n") +test.must_match('test05' + _exe, "This is a .f95 file.\n") +test.must_match('test06' + _exe, "This is a .F95 file.\n") + +test.pass_test() diff --git a/test/Fortran/F77FLAGS.py b/test/Fortran/F77FLAGS.py index cd25167..a358507 100644 --- a/test/Fortran/F77FLAGS.py +++ b/test/Fortran/F77FLAGS.py @@ -29,46 +29,14 @@ import string import sys import TestSCons +from common import write_fake_link + _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) -""") +write_fake_link(test) test.write('myg77.py', r""" import getopt @@ -94,46 +62,21 @@ env = Environment(LINK = r'%(_python_)s mylink.py', LINKFLAGS = [], F77 = r'%(_python_)s myg77.py', F77FLAGS = '-x') -env.Program(target = 'test01', source = 'test01.f') -env.Program(target = 'test02', source = 'test02.F') -env.Program(target = 'test03', source = 'test03.for') -env.Program(target = 'test04', source = 'test04.FOR') -env.Program(target = 'test05', source = 'test05.ftn') -env.Program(target = 'test06', source = 'test06.FTN') -env.Program(target = 'test07', source = 'test07.fpp') -env.Program(target = 'test08', source = 'test08.FPP') env.Program(target = 'test09', source = 'test09.f77') env.Program(target = 'test10', source = 'test10.F77') """ % locals()) -test.write('test01.f', "This is a .f file.\n#link\n#g77\n") -test.write('test02.F', "This is a .F file.\n#link\n#g77\n") -test.write('test03.for', "This is a .for file.\n#link\n#g77\n") -test.write('test04.FOR', "This is a .FOR file.\n#link\n#g77\n") -test.write('test05.ftn', "This is a .ftn file.\n#link\n#g77\n") -test.write('test06.FTN', "This is a .FTN file.\n#link\n#g77\n") -test.write('test07.fpp', "This is a .fpp file.\n#link\n#g77\n") -test.write('test08.FPP', "This is a .FPP file.\n#link\n#g77\n") test.write('test09.f77', "This is a .f77 file.\n#link\n#g77\n") test.write('test10.F77', "This is a .F77 file.\n#link\n#g77\n") test.run(arguments = '.', stderr = None) -test.must_match('test01' + _exe, " -c -x\nThis is a .f file.\n") -test.must_match('test02' + _exe, " -c -x\nThis is a .F file.\n") -test.must_match('test03' + _exe, " -c -x\nThis is a .for file.\n") -test.must_match('test04' + _exe, " -c -x\nThis is a .FOR file.\n") -test.must_match('test05' + _exe, " -c -x\nThis is a .ftn file.\n") -test.must_match('test06' + _exe, " -c -x\nThis is a .FTN file.\n") -test.must_match('test07' + _exe, " -c -x\nThis is a .fpp file.\n") -test.must_match('test08' + _exe, " -c -x\nThis is a .FPP file.\n") test.must_match('test09' + _exe, " -c -x\nThis is a .f77 file.\n") test.must_match('test10' + _exe, " -c -x\nThis is a .F77 file.\n") - -g77 = test.detect('F77', 'g77') -FTN_LIB = TestSCons.fortran_lib +fc = 'f77' +g77 = test.detect_tool(fc) if g77: @@ -146,7 +89,7 @@ os.system(string.join(sys.argv[1:], " ")) """ % string.replace(test.workpath('wrapper.out'), '\\', '\\\\')) test.write('SConstruct', """ -foo = Environment(LIBS = %FTN_LIBs) +foo = Environment(F77 = '%(fc)s', tools = ['default', 'f77'], F77FILESUFFIXES = [".f"]) f77 = foo.Dictionary('F77') bar = foo.Clone(F77 = r'%(_python_)s wrapper.py ' + f77, F77FLAGS = '-Ix') foo.Program(target = 'foo', source = 'foo.f') @@ -174,7 +117,11 @@ bar.Program(target = 'bar', source = 'bar.f') test.must_not_exist('wrapper.out') - test.run(arguments = 'bar' + _exe) + import sys + if sys.platform[:5] == 'sunos': + test.run(arguments = 'bar' + _exe, stderr = None) + else: + test.run(arguments = 'bar' + _exe) test.run(program = test.workpath('bar'), stdout = " bar.f\n") diff --git a/test/Fortran/F77PATH.py b/test/Fortran/F77PATH.py index 738954f..b8856f3 100644 --- a/test/Fortran/F77PATH.py +++ b/test/Fortran/F77PATH.py @@ -29,7 +29,6 @@ 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) @@ -38,8 +37,9 @@ args = prog + ' ' + variant_prog + ' ' + subdir_prog test = TestSCons.TestSCons() -if not test.detect('_F77G', 'g77'): - test.skip_test('Could not find a $F77 tool; skipping test.\n') +fc = 'f77' +if not test.detect_tool(fc): + test.skip_test('Could not find a f77 tool; skipping test.\n') test.subdir('include', 'subdir', @@ -50,8 +50,8 @@ test.subdir('include', test.write('SConstruct', """ -env = Environment(F77PATH = ['$FOO', '${TARGET.dir}', '${SOURCE.dir}'], - LIBS = %s, +env = Environment(F77 = '%s', + F77PATH = ['$FOO', '${TARGET.dir}', '${SOURCE.dir}'], FOO='include', F77FLAGS = '-x f77') obj = env.Object(target='foobar/prog', source='subdir/prog.f77') @@ -60,11 +60,11 @@ SConscript('subdir/SConscript', "env") VariantDir('variant', 'subdir', 0) include = Dir('include') -env = Environment(F77PATH=[include, '#foobar', '#subdir'], - LIBS = %s, +env = Environment(F77 = '%s', + F77PATH=[include, '#foobar', '#subdir'], F77FLAGS = '-x f77') SConscript('variant/SConscript', "env") -""" % (FTN_LIB, FTN_LIB)) +""" % (fc, fc)) test.write(['subdir', 'SConscript'], """ @@ -239,8 +239,8 @@ 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 ${TARGET.dir} ${SOURCE.dir}'), - LIBS = %s, +env = Environment(F77 = '%s', + F77PATH = Split('inc2 include ${TARGET.dir} ${SOURCE.dir}'), F77FLAGS = '-x f77') obj = env.Object(target='foobar/prog', source='subdir/prog.f77') env.Program(target='prog', source=obj) @@ -248,11 +248,11 @@ SConscript('subdir/SConscript', "env") VariantDir('variant', 'subdir', 0) include = Dir('include') -env = Environment(F77PATH=['inc2', include, '#foobar', '#subdir'], - LIBS = %s, +env = Environment(F77 = '%s', + F77PATH=['inc2', include, '#foobar', '#subdir'], F77FLAGS = '-x f77') SConscript('variant/SConscript', "env") -""" % (FTN_LIB, FTN_LIB)) +""" % (fc, fc)) test.up_to_date(arguments = args) @@ -298,9 +298,9 @@ test.up_to_date(arguments = args) # Check that a null-string F77PATH doesn't blow up. test.write('SConstruct', """ -env = Environment(F77PATH = '', LIBS = %s, F77FLAGS = '-x f77') +env = Environment(tools = ['f77'], F77PATH = '', F77FLAGS = '-x f77') env.Object('foo', source = 'empty.f77') -""" % FTN_LIB) +""") test.write('empty.f77', '') diff --git a/test/Fortran/F90.py b/test/Fortran/F90.py index cadfb01..ad73d9f 100644 --- a/test/Fortran/F90.py +++ b/test/Fortran/F90.py @@ -29,48 +29,14 @@ import string import sys import TestSCons +from common import write_fake_link + _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) -""") +write_fake_link(test) test.write('myfortran.py', r""" import getopt @@ -101,12 +67,8 @@ env.Program(target = 'test05', source = 'test05.ftn') env.Program(target = 'test06', source = 'test06.FTN') env.Program(target = 'test07', source = 'test07.fpp') env.Program(target = 'test08', source = 'test08.FPP') -env.Program(target = 'test09', source = 'test09.f77') -env.Program(target = 'test10', source = 'test10.F77') env.Program(target = 'test11', source = 'test11.f90') env.Program(target = 'test12', source = 'test12.F90') -env.Program(target = 'test13', source = 'test13.f95') -env.Program(target = 'test14', source = 'test14.F95') """ % locals()) test.write('test01.f', "This is a .f file.\n#link\n#fortran\n") @@ -117,12 +79,8 @@ test.write('test05.ftn', "This is a .ftn file.\n#link\n#fortran\n") test.write('test06.FTN', "This is a .FTN file.\n#link\n#fortran\n") test.write('test07.fpp', "This is a .fpp file.\n#link\n#fortran\n") test.write('test08.FPP', "This is a .FPP file.\n#link\n#fortran\n") -test.write('test09.f77', "This is a .f77 file.\n#link\n#fortran\n") -test.write('test10.F77', "This is a .F77 file.\n#link\n#fortran\n") test.write('test11.f90', "This is a .f90 file.\n#link\n#f90\n") test.write('test12.F90', "This is a .F90 file.\n#link\n#f90\n") -test.write('test13.f95', "This is a .f95 file.\n#link\n#fortran\n") -test.write('test14.F95', "This is a .F95 file.\n#link\n#fortran\n") test.run(arguments = '.', stderr = None) @@ -134,17 +92,12 @@ test.must_match('test05' + _exe, "This is a .ftn file.\n") test.must_match('test06' + _exe, "This is a .FTN file.\n") test.must_match('test07' + _exe, "This is a .fpp file.\n") test.must_match('test08' + _exe, "This is a .FPP file.\n") -test.must_match('test09' + _exe, "This is a .f77 file.\n") -test.must_match('test10' + _exe, "This is a .F77 file.\n") test.must_match('test11' + _exe, "This is a .f90 file.\n") test.must_match('test12' + _exe, "This is a .F90 file.\n") -test.must_match('test13' + _exe, "This is a .f95 file.\n") -test.must_match('test14' + _exe, "This is a .F95 file.\n") - -g90 = test.detect('F90', 'g90') -FTN_LIB = TestSCons.fortran_lib +fc = 'f90' +g90 = test.detect_tool(fc) if g90: @@ -157,57 +110,38 @@ os.system(string.join(sys.argv[1:], " ")) """ % string.replace(test.workpath('wrapper.out'), '\\', '\\\\')) test.write('SConstruct', """ -foo = Environment(LIBS = %(FTN_LIB)s) +foo = Environment(F90 = '%(fc)s') f90 = foo.Dictionary('F90') bar = foo.Clone(F90 = r'%(_python_)s wrapper.py ' + f90) -foo.Program(target = 'foo', source = 'foo.f') -bar.Program(target = 'bar', source = 'bar.f') +foo.Program(target = 'foo', source = 'foo.f90') +bar.Program(target = 'bar', source = 'bar.f90') """ % locals()) - test.write('foo.f', r""" + test.write('foo.f90', r""" PROGRAM FOO - USE MOD_BAR - PRINT *,'foo.f' - CALL P - STOP + PRINT *,'foo.f90' END - MODULE MOD_BAR - IMPLICIT NONE - CONTAINS - SUBROUTINE P - PRINT *,'mod_bar' - END SUBROUTINE P - END MODULE MOD_BAR """) - test.write('bar.f', r""" + test.write('bar.f90', r""" PROGRAM BAR - USE MOD_FOO - PRINT *,'bar.f' - CALL P - STOP + PRINT *,'bar.f90' END """) - test.write('foo_mod.f', r""" - MODULE MOD_FOO - IMPLICIT NONE - CONTAINS - SUBROUTINE P - PRINT *,'mod_foo' - END SUBROUTINE P - END MODULE MOD_FOO -""") - test.run(arguments = 'foo' + _exe, stderr = None) - test.run(program = test.workpath('foo'), stdout = " foo.f\n") + test.run(program = test.workpath('foo'), stdout = " foo.f90\n") test.must_not_exist('wrapper.out') - test.run(arguments = 'bar' + _exe) + import sys + if sys.platform[:5] == 'sunos': + test.run(arguments = 'bar' + _exe, stderr = None) + else: + test.run(arguments = 'bar' + _exe) - test.run(program = test.workpath('bar'), stdout = " bar.f\n") + test.run(program = test.workpath('bar'), stdout = " bar.f90\n") test.must_match('wrapper.out', "wrapper.py\n") diff --git a/test/Fortran/F90COM.py b/test/Fortran/F90COM.py index 7a206da..1b33c73 100644 --- a/test/Fortran/F90COM.py +++ b/test/Fortran/F90COM.py @@ -29,48 +29,14 @@ import string import sys import TestSCons +from common import write_fake_link + _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) -""") +write_fake_link(test) test.write('myfortran.py', r""" import sys @@ -98,12 +64,8 @@ env.Program(target = 'test05', source = 'test05.ftn') env.Program(target = 'test06', source = 'test06.FTN') env.Program(target = 'test07', source = 'test07.fpp') env.Program(target = 'test08', source = 'test08.FPP') -env.Program(target = 'test09', source = 'test09.f77') -env.Program(target = 'test10', source = 'test10.F77') env.Program(target = 'test11', source = 'test11.f90') env.Program(target = 'test12', source = 'test12.F90') -env.Program(target = 'test13', source = 'test13.f95') -env.Program(target = 'test14', source = 'test14.F95') env2 = Environment(LINK = r'%(_python_)s mylink.py', LINKFLAGS = [], F90COM = r'%(_python_)s myfortran.py f90 $TARGET $SOURCES', @@ -120,12 +82,8 @@ test.write('test05.ftn', "This is a .ftn file.\n#link\n#fortran\n") test.write('test06.FTN', "This is a .FTN file.\n#link\n#fortranpp\n") test.write('test07.fpp', "This is a .fpp file.\n#link\n#fortranpp\n") test.write('test08.FPP', "This is a .FPP file.\n#link\n#fortranpp\n") -test.write('test09.f77', "This is a .f77 file.\n#link\n#fortran\n") -test.write('test10.F77', "This is a .F77 file.\n#link\n#fortranpp\n") test.write('test11.f90', "This is a .f90 file.\n#link\n#f90\n") test.write('test12.F90', "This is a .F90 file.\n#link\n#f90pp\n") -test.write('test13.f95', "This is a .f95 file.\n#link\n#fortran\n") -test.write('test14.F95', "This is a .F95 file.\n#link\n#fortranpp\n") test.write('test21.f90', "This is a .f90 file.\n#link\n#f90\n") test.write('test22.F90', "This is a .F90 file.\n#link\n#f90pp\n") @@ -140,12 +98,8 @@ test.must_match('test05' + _exe, "This is a .ftn file.\n") test.must_match('test06' + _exe, "This is a .FTN file.\n") test.must_match('test07' + _exe, "This is a .fpp file.\n") test.must_match('test08' + _exe, "This is a .FPP file.\n") -test.must_match('test09' + _exe, "This is a .f77 file.\n") -test.must_match('test10' + _exe, "This is a .F77 file.\n") test.must_match('test11' + _exe, "This is a .f90 file.\n") test.must_match('test12' + _exe, "This is a .F90 file.\n") -test.must_match('test13' + _exe, "This is a .f95 file.\n") -test.must_match('test14' + _exe, "This is a .F95 file.\n") test.must_match('test21' + _exe, "This is a .f90 file.\n") test.must_match('test22' + _exe, "This is a .F90 file.\n") diff --git a/test/Fortran/F90FILESUFFIXES.py b/test/Fortran/F90FILESUFFIXES.py new file mode 100644 index 0000000..ac4126a --- /dev/null +++ b/test/Fortran/F90FILESUFFIXES.py @@ -0,0 +1,98 @@ +#!/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 + +from common import write_fake_link + +_python_ = TestSCons._python_ +_exe = TestSCons._exe + +test = TestSCons.TestSCons() + +write_fake_link(test) + +test.write('myfortran.py', r""" +import getopt +import sys +comment = '#' + sys.argv[1] +opts, args = getopt.getopt(sys.argv[2:], '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[:len(comment)] != comment: + outfile.write(l) +sys.exit(0) +""") + +# Test default file suffix: .f90/.F90 for F90 +test.write('SConstruct', """ +env = Environment(LINK = r'%(_python_)s mylink.py', + LINKFLAGS = [], + F90 = r'%(_python_)s myfortran.py f90', + FORTRAN = r'%(_python_)s myfortran.py fortran') +env.Program(target = 'test01', source = 'test01.f') +env.Program(target = 'test02', source = 'test02.F') +env.Program(target = 'test03', source = 'test03.for') +env.Program(target = 'test04', source = 'test04.FOR') +env.Program(target = 'test05', source = 'test05.ftn') +env.Program(target = 'test06', source = 'test06.FTN') +env.Program(target = 'test07', source = 'test07.fpp') +env.Program(target = 'test08', source = 'test08.FPP') +env.Program(target = 'test09', source = 'test09.f90') +env.Program(target = 'test10', source = 'test10.F90') +""" % locals()) + +test.write('test01.f', "This is a .f file.\n#link\n#fortran\n") +test.write('test02.F', "This is a .F file.\n#link\n#fortran\n") +test.write('test03.for', "This is a .for file.\n#link\n#fortran\n") +test.write('test04.FOR', "This is a .FOR file.\n#link\n#fortran\n") +test.write('test05.ftn', "This is a .ftn file.\n#link\n#fortran\n") +test.write('test06.FTN', "This is a .FTN file.\n#link\n#fortran\n") +test.write('test07.fpp', "This is a .fpp file.\n#link\n#fortran\n") +test.write('test08.FPP', "This is a .FPP file.\n#link\n#fortran\n") +test.write('test09.f90', "This is a .f90 file.\n#link\n#f90\n") +test.write('test10.F90', "This is a .F90 file.\n#link\n#f90\n") + +test.run(arguments = '.', stderr = None) + +test.must_match('test01' + _exe, "This is a .f file.\n") +test.must_match('test02' + _exe, "This is a .F file.\n") +test.must_match('test03' + _exe, "This is a .for file.\n") +test.must_match('test04' + _exe, "This is a .FOR file.\n") +test.must_match('test05' + _exe, "This is a .ftn file.\n") +test.must_match('test06' + _exe, "This is a .FTN file.\n") +test.must_match('test07' + _exe, "This is a .fpp file.\n") +test.must_match('test08' + _exe, "This is a .FPP file.\n") +test.must_match('test09' + _exe, "This is a .f90 file.\n") +test.must_match('test10' + _exe, "This is a .F90 file.\n") + +test.pass_test() diff --git a/test/Fortran/F90FILESUFFIXES2.py b/test/Fortran/F90FILESUFFIXES2.py new file mode 100644 index 0000000..658eda3 --- /dev/null +++ b/test/Fortran/F90FILESUFFIXES2.py @@ -0,0 +1,88 @@ +#!/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 + +from common import write_fake_link + +_python_ = TestSCons._python_ +_exe = TestSCons._exe + +test = TestSCons.TestSCons() + +write_fake_link(test) + +test.write('myfortran.py', r""" +import getopt +import sys +comment = '#' + sys.argv[1] +opts, args = getopt.getopt(sys.argv[2:], '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[:len(comment)] != comment: + outfile.write(l) +sys.exit(0) +""") + +# Test non-default file suffix: .f/.F for F90 +test.write('SConstruct', """ +env = Environment(LINK = r'%(_python_)s mylink.py', + LINKFLAGS = [], + F77 = r'%(_python_)s myfortran.py f77', + F90 = r'%(_python_)s myfortran.py f90', + F90FILESUFFIXES = ['.f', '.F', '.f90', '.F90'], + tools = ['default', 'f90']) +env.Program(target = 'test01', source = 'test01.f') +env.Program(target = 'test02', source = 'test02.F') +env.Program(target = 'test03', source = 'test03.f90') +env.Program(target = 'test04', source = 'test04.F90') +env.Program(target = 'test05', source = 'test05.f77') +env.Program(target = 'test06', source = 'test06.F77') +""" % locals()) + +test.write('test01.f', "This is a .f file.\n#link\n#f90\n") +test.write('test02.F', "This is a .F file.\n#link\n#f90\n") +test.write('test03.f90', "This is a .f90 file.\n#link\n#f90\n") +test.write('test04.F90', "This is a .F90 file.\n#link\n#f90\n") +test.write('test05.f77', "This is a .f77 file.\n#link\n#f77\n") +test.write('test06.F77', "This is a .F77 file.\n#link\n#f77\n") + +test.run(arguments = '.', stderr = None) + +test.must_match('test01' + _exe, "This is a .f file.\n") +test.must_match('test02' + _exe, "This is a .F file.\n") +test.must_match('test03' + _exe, "This is a .f90 file.\n") +test.must_match('test04' + _exe, "This is a .F90 file.\n") +test.must_match('test05' + _exe, "This is a .f77 file.\n") +test.must_match('test06' + _exe, "This is a .F77 file.\n") + +test.pass_test() diff --git a/test/Fortran/F90FLAGS.py b/test/Fortran/F90FLAGS.py index 2243ba6..8e42ed5 100644 --- a/test/Fortran/F90FLAGS.py +++ b/test/Fortran/F90FLAGS.py @@ -30,46 +30,14 @@ import string import sys import TestSCons +from common import write_fake_link + _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) -""") +write_fake_link(test) test.write('myfortran.py', r""" import getopt @@ -105,12 +73,8 @@ env.Program(target = 'test05', source = 'test05.ftn') env.Program(target = 'test06', source = 'test06.FTN') env.Program(target = 'test07', source = 'test07.fpp') env.Program(target = 'test08', source = 'test08.FPP') -env.Program(target = 'test09', source = 'test09.f77') -env.Program(target = 'test10', source = 'test10.F77') env.Program(target = 'test11', source = 'test11.f90') env.Program(target = 'test12', source = 'test12.F90') -env.Program(target = 'test13', source = 'test13.f95') -env.Program(target = 'test14', source = 'test14.F95') """ % locals()) test.write('test01.f', "This is a .f file.\n#link\n#fortran\n") @@ -121,12 +85,8 @@ test.write('test05.ftn', "This is a .ftn file.\n#link\n#fortran\n") test.write('test06.FTN', "This is a .FTN file.\n#link\n#fortran\n") test.write('test07.fpp', "This is a .fpp file.\n#link\n#fortran\n") test.write('test08.FPP', "This is a .FPP file.\n#link\n#fortran\n") -test.write('test09.f77', "This is a .f77 file.\n#link\n#fortran\n") -test.write('test10.F77', "This is a .F77 file.\n#link\n#fortran\n") test.write('test11.f90', "This is a .f90 file.\n#link\n#g90\n") test.write('test12.F90', "This is a .F90 file.\n#link\n#g90\n") -test.write('test13.f95', "This is a .f95 file.\n#link\n#fortran\n") -test.write('test14.F95', "This is a .F95 file.\n#link\n#fortran\n") test.run(arguments = '.', stderr = None) @@ -138,17 +98,13 @@ test.must_match('test05' + _exe, " -c -y\nThis is a .ftn file.\n") test.must_match('test06' + _exe, " -c -y\nThis is a .FTN file.\n") test.must_match('test07' + _exe, " -c -y\nThis is a .fpp file.\n") test.must_match('test08' + _exe, " -c -y\nThis is a .FPP file.\n") -test.must_match('test09' + _exe, " -c -y\nThis is a .f77 file.\n") -test.must_match('test10' + _exe, " -c -y\nThis is a .F77 file.\n") test.must_match('test11' + _exe, " -c -x\nThis is a .f90 file.\n") test.must_match('test12' + _exe, " -c -x\nThis is a .F90 file.\n") -test.must_match('test13' + _exe, " -c -y\nThis is a .f95 file.\n") -test.must_match('test14' + _exe, " -c -y\nThis is a .F95 file.\n") -g90 = test.detect('F90', 'g90') -FTN_LIB = TestSCons.fortran_lib +fc = 'f90' +g90 = test.detect_tool(fc) if g90: @@ -161,57 +117,38 @@ os.system(string.join(sys.argv[1:], " ")) """ % string.replace(test.workpath('wrapper.out'), '\\', '\\\\')) test.write('SConstruct', """ -foo = Environment(LIBS = %(FTN_LIB)s) +foo = Environment(F90 = '%(fc)s') f90 = foo.Dictionary('F90') -bar = foo.Clone(F90 = r'%(_python_)s wrapper.py ' + f90, F90FLAGS = '-Ix') -foo.Program(target = 'foo', source = 'foo.f') -bar.Program(target = 'bar', source = 'bar.f') +bar = foo.Clone(F90 = r'%(_python_)s wrapper.py ' + f90) +foo.Program(target = 'foo', source = 'foo.f90') +bar.Program(target = 'bar', source = 'bar.f90') """ % locals()) - test.write('foo.f', r""" + test.write('foo.f90', r""" PROGRAM FOO - USE MOD_BAR - PRINT *,'foo.f' - CALL P - STOP + PRINT *,'foo.f90' END - MODULE MOD_BAR - IMPLICIT NONE - CONTAINS - SUBROUTINE P - PRINT *,'mod_bar' - END SUBROUTINE P - END MODULE MOD_BAR """) - test.write('bar.f', r""" + test.write('bar.f90', r""" PROGRAM BAR - USE MOD_FOO - PRINT *,'bar.f' - CALL P - STOP + PRINT *,'bar.f90' END """) - test.write('foo_mod.f', r""" - MODULE MOD_FOO - IMPLICIT NONE - CONTAINS - SUBROUTINE P - PRINT *,'mod_foo' - END SUBROUTINE P - END MODULE MOD_FOO -""") - test.run(arguments = 'foo' + _exe, stderr = None) - test.run(program = test.workpath('foo'), stdout = " foo.f\n") + test.run(program = test.workpath('foo'), stdout = " foo.f90\n") test.must_not_exist('wrapper.out') - test.run(arguments = 'bar' + _exe) + import sys + if sys.platform[:5] == 'sunos': + test.run(arguments = 'bar' + _exe, stderr = None) + else: + test.run(arguments = 'bar' + _exe) - test.run(program = test.workpath('bar'), stdout = " bar.f\n") + test.run(program = test.workpath('bar'), stdout = " bar.f90\n") test.must_match('wrapper.out', "wrapper.py\n") diff --git a/test/Fortran/F90PATH.py b/test/Fortran/F90PATH.py index fb159cf..e5fca99 100644 --- a/test/Fortran/F90PATH.py +++ b/test/Fortran/F90PATH.py @@ -31,7 +31,6 @@ 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) @@ -40,24 +39,9 @@ args = prog + ' ' + subdir_prog + ' ' + variant_prog test = TestSCons.TestSCons() -baselist = [ - '/opt/intel_fc_80', - '/opt/intel/fc/9.0', -] - -F90 = None -for base in baselist: - ifort = os.path.join(base, 'bin', 'ifort') - if os.path.exists(ifort): - F90 = ifort - -if not F90: - l = string.join(baselist, '\n\t') - test.skip_test('No (hard-coded) F90 compiler under:' + l + '\n') - -LIBPATH = os.path.join(base, 'lib') -LIBS = ['irc'] -os.environ['LD_LIBRARY_PATH'] = LIBPATH +fc = 'f90' +if not test.detect_tool(fc): + test.skip_test('Could not find a f90 tool; skipping test.\n') test.subdir('include', 'subdir', @@ -71,8 +55,6 @@ test.write('SConstruct', """ env = Environment(F90 = r'%s', F90PATH = ['$FOO', '${TARGET.dir}', '${SOURCE.dir}'], LINK = '$F90', - LIBPATH = %s, - LIBS = %s, FOO='include') obj = env.Object(target='foobar/prog', source='subdir/prog.f90') env.Program(target='prog', source=obj) @@ -82,11 +64,9 @@ VariantDir('variant', 'subdir', 0) include = Dir('include') env = Environment(F90 = r'%s', F90PATH=[include, '#foobar', '#subdir'], - LINK = '$F90', - LIBPATH = %s, - LIBS = %s) + LINK = '$F90') SConscript('variant/SConscript', "env") -""" % (F90, repr(LIBPATH), LIBS, F90, repr(LIBPATH), LIBS)) +""" % (fc, fc, )) test.write(['subdir', 'SConscript'], """ @@ -263,9 +243,7 @@ test.up_to_date(arguments = args) test.write('SConstruct', """ env = Environment(F90 = r'%s', F90PATH = Split('inc2 include ${TARGET.dir} ${SOURCE.dir}'), - LINK = '$F90', - LIBPATH = %s, - LIBS = %s) + LINK = '$F90') obj = env.Object(target='foobar/prog', source='subdir/prog.f90') env.Program(target='prog', source=obj) SConscript('subdir/SConscript', "env") @@ -274,11 +252,9 @@ VariantDir('variant', 'subdir', 0) include = Dir('include') env = Environment(F90 = r'%s', F90PATH=['inc2', include, '#foobar', '#subdir'], - LINK = '$F90', - LIBPATH = %s, - LIBS = %s) + LINK = '$F90') SConscript('variant/SConscript', "env") -""" % (F90, repr(LIBPATH), LIBS, F90, repr(LIBPATH), LIBS)) +""" % (fc, fc)) test.up_to_date(arguments = args) diff --git a/test/Fortran/F95.py b/test/Fortran/F95.py index 767a3b4..0a5d853 100644 --- a/test/Fortran/F95.py +++ b/test/Fortran/F95.py @@ -29,48 +29,14 @@ import string import sys import TestSCons +from common import write_fake_link + _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) -""") +write_fake_link(test) test.write('myfortran.py', r""" import getopt @@ -101,10 +67,6 @@ env.Program(target = 'test05', source = 'test05.ftn') env.Program(target = 'test06', source = 'test06.FTN') env.Program(target = 'test07', source = 'test07.fpp') env.Program(target = 'test08', source = 'test08.FPP') -env.Program(target = 'test09', source = 'test09.f77') -env.Program(target = 'test10', source = 'test10.F77') -env.Program(target = 'test11', source = 'test11.f90') -env.Program(target = 'test12', source = 'test12.F90') env.Program(target = 'test13', source = 'test13.f95') env.Program(target = 'test14', source = 'test14.F95') """ % locals()) @@ -117,10 +79,6 @@ test.write('test05.ftn', "This is a .ftn file.\n#link\n#fortran\n") test.write('test06.FTN', "This is a .FTN file.\n#link\n#fortran\n") test.write('test07.fpp', "This is a .fpp file.\n#link\n#fortran\n") test.write('test08.FPP', "This is a .FPP file.\n#link\n#fortran\n") -test.write('test09.f77', "This is a .f77 file.\n#link\n#fortran\n") -test.write('test10.F77', "This is a .F77 file.\n#link\n#fortran\n") -test.write('test11.f90', "This is a .f90 file.\n#link\n#fortran\n") -test.write('test12.F90', "This is a .F90 file.\n#link\n#fortran\n") test.write('test13.f95', "This is a .f95 file.\n#link\n#f95\n") test.write('test14.F95', "This is a .F95 file.\n#link\n#f95\n") @@ -134,17 +92,12 @@ test.must_match('test05' + _exe, "This is a .ftn file.\n") test.must_match('test06' + _exe, "This is a .FTN file.\n") test.must_match('test07' + _exe, "This is a .fpp file.\n") test.must_match('test08' + _exe, "This is a .FPP file.\n") -test.must_match('test09' + _exe, "This is a .f77 file.\n") -test.must_match('test10' + _exe, "This is a .F77 file.\n") -test.must_match('test11' + _exe, "This is a .f90 file.\n") -test.must_match('test12' + _exe, "This is a .F90 file.\n") test.must_match('test13' + _exe, "This is a .f95 file.\n") test.must_match('test14' + _exe, "This is a .F95 file.\n") - -g95 = test.detect('F95', 'g95') -FTN_LIB = TestSCons.fortran_lib +fc = 'f95' +g95 = test.detect_tool(fc) if g95: @@ -157,23 +110,23 @@ os.system(string.join(sys.argv[1:], " ")) """ % string.replace(test.workpath('wrapper.out'), '\\', '\\\\')) test.write('SConstruct', """ -foo = Environment(LIBS = %(FTN_LIB)s) +foo = Environment(F95 = '%(fc)s') f95 = foo.Dictionary('F95') bar = foo.Clone(F95 = r'%(_python_)s wrapper.py ' + f95) -foo.Program(target = 'foo', source = 'foo.f') -bar.Program(target = 'bar', source = 'bar.f') +foo.Program(target = 'foo', source = 'foo.f95') +bar.Program(target = 'bar', source = 'bar.f95') """ % locals()) - test.write('foo.f', r""" + test.write('foo.f95', r""" PROGRAM FOO - PRINT *,'foo.f' + PRINT *,'foo.f95' STOP END """) - test.write('bar.f', r""" + test.write('bar.f95', r""" PROGRAM BAR - PRINT *,'bar.f' + PRINT *,'bar.f95' STOP END """) @@ -181,13 +134,17 @@ bar.Program(target = 'bar', source = 'bar.f') test.run(arguments = 'foo' + _exe, stderr = None) - test.run(program = test.workpath('foo'), stdout = " foo.f\n") + test.run(program = test.workpath('foo'), stdout = " foo.f95\n") test.must_not_exist('wrapper.out') - test.run(arguments = 'bar' + _exe) + import sys + if sys.platform[:5] == 'sunos': + test.run(arguments = 'bar' + _exe, stderr = None) + else: + test.run(arguments = 'bar' + _exe) - test.run(program = test.workpath('bar'), stdout = " bar.f\n") + test.run(program = test.workpath('bar'), stdout = " bar.f95\n") test.must_match('wrapper.out', "wrapper.py\n") diff --git a/test/Fortran/F95COM.py b/test/Fortran/F95COM.py index 016230a..71585ca 100644 --- a/test/Fortran/F95COM.py +++ b/test/Fortran/F95COM.py @@ -29,48 +29,14 @@ import string import sys import TestSCons +from common import write_fake_link + _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) -""") +write_fake_link(test) test.write('myfortran.py', r""" import sys @@ -98,10 +64,6 @@ env.Program(target = 'test05', source = 'test05.ftn') env.Program(target = 'test06', source = 'test06.FTN') env.Program(target = 'test07', source = 'test07.fpp') env.Program(target = 'test08', source = 'test08.FPP') -env.Program(target = 'test09', source = 'test09.f77') -env.Program(target = 'test10', source = 'test10.F77') -env.Program(target = 'test11', source = 'test11.f90') -env.Program(target = 'test12', source = 'test12.F90') env.Program(target = 'test13', source = 'test13.f95') env.Program(target = 'test14', source = 'test14.F95') env2 = Environment(LINK = r'%(_python_)s mylink.py', @@ -120,10 +82,6 @@ test.write('test05.ftn', "This is a .ftn file.\n#link\n#fortran\n") test.write('test06.FTN', "This is a .FTN file.\n#link\n#fortranpp\n") test.write('test07.fpp', "This is a .fpp file.\n#link\n#fortranpp\n") test.write('test08.FPP', "This is a .FPP file.\n#link\n#fortranpp\n") -test.write('test09.f77', "This is a .f77 file.\n#link\n#fortran\n") -test.write('test10.F77', "This is a .F77 file.\n#link\n#fortranpp\n") -test.write('test11.f90', "This is a .f90 file.\n#link\n#fortran\n") -test.write('test12.F90', "This is a .F90 file.\n#link\n#fortranpp\n") test.write('test13.f95', "This is a .f95 file.\n#link\n#f95\n") test.write('test14.F95', "This is a .F95 file.\n#link\n#f95pp\n") @@ -140,10 +98,6 @@ test.must_match('test05' + _exe, "This is a .ftn file.\n") test.must_match('test06' + _exe, "This is a .FTN file.\n") test.must_match('test07' + _exe, "This is a .fpp file.\n") test.must_match('test08' + _exe, "This is a .FPP file.\n") -test.must_match('test09' + _exe, "This is a .f77 file.\n") -test.must_match('test10' + _exe, "This is a .F77 file.\n") -test.must_match('test11' + _exe, "This is a .f90 file.\n") -test.must_match('test12' + _exe, "This is a .F90 file.\n") test.must_match('test13' + _exe, "This is a .f95 file.\n") test.must_match('test14' + _exe, "This is a .F95 file.\n") diff --git a/test/Fortran/F95FILESUFFIXES.py b/test/Fortran/F95FILESUFFIXES.py new file mode 100644 index 0000000..f42d236 --- /dev/null +++ b/test/Fortran/F95FILESUFFIXES.py @@ -0,0 +1,98 @@ +#!/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 + +from common import write_fake_link + +_python_ = TestSCons._python_ +_exe = TestSCons._exe + +test = TestSCons.TestSCons() + +write_fake_link(test) + +test.write('myfortran.py', r""" +import getopt +import sys +comment = '#' + sys.argv[1] +opts, args = getopt.getopt(sys.argv[2:], '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[:len(comment)] != comment: + outfile.write(l) +sys.exit(0) +""") + +# Test default file suffix: .f90/.F90 for F90 +test.write('SConstruct', """ +env = Environment(LINK = r'%(_python_)s mylink.py', + LINKFLAGS = [], + F95 = r'%(_python_)s myfortran.py f95', + FORTRAN = r'%(_python_)s myfortran.py fortran') +env.Program(target = 'test01', source = 'test01.f') +env.Program(target = 'test02', source = 'test02.F') +env.Program(target = 'test03', source = 'test03.for') +env.Program(target = 'test04', source = 'test04.FOR') +env.Program(target = 'test05', source = 'test05.ftn') +env.Program(target = 'test06', source = 'test06.FTN') +env.Program(target = 'test07', source = 'test07.fpp') +env.Program(target = 'test08', source = 'test08.FPP') +env.Program(target = 'test09', source = 'test09.f95') +env.Program(target = 'test10', source = 'test10.F95') +""" % locals()) + +test.write('test01.f', "This is a .f file.\n#link\n#fortran\n") +test.write('test02.F', "This is a .F file.\n#link\n#fortran\n") +test.write('test03.for', "This is a .for file.\n#link\n#fortran\n") +test.write('test04.FOR', "This is a .FOR file.\n#link\n#fortran\n") +test.write('test05.ftn', "This is a .ftn file.\n#link\n#fortran\n") +test.write('test06.FTN', "This is a .FTN file.\n#link\n#fortran\n") +test.write('test07.fpp', "This is a .fpp file.\n#link\n#fortran\n") +test.write('test08.FPP', "This is a .FPP file.\n#link\n#fortran\n") +test.write('test09.f95', "This is a .f95 file.\n#link\n#f95\n") +test.write('test10.F95', "This is a .F95 file.\n#link\n#f95\n") + +test.run(arguments = '.', stderr = None) + +test.must_match('test01' + _exe, "This is a .f file.\n") +test.must_match('test02' + _exe, "This is a .F file.\n") +test.must_match('test03' + _exe, "This is a .for file.\n") +test.must_match('test04' + _exe, "This is a .FOR file.\n") +test.must_match('test05' + _exe, "This is a .ftn file.\n") +test.must_match('test06' + _exe, "This is a .FTN file.\n") +test.must_match('test07' + _exe, "This is a .fpp file.\n") +test.must_match('test08' + _exe, "This is a .FPP file.\n") +test.must_match('test09' + _exe, "This is a .f95 file.\n") +test.must_match('test10' + _exe, "This is a .F95 file.\n") + +test.pass_test() diff --git a/test/Fortran/F95FILESUFFIXES2.py b/test/Fortran/F95FILESUFFIXES2.py new file mode 100644 index 0000000..2f31152 --- /dev/null +++ b/test/Fortran/F95FILESUFFIXES2.py @@ -0,0 +1,88 @@ +#!/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 + +from common import write_fake_link + +_python_ = TestSCons._python_ +_exe = TestSCons._exe + +test = TestSCons.TestSCons() + +write_fake_link(test) + +test.write('myfortran.py', r""" +import getopt +import sys +comment = '#' + sys.argv[1] +opts, args = getopt.getopt(sys.argv[2:], '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[:len(comment)] != comment: + outfile.write(l) +sys.exit(0) +""") + +# Test non-default file suffix: .f/.F for F95 +test.write('SConstruct', """ +env = Environment(LINK = r'%(_python_)s mylink.py', + LINKFLAGS = [], + F77 = r'%(_python_)s myfortran.py f77', + F95 = r'%(_python_)s myfortran.py f95', + F95FILESUFFIXES = ['.f', '.F', '.f95', '.F95'], + tools = ['default', 'f95']) +env.Program(target = 'test01', source = 'test01.f') +env.Program(target = 'test02', source = 'test02.F') +env.Program(target = 'test03', source = 'test03.f95') +env.Program(target = 'test04', source = 'test04.F95') +env.Program(target = 'test05', source = 'test05.f77') +env.Program(target = 'test06', source = 'test06.F77') +""" % locals()) + +test.write('test01.f', "This is a .f file.\n#link\n#f95\n") +test.write('test02.F', "This is a .F file.\n#link\n#f95\n") +test.write('test03.f95', "This is a .f95 file.\n#link\n#f95\n") +test.write('test04.F95', "This is a .F95 file.\n#link\n#f95\n") +test.write('test05.f77', "This is a .f77 file.\n#link\n#f77\n") +test.write('test06.F77', "This is a .F77 file.\n#link\n#f77\n") + +test.run(arguments = '.', stderr = None) + +test.must_match('test01' + _exe, "This is a .f file.\n") +test.must_match('test02' + _exe, "This is a .F file.\n") +test.must_match('test03' + _exe, "This is a .f95 file.\n") +test.must_match('test04' + _exe, "This is a .F95 file.\n") +test.must_match('test05' + _exe, "This is a .f77 file.\n") +test.must_match('test06' + _exe, "This is a .F77 file.\n") + +test.pass_test() diff --git a/test/Fortran/F95FLAGS.py b/test/Fortran/F95FLAGS.py index 7d32419..d43d8f5 100644 --- a/test/Fortran/F95FLAGS.py +++ b/test/Fortran/F95FLAGS.py @@ -29,46 +29,14 @@ import string import sys import TestSCons +from common import write_fake_link + _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) -""") +write_fake_link(test) test.write('myfortran.py', r""" import getopt @@ -105,10 +73,6 @@ env.Program(target = 'test05', source = 'test05.ftn') env.Program(target = 'test06', source = 'test06.FTN') env.Program(target = 'test07', source = 'test07.fpp') env.Program(target = 'test08', source = 'test08.FPP') -env.Program(target = 'test09', source = 'test09.f77') -env.Program(target = 'test10', source = 'test10.F77') -env.Program(target = 'test11', source = 'test11.f90') -env.Program(target = 'test12', source = 'test12.F90') env.Program(target = 'test13', source = 'test13.f95') env.Program(target = 'test14', source = 'test14.F95') """ % locals()) @@ -121,10 +85,6 @@ test.write('test05.ftn', "This is a .ftn file.\n#link\n#fortran\n") test.write('test06.FTN', "This is a .FTN file.\n#link\n#fortran\n") test.write('test07.fpp', "This is a .fpp file.\n#link\n#fortran\n") test.write('test08.FPP', "This is a .FPP file.\n#link\n#fortran\n") -test.write('test09.f77', "This is a .f77 file.\n#link\n#fortran\n") -test.write('test10.F77', "This is a .F77 file.\n#link\n#fortran\n") -test.write('test11.f90', "This is a .f90 file.\n#link\n#fortran\n") -test.write('test12.F90', "This is a .F90 file.\n#link\n#fortran\n") test.write('test13.f95', "This is a .f95 file.\n#link\n#g95\n") test.write('test14.F95', "This is a .F95 file.\n#link\n#g95\n") @@ -138,17 +98,13 @@ test.must_match('test05' + _exe, " -c -y\nThis is a .ftn file.\n") test.must_match('test06' + _exe, " -c -y\nThis is a .FTN file.\n") test.must_match('test07' + _exe, " -c -y\nThis is a .fpp file.\n") test.must_match('test08' + _exe, " -c -y\nThis is a .FPP file.\n") -test.must_match('test09' + _exe, " -c -y\nThis is a .f77 file.\n") -test.must_match('test10' + _exe, " -c -y\nThis is a .F77 file.\n") -test.must_match('test11' + _exe, " -c -y\nThis is a .f90 file.\n") -test.must_match('test12' + _exe, " -c -y\nThis is a .F90 file.\n") test.must_match('test13' + _exe, " -c -x\nThis is a .f95 file.\n") test.must_match('test14' + _exe, " -c -x\nThis is a .F95 file.\n") +fc = 'f95' +g95 = test.detect_tool(fc) -g95 = test.detect('F95', 'g95') -FTN_LIB = TestSCons.fortran_lib if g95: @@ -161,23 +117,23 @@ os.system(string.join(sys.argv[1:], " ")) """ % string.replace(test.workpath('wrapper.out'), '\\', '\\\\')) test.write('SConstruct', """ -foo = Environment(LIBS = %(FTN_LIB)s) +foo = Environment(F95 = '%(fc)s') f95 = foo.Dictionary('F95') bar = foo.Clone(F95 = r'%(_python_)s wrapper.py ' + f95, F95FLAGS = '-Ix') -foo.Program(target = 'foo', source = 'foo.f') -bar.Program(target = 'bar', source = 'bar.f') +foo.Program(target = 'foo', source = 'foo.f95') +bar.Program(target = 'bar', source = 'bar.f95') """ % locals()) - test.write('foo.f', r""" + test.write('foo.f95', r""" PROGRAM FOO - PRINT *,'foo.f' + PRINT *,'foo.f95' STOP END """) - test.write('bar.f', r""" + test.write('bar.f95', r""" PROGRAM BAR - PRINT *,'bar.f' + PRINT *,'bar.f95' STOP END """) @@ -185,13 +141,17 @@ bar.Program(target = 'bar', source = 'bar.f') test.run(arguments = 'foo' + _exe, stderr = None) - test.run(program = test.workpath('foo'), stdout = " foo.f\n") + test.run(program = test.workpath('foo'), stdout = " foo.f95\n") test.must_not_exist('wrapper.out') - test.run(arguments = 'bar' + _exe) + import sys + if sys.platform[:5] == 'sunos': + test.run(arguments = 'bar' + _exe, stderr = None) + else: + test.run(arguments = 'bar' + _exe) - test.run(program = test.workpath('bar'), stdout = " bar.f\n") + test.run(program = test.workpath('bar'), stdout = " bar.f95\n") test.must_match('wrapper.out', "wrapper.py\n") diff --git a/test/Fortran/FORTRAN.py b/test/Fortran/FORTRAN.py index 235de74..768ff91 100644 --- a/test/Fortran/FORTRAN.py +++ b/test/Fortran/FORTRAN.py @@ -29,48 +29,14 @@ import string import sys import TestSCons +from common import write_fake_link + _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) -""") +write_fake_link(test) test.write('myg77.py', r""" import getopt @@ -98,12 +64,6 @@ env.Program(target = 'test05', source = 'test05.ftn') env.Program(target = 'test06', source = 'test06.FTN') env.Program(target = 'test07', source = 'test07.fpp') env.Program(target = 'test08', source = 'test08.FPP') -env.Program(target = 'test09', source = 'test09.f77') -env.Program(target = 'test10', source = 'test10.F77') -env.Program(target = 'test11', source = 'test11.f90') -env.Program(target = 'test12', source = 'test12.F90') -env.Program(target = 'test13', source = 'test13.f95') -env.Program(target = 'test14', source = 'test14.F95') """ % locals()) test.write('test01.f', "This is a .f file.\n#link\n#g77\n") @@ -114,12 +74,6 @@ test.write('test05.ftn', "This is a .ftn file.\n#link\n#g77\n") test.write('test06.FTN', "This is a .FTN file.\n#link\n#g77\n") test.write('test07.fpp', "This is a .fpp file.\n#link\n#g77\n") test.write('test08.FPP', "This is a .FPP file.\n#link\n#g77\n") -test.write('test09.f77', "This is a .f77 file.\n#link\n#g77\n") -test.write('test10.F77', "This is a .F77 file.\n#link\n#g77\n") -test.write('test11.f90', "This is a .f90 file.\n#link\n#g77\n") -test.write('test12.F90', "This is a .F90 file.\n#link\n#g77\n") -test.write('test13.f95', "This is a .f95 file.\n#link\n#g77\n") -test.write('test14.F95', "This is a .F95 file.\n#link\n#g77\n") test.run(arguments = '.', stderr = None) @@ -131,19 +85,14 @@ test.must_match('test05' + _exe, "This is a .ftn file.\n") test.must_match('test06' + _exe, "This is a .FTN file.\n") test.must_match('test07' + _exe, "This is a .fpp file.\n") test.must_match('test08' + _exe, "This is a .FPP file.\n") -test.must_match('test09' + _exe, "This is a .f77 file.\n") -test.must_match('test10' + _exe, "This is a .F77 file.\n") -test.must_match('test11' + _exe, "This is a .f90 file.\n") -test.must_match('test12' + _exe, "This is a .F90 file.\n") -test.must_match('test13' + _exe, "This is a .f95 file.\n") -test.must_match('test14' + _exe, "This is a .F95 file.\n") -g77 = test.detect('FORTRAN', 'g77') +fc = 'f77' +f77 = test.detect_tool(fc) FTN_LIB = TestSCons.fortran_lib -if g77: +if f77: test.write("wrapper.py", """import os @@ -154,7 +103,7 @@ os.system(string.join(sys.argv[1:], " ")) """ % string.replace(test.workpath('wrapper.out'), '\\', '\\\\')) test.write('SConstruct', """ -foo = Environment(LIBS = %(FTN_LIB)s) +foo = Environment(FORTRAN = '%(fc)s') f77 = foo.Dictionary('FORTRAN') bar = foo.Clone(FORTRAN = r'%(_python_)s wrapper.py ' + f77) foo.Program(target = 'foo', source = 'foo.f') @@ -182,7 +131,11 @@ bar.Program(target = 'bar', source = 'bar.f') test.must_not_exist('wrapper.out') - test.run(arguments = 'bar' + _exe) + import sys + if sys.platform[:5] == 'sunos': + test.run(arguments = 'bar' + _exe, stderr = None) + else: + test.run(arguments = 'bar' + _exe) test.run(program = test.workpath('bar'), stdout = " bar.f\n") diff --git a/test/Fortran/FORTRANCOM.py b/test/Fortran/FORTRANCOM.py index 3e3fcb2..c20f230 100644 --- a/test/Fortran/FORTRANCOM.py +++ b/test/Fortran/FORTRANCOM.py @@ -29,48 +29,14 @@ import string import sys import TestSCons +from common import write_fake_link + _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) -""") +write_fake_link(test) test.write('myfortran.py', r""" import sys @@ -96,12 +62,6 @@ env.Program(target = 'test05', source = 'test05.ftn') env.Program(target = 'test06', source = 'test06.FTN') env.Program(target = 'test07', source = 'test07.fpp') env.Program(target = 'test08', source = 'test08.FPP') -env.Program(target = 'test09', source = 'test09.f77') -env.Program(target = 'test10', source = 'test10.F77') -env.Program(target = 'test11', source = 'test11.f90') -env.Program(target = 'test12', source = 'test12.F90') -env.Program(target = 'test13', source = 'test13.f95') -env.Program(target = 'test14', source = 'test14.F95') """ % locals()) test.write('test01.f', "This is a .f file.\n#link\n#fortran\n") @@ -112,12 +72,6 @@ test.write('test05.ftn', "This is a .ftn file.\n#link\n#fortran\n") test.write('test06.FTN', "This is a .FTN file.\n#link\n#fortranpp\n") test.write('test07.fpp', "This is a .fpp file.\n#link\n#fortranpp\n") test.write('test08.FPP', "This is a .FPP file.\n#link\n#fortranpp\n") -test.write('test09.f77', "This is a .f77 file.\n#link\n#fortran\n") -test.write('test10.F77', "This is a .F77 file.\n#link\n#fortranpp\n") -test.write('test11.f90', "This is a .f90 file.\n#link\n#fortran\n") -test.write('test12.F90', "This is a .F90 file.\n#link\n#fortranpp\n") -test.write('test13.f95', "This is a .f95 file.\n#link\n#fortran\n") -test.write('test14.F95', "This is a .F95 file.\n#link\n#fortranpp\n") test.run(arguments = '.', stderr = None) @@ -129,11 +83,5 @@ test.must_match('test05' + _exe, "This is a .ftn file.\n") test.must_match('test06' + _exe, "This is a .FTN file.\n") test.must_match('test07' + _exe, "This is a .fpp file.\n") test.must_match('test08' + _exe, "This is a .FPP file.\n") -test.must_match('test09' + _exe, "This is a .f77 file.\n") -test.must_match('test10' + _exe, "This is a .F77 file.\n") -test.must_match('test11' + _exe, "This is a .f90 file.\n") -test.must_match('test12' + _exe, "This is a .F90 file.\n") -test.must_match('test13' + _exe, "This is a .f95 file.\n") -test.must_match('test14' + _exe, "This is a .F95 file.\n") test.pass_test() diff --git a/test/Fortran/FORTRANCOMSTR.py b/test/Fortran/FORTRANCOMSTR.py index f942669..e71c516 100644 --- a/test/Fortran/FORTRANCOMSTR.py +++ b/test/Fortran/FORTRANCOMSTR.py @@ -65,12 +65,6 @@ env.Object(source = 'test05.ftn') env.Object(source = 'test06.FTN') env.Object(source = 'test07.fpp') env.Object(source = 'test08.FPP') -env.Object(source = 'test09.f77') -env.Object(source = 'test10.F77') -env.Object(source = 'test11.f90') -env.Object(source = 'test12.F90') -env.Object(source = 'test13.f95') -env.Object(source = 'test14.F95') """ % locals()) test.write('test01.f', "A .f file.\n#fortran\n") @@ -81,12 +75,6 @@ test.write('test05.ftn', "A .ftn file.\n#fortran\n") test.write('test06.FTN', "A .FTN file.\n#%s\n" % fortranpp) test.write('test07.fpp', "A .fpp file.\n#fortranpp\n") test.write('test08.FPP', "A .FPP file.\n#fortranpp\n") -test.write('test09.f77', "A .f77 file.\n#fortran\n") -test.write('test10.F77', "A .F77 file.\n#%s\n" % fortranpp) -test.write('test11.f90', "A .f90 file.\n#fortran\n") -test.write('test12.F90', "A .F90 file.\n#%s\n" % fortranpp) -test.write('test13.f95', "A .f95 file.\n#fortran\n") -test.write('test14.F95', "A .F95 file.\n#%s\n" % fortranpp) test.run(stdout = test.wrap_stdout("""\ Building fortran test01.obj from test01.f @@ -97,12 +85,6 @@ Building fortran test05.obj from test05.ftn Building %(fortranpp)s test06.obj from test06.FTN Building fortranpp test07.obj from test07.fpp Building fortranpp test08.obj from test08.FPP -Building fortran test09.obj from test09.f77 -Building %(fortranpp)s test10.obj from test10.F77 -Building fortran test11.obj from test11.f90 -Building %(fortranpp)s test12.obj from test12.F90 -Building fortran test13.obj from test13.f95 -Building %(fortranpp)s test14.obj from test14.F95 """ % locals())) test.must_match('test01.obj', "A .f file.\n") @@ -113,11 +95,5 @@ test.must_match('test05.obj', "A .ftn file.\n") test.must_match('test06.obj', "A .FTN file.\n") test.must_match('test07.obj', "A .fpp file.\n") test.must_match('test08.obj', "A .FPP file.\n") -test.must_match('test09.obj', "A .f77 file.\n") -test.must_match('test10.obj', "A .F77 file.\n") -test.must_match('test11.obj', "A .f90 file.\n") -test.must_match('test12.obj', "A .F90 file.\n") -test.must_match('test13.obj', "A .f95 file.\n") -test.must_match('test14.obj', "A .F95 file.\n") test.pass_test() diff --git a/test/Fortran/FORTRANFILESUFFIXES.py b/test/Fortran/FORTRANFILESUFFIXES.py new file mode 100644 index 0000000..01642e0 --- /dev/null +++ b/test/Fortran/FORTRANFILESUFFIXES.py @@ -0,0 +1,91 @@ +#!/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 + +from common import write_fake_link + +_python_ = TestSCons._python_ +_exe = TestSCons._exe + +test = TestSCons.TestSCons() + +write_fake_link(test) + +test.write('myfortran.py', r""" +import getopt +import sys +comment = '#' + sys.argv[1] +opts, args = getopt.getopt(sys.argv[2:], '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[:len(comment)] != comment: + outfile.write(l) +sys.exit(0) +""") + +# Test default file suffix: .f/.F for FORTRAN +test.write('SConstruct', """ +env = Environment(LINK = r'%(_python_)s mylink.py', + LINKFLAGS = [], + FORTRAN = r'%(_python_)s myfortran.py fortran') +env.Program(target = 'test01', source = 'test01.f') +env.Program(target = 'test02', source = 'test02.F') +env.Program(target = 'test03', source = 'test03.for') +env.Program(target = 'test04', source = 'test04.FOR') +env.Program(target = 'test05', source = 'test05.ftn') +env.Program(target = 'test06', source = 'test06.FTN') +env.Program(target = 'test07', source = 'test07.fpp') +env.Program(target = 'test08', source = 'test08.FPP') +""" % locals()) + +test.write('test01.f', "This is a .f file.\n#link\n#fortran\n") +test.write('test02.F', "This is a .F file.\n#link\n#fortran\n") +test.write('test03.for', "This is a .for file.\n#link\n#fortran\n") +test.write('test04.FOR', "This is a .FOR file.\n#link\n#fortran\n") +test.write('test05.ftn', "This is a .ftn file.\n#link\n#fortran\n") +test.write('test06.FTN', "This is a .FTN file.\n#link\n#fortran\n") +test.write('test07.fpp', "This is a .fpp file.\n#link\n#fortran\n") +test.write('test08.FPP', "This is a .FPP file.\n#link\n#fortran\n") + +test.run(arguments = '.', stderr = None) + +test.must_match('test01' + _exe, "This is a .f file.\n") +test.must_match('test02' + _exe, "This is a .F file.\n") +test.must_match('test03' + _exe, "This is a .for file.\n") +test.must_match('test04' + _exe, "This is a .FOR file.\n") +test.must_match('test05' + _exe, "This is a .ftn file.\n") +test.must_match('test06' + _exe, "This is a .FTN file.\n") +test.must_match('test07' + _exe, "This is a .fpp file.\n") +test.must_match('test08' + _exe, "This is a .FPP file.\n") + +test.pass_test() diff --git a/test/Fortran/FORTRANFILESUFFIXES2.py b/test/Fortran/FORTRANFILESUFFIXES2.py new file mode 100644 index 0000000..4cfcc07 --- /dev/null +++ b/test/Fortran/FORTRANFILESUFFIXES2.py @@ -0,0 +1,86 @@ +#!/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 + +from common import write_fake_link + +_python_ = TestSCons._python_ +_exe = TestSCons._exe + +test = TestSCons.TestSCons() + +write_fake_link(test) + +test.write('myfortran.py', r""" +import getopt +import sys +comment = '#' + sys.argv[1] +opts, args = getopt.getopt(sys.argv[2:], '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[:len(comment)] != comment: + outfile.write(l) +sys.exit(0) +""") + +# Test non default file suffix: .f, .f90 and .f95 for FORTRAN +test.write('SConstruct', """ +env = Environment(LINK = r'%(_python_)s mylink.py', + LINKFLAGS = [], + F77 = r'%(_python_)s myfortran.py g77', + FORTRAN = r'%(_python_)s myfortran.py fortran', + FORTRANFILESUFFIXES = ['.f', '.f95', '.f90', '.ffake'], + tools = ['default', 'fortran']) +#print env.Dump() +env.Program(target = 'test01', source = 'test01.f') +env.Program(target = 'test02', source = 'test02.f90') +env.Program(target = 'test03', source = 'test03.f95') +env.Program(target = 'test04', source = 'test04.ffake') +env.Program(target = 'test05', source = 'test05.f77') +""" % locals()) + +test.write('test01.f', "This is a .f file.\n#link\n#fortran\n") +test.write('test02.f90', "This is a .f90 file.\n#link\n#fortran\n") +test.write('test03.f95', "This is a .f95 file.\n#link\n#fortran\n") +test.write('test04.ffake', "This is a .ffake file.\n#link\n#fortran\n") +test.write('test05.f77', "This is a .f77 file.\n#link\n#g77\n") + +test.run(arguments = '.', stderr = None) + +test.must_match('test01' + _exe, "This is a .f file.\n") +test.must_match('test02' + _exe, "This is a .f90 file.\n") +test.must_match('test03' + _exe, "This is a .f95 file.\n") +test.must_match('test04' + _exe, "This is a .ffake file.\n") +test.must_match('test05' + _exe, "This is a .f77 file.\n") + +test.pass_test() diff --git a/test/Fortran/FORTRANFLAGS.py b/test/Fortran/FORTRANFLAGS.py index 8ae00f8..e3a8c9b 100644 --- a/test/Fortran/FORTRANFLAGS.py +++ b/test/Fortran/FORTRANFLAGS.py @@ -29,46 +29,14 @@ import string import sys import TestSCons +from common import write_fake_link + _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) -""") +write_fake_link(test) test.write('myfortran.py', r""" import getopt @@ -102,12 +70,6 @@ env.Program(target = 'test05', source = 'test05.ftn') env.Program(target = 'test06', source = 'test06.FTN') env.Program(target = 'test07', source = 'test07.fpp') env.Program(target = 'test08', source = 'test08.FPP') -env.Program(target = 'test09', source = 'test09.f77') -env.Program(target = 'test10', source = 'test10.F77') -env.Program(target = 'test11', source = 'test11.f90') -env.Program(target = 'test12', source = 'test12.F90') -env.Program(target = 'test13', source = 'test13.f95') -env.Program(target = 'test14', source = 'test14.F95') """ % locals()) test.write('test01.f', "This is a .f file.\n#link\n#fortran\n") @@ -118,12 +80,6 @@ test.write('test05.ftn', "This is a .ftn file.\n#link\n#fortran\n") test.write('test06.FTN', "This is a .FTN file.\n#link\n#fortran\n") test.write('test07.fpp', "This is a .fpp file.\n#link\n#fortran\n") test.write('test08.FPP', "This is a .FPP file.\n#link\n#fortran\n") -test.write('test09.f77', "This is a .f77 file.\n#link\n#fortran\n") -test.write('test10.F77', "This is a .F77 file.\n#link\n#fortran\n") -test.write('test11.f90', "This is a .f90 file.\n#link\n#fortran\n") -test.write('test12.F90', "This is a .F90 file.\n#link\n#fortran\n") -test.write('test13.f95', "This is a .f95 file.\n#link\n#fortran\n") -test.write('test14.F95', "This is a .F95 file.\n#link\n#fortran\n") test.run(arguments = '.', stderr = None) @@ -135,17 +91,10 @@ test.must_match('test05' + _exe, " -c -x\nThis is a .ftn file.\n") test.must_match('test06' + _exe, " -c -x\nThis is a .FTN file.\n") test.must_match('test07' + _exe, " -c -x\nThis is a .fpp file.\n") test.must_match('test08' + _exe, " -c -x\nThis is a .FPP file.\n") -test.must_match('test09' + _exe, " -c -x\nThis is a .f77 file.\n") -test.must_match('test10' + _exe, " -c -x\nThis is a .F77 file.\n") -test.must_match('test11' + _exe, " -c -x\nThis is a .f90 file.\n") -test.must_match('test12' + _exe, " -c -x\nThis is a .F90 file.\n") -test.must_match('test13' + _exe, " -c -x\nThis is a .f95 file.\n") -test.must_match('test14' + _exe, " -c -x\nThis is a .F95 file.\n") - -g77 = test.detect('FORTRAN', 'g77') -FTN_LIB = TestSCons.fortran_lib +fc = 'f77' +g77 = test.detect_tool(fc) if g77: @@ -158,7 +107,7 @@ os.system(string.join(sys.argv[1:], " ")) """ % string.replace(test.workpath('wrapper.out'), '\\', '\\\\')) test.write('SConstruct', """ -foo = Environment(LIBS = %(FTN_LIB)s) +foo = Environment(FORTRAN = '%(fc)s') f77 = foo.Dictionary('FORTRAN') bar = foo.Clone(FORTRAN = r'%(_python_)s wrapper.py ' + f77, FORTRANFLAGS = '-Ix') foo.Program(target = 'foo', source = 'foo.f') @@ -186,7 +135,11 @@ bar.Program(target = 'bar', source = 'bar.f') test.must_not_exist('wrapper.out') - test.run(arguments = 'bar' + _exe) + import sys + if sys.platform[:5] == 'sunos': + test.run(arguments = 'bar' + _exe, stderr = None) + else: + test.run(arguments = 'bar' + _exe) test.run(program = test.workpath('bar'), stdout = " bar.f\n") diff --git a/test/Fortran/FORTRANPATH.py b/test/Fortran/FORTRANPATH.py index 5f9d022..d5f2cb1 100644 --- a/test/Fortran/FORTRANPATH.py +++ b/test/Fortran/FORTRANPATH.py @@ -29,7 +29,6 @@ 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) @@ -38,8 +37,9 @@ args = prog + ' ' + subdir_prog + ' ' + variant_prog test = TestSCons.TestSCons() -if not test.detect('_FORTRANG', 'g77'): - test.skip_test('Could not find a $F77 tool; skipping test.\n') +fc = 'f77' +if not test.detect_tool(fc): + test.skip_test('Could not find a f77 tool; skipping test.\n') test.subdir('include', 'subdir', @@ -50,18 +50,19 @@ test.subdir('include', test.write('SConstruct', """ -env = Environment(FORTRANPATH = ['$FOO', '${TARGET.dir}', '${SOURCE.dir}'], - LIBS = %s, FOO='include') +env = Environment(FORTRAN = '%s', + FORTRANPATH = ['$FOO', '${TARGET.dir}', '${SOURCE.dir}'], + FOO='include') obj = env.Object(target='foobar/prog', source='subdir/prog.f') env.Program(target='prog', source=obj) SConscript('subdir/SConscript', "env") VariantDir('variant', 'subdir', 0) include = Dir('include') -env = Environment(FORTRANPATH=[include, '#foobar', '#subdir'], - LIBS = %s) +env = Environment(FORTRAN = '%s', + FORTRANPATH=[include, '#foobar', '#subdir']) SConscript('variant/SConscript', "env") -""" % (FTN_LIB, FTN_LIB)) +""" % (fc, fc)) test.write(['subdir', 'SConscript'], """ @@ -113,8 +114,12 @@ r""" """) - -test.run(arguments = args) +import sys +if sys.platform[:5] == 'sunos': + # Sun f77 always put some junk in stderr + test.run(arguments = args, stderr = None) +else: + test.run(arguments = args) test.run(program = test.workpath(prog), stdout = """\ @@ -156,7 +161,11 @@ r""" INCLUDE 'bar.f' """) -test.run(arguments = args) +if sys.platform[:5] == 'sunos': + # Sun f77 always put some junk in stderr + test.run(arguments = args, stderr = None) +else: + test.run(arguments = args) test.run(program = test.workpath(prog), stdout = """\ @@ -198,7 +207,12 @@ r""" PRINT *, 'include/bar.f 2' """) -test.run(arguments = args) +if sys.platform[:5] == 'sunos': + # Sun f77 always put some junk in stderr + test.run(arguments = args, stderr = None) +else: + test.run(arguments = args) + test.run(program = test.workpath(prog), stdout = """\ @@ -236,18 +250,18 @@ test.up_to_date(arguments = args) # Change FORTRANPATH and make sure we don't rebuild because of it. test.write('SConstruct', """ -env = Environment(FORTRANPATH = Split('inc2 include ${TARGET.dir} ${SOURCE.dir}'), - LIBS = %s) +env = Environment(FORTRAN = '%s', + FORTRANPATH = Split('inc2 include ${TARGET.dir} ${SOURCE.dir}')) obj = env.Object(target='foobar/prog', source='subdir/prog.f') env.Program(target='prog', source=obj) SConscript('subdir/SConscript', "env") VariantDir('variant', 'subdir', 0) include = Dir('include') -env = Environment(FORTRANPATH=['inc2', include, '#foobar', '#subdir'], - LIBS = %s) +env = Environment(FORTRAN = '%s', + FORTRANPATH=['inc2', include, '#foobar', '#subdir']) SConscript('variant/SConscript', "env") -""" % (FTN_LIB, FTN_LIB)) +""" % (fc, fc)) test.up_to_date(arguments = args) @@ -260,7 +274,12 @@ r""" INCLUDE 'bar.f' """) -test.run(arguments = args) +if sys.platform[:5] == 'sunos': + # Sun f77 always put some junk in stderr + test.run(arguments = args, stderr = None) +else: + test.run(arguments = args) + test.run(program = test.workpath(prog), stdout = """\ @@ -295,14 +314,16 @@ test.up_to_date(arguments = args) # Check that a null-string FORTRANPATH doesn't blow up. test.write('SConstruct', """ -env = Environment(FORTRANPATH = '', LIBS = %s) +env = Environment(FORTRANPATH = '') env.Object('foo', source = 'empty.f') -""" % FTN_LIB) +""") test.write('empty.f', '') -test.run(arguments = '.') - - +if sys.platform[:5] == 'sunos': + # Sun f77 always put some junk in stderr + test.run(arguments = '.', stderr = None) +else: + test.run(arguments = '.') test.pass_test() diff --git a/test/Fortran/SHF77.py b/test/Fortran/SHF77.py index 3f1f7e7..3671449 100644 --- a/test/Fortran/SHF77.py +++ b/test/Fortran/SHF77.py @@ -31,6 +31,7 @@ import TestSCons _python_ = TestSCons._python_ _obj = TestSCons._shobj +obj_ = TestSCons.shobj_ test = TestSCons.TestSCons() @@ -40,7 +41,7 @@ test.write('myfortran.py', r""" import getopt import sys comment = '#' + sys.argv[1] -opts, args = getopt.getopt(sys.argv[2:], 'cf:o:') +opts, args = getopt.getopt(sys.argv[2:], 'cf:o:K:') for opt, arg in opts: if opt == '-o': out = arg infile = open(args[0], 'rb') @@ -66,19 +67,6 @@ env.SharedObject(target = 'test07', source = 'test07.fpp') env.SharedObject(target = 'test08', source = 'test08.FPP') env.SharedObject(target = 'test09', source = 'test09.f77') env.SharedObject(target = 'test10', source = 'test10.F77') -env.SharedObject(target = 'test11', source = 'test11.f90') -env.SharedObject(target = 'test12', source = 'test12.F90') -env.SharedObject(target = 'test13', source = 'test13.f95') -env.SharedObject(target = 'test14', source = 'test14.F95') -env2 = Environment(SHF77 = r'%(_python_)s myfortran.py g77') -env2.SharedObject(target = 'test21', source = 'test21.f') -env2.SharedObject(target = 'test22', source = 'test22.F') -env2.SharedObject(target = 'test23', source = 'test23.for') -env2.SharedObject(target = 'test24', source = 'test24.FOR') -env2.SharedObject(target = 'test25', source = 'test25.ftn') -env2.SharedObject(target = 'test26', source = 'test26.FTN') -env2.SharedObject(target = 'test27', source = 'test27.fpp') -env2.SharedObject(target = 'test28', source = 'test28.FPP') """ % locals()) test.write('test01.f', "This is a .f file.\n#fortran\n") @@ -91,51 +79,23 @@ test.write('test07.fpp', "This is a .fpp file.\n#fortran\n") test.write('test08.FPP', "This is a .FPP file.\n#fortran\n") test.write('test09.f77', "This is a .f77 file.\n#g77\n") test.write('test10.F77', "This is a .F77 file.\n#g77\n") -test.write('test11.f90', "This is a .f90 file.\n#fortran\n") -test.write('test12.F90', "This is a .F90 file.\n#fortran\n") -test.write('test13.f95', "This is a .f95 file.\n#fortran\n") -test.write('test14.F95', "This is a .F95 file.\n#fortran\n") - -test.write('test21.f', "This is a .f file.\n#g77\n") -test.write('test22.F', "This is a .F file.\n#g77\n") -test.write('test23.for', "This is a .for file.\n#g77\n") -test.write('test24.FOR', "This is a .FOR file.\n#g77\n") -test.write('test25.ftn', "This is a .ftn file.\n#g77\n") -test.write('test26.FTN', "This is a .FTN file.\n#g77\n") -test.write('test27.fpp', "This is a .fpp file.\n#g77\n") -test.write('test28.FPP', "This is a .FPP file.\n#g77\n") test.run(arguments = '.', stderr = None) -test.must_match('test01' + _obj, "This is a .f file.\n") -test.must_match('test02' + _obj, "This is a .F file.\n") -test.must_match('test03' + _obj, "This is a .for file.\n") -test.must_match('test04' + _obj, "This is a .FOR file.\n") -test.must_match('test05' + _obj, "This is a .ftn file.\n") -test.must_match('test06' + _obj, "This is a .FTN file.\n") -test.must_match('test07' + _obj, "This is a .fpp file.\n") -test.must_match('test08' + _obj, "This is a .FPP file.\n") -test.must_match('test09' + _obj, "This is a .f77 file.\n") -test.must_match('test10' + _obj, "This is a .F77 file.\n") -test.must_match('test11' + _obj, "This is a .f90 file.\n") -test.must_match('test12' + _obj, "This is a .F90 file.\n") -test.must_match('test13' + _obj, "This is a .f95 file.\n") -test.must_match('test14' + _obj, "This is a .F95 file.\n") +test.must_match(obj_ + 'test01' + _obj, "This is a .f file.\n") +test.must_match(obj_ + 'test02' + _obj, "This is a .F file.\n") +test.must_match(obj_ + 'test03' + _obj, "This is a .for file.\n") +test.must_match(obj_ + 'test04' + _obj, "This is a .FOR file.\n") +test.must_match(obj_ + 'test05' + _obj, "This is a .ftn file.\n") +test.must_match(obj_ + 'test06' + _obj, "This is a .FTN file.\n") +test.must_match(obj_ + 'test07' + _obj, "This is a .fpp file.\n") +test.must_match(obj_ + 'test08' + _obj, "This is a .FPP file.\n") +test.must_match(obj_ + 'test09' + _obj, "This is a .f77 file.\n") -test.must_match('test21' + _obj, "This is a .f file.\n") -test.must_match('test22' + _obj, "This is a .F file.\n") -test.must_match('test23' + _obj, "This is a .for file.\n") -test.must_match('test24' + _obj, "This is a .FOR file.\n") -test.must_match('test25' + _obj, "This is a .ftn file.\n") -test.must_match('test26' + _obj, "This is a .FTN file.\n") -test.must_match('test27' + _obj, "This is a .fpp file.\n") -test.must_match('test28' + _obj, "This is a .FPP file.\n") +fc = 'f77' +f77 = test.detect_tool(fc) - - -g77 = test.detect('F77', 'g77') - -if g77: +if f77: test.write("wrapper.py", """import os @@ -146,9 +106,9 @@ os.system(string.join(sys.argv[1:], " ")) """ % string.replace(test.workpath('wrapper.out'), '\\', '\\\\')) test.write('SConstruct', """ -foo = Environment(LIBS = 'g2c') +foo = Environment(SHF77 = '%(fc)s') shf77 = foo.Dictionary('SHF77') -bar = foo.Clone(SHF77 = r'%(_python_)s wrapper.py ' + shf77) +bar = foo.Clone(SHF77 = r'%(_python_)s wrapper.py ' + shf77, tools = ['default', 'f77'], F77FILESUFFIXES = ['.f']) foo.SharedObject(target = 'foo/foo', source = 'foo.f') bar.SharedObject(target = 'bar/bar', source = 'bar.f') """ % locals()) @@ -172,7 +132,11 @@ bar.SharedObject(target = 'bar/bar', source = 'bar.f') test.must_not_exist('wrapper.out') - test.run(arguments = 'bar') + import sys + if sys.platform[:5] == 'sunos': + test.run(arguments = 'bar', stderr = None) + else: + test.run(arguments = 'bar') test.must_match('wrapper.out', "wrapper.py\n") diff --git a/test/Fortran/SHF77COM.py b/test/Fortran/SHF77COM.py index 75192df..fcb25e5 100644 --- a/test/Fortran/SHF77COM.py +++ b/test/Fortran/SHF77COM.py @@ -31,6 +31,7 @@ import TestSCons _python_ = TestSCons._python_ _obj = TestSCons._shobj +obj_ = TestSCons.shobj_ test = TestSCons.TestSCons() @@ -64,22 +65,6 @@ env.SharedObject(target = 'test07', source = 'test07.fpp') env.SharedObject(target = 'test08', source = 'test08.FPP') env.SharedObject(target = 'test09', source = 'test09.f77') env.SharedObject(target = 'test10', source = 'test10.F77') -env.SharedObject(target = 'test11', source = 'test11.f90') -env.SharedObject(target = 'test12', source = 'test12.F90') -env.SharedObject(target = 'test13', source = 'test13.f95') -env.SharedObject(target = 'test14', source = 'test14.F95') -env2 = Environment(SHF77COM = r'%(_python_)s myfortran.py f77 $TARGET $SOURCES', - SHF77PPCOM = r'%(_python_)s myfortran.py f77pp $TARGET $SOURCES') -env2.SharedObject(target = 'test21', source = 'test21.f') -env2.SharedObject(target = 'test22', source = 'test22.F') -env2.SharedObject(target = 'test23', source = 'test23.for') -env2.SharedObject(target = 'test24', source = 'test24.FOR') -env2.SharedObject(target = 'test25', source = 'test25.ftn') -env2.SharedObject(target = 'test26', source = 'test26.FTN') -env2.SharedObject(target = 'test27', source = 'test27.fpp') -env2.SharedObject(target = 'test28', source = 'test28.FPP') -env2.SharedObject(target = 'test29', source = 'test29.f77') -env2.SharedObject(target = 'test30', source = 'test30.F77') """ % locals()) test.write('test01.f', "This is a .f file.\n#fortran\n") @@ -92,48 +77,18 @@ test.write('test07.fpp', "This is a .fpp file.\n#fortranpp\n") test.write('test08.FPP', "This is a .FPP file.\n#fortranpp\n") test.write('test09.f77', "This is a .f77 file.\n#f77\n") test.write('test10.F77', "This is a .F77 file.\n#f77pp\n") -test.write('test11.f90', "This is a .f90 file.\n#fortran\n") -test.write('test12.F90', "This is a .F90 file.\n#fortranpp\n") -test.write('test13.f95', "This is a .f95 file.\n#fortran\n") -test.write('test14.F95', "This is a .F95 file.\n#fortranpp\n") - -test.write('test21.f', "This is a .f file.\n#f77\n") -test.write('test22.F', "This is a .F file.\n#f77pp\n") -test.write('test23.for', "This is a .for file.\n#f77\n") -test.write('test24.FOR', "This is a .FOR file.\n#f77pp\n") -test.write('test25.ftn', "This is a .ftn file.\n#f77\n") -test.write('test26.FTN', "This is a .FTN file.\n#f77pp\n") -test.write('test27.fpp', "This is a .fpp file.\n#f77pp\n") -test.write('test28.FPP', "This is a .FPP file.\n#f77pp\n") -test.write('test29.f77', "This is a .f77 file.\n#f77\n") -test.write('test30.F77', "This is a .F77 file.\n#f77pp\n") test.run(arguments = '.', stderr = None) -test.must_match('test01' + _obj, "This is a .f file.\n") -test.must_match('test02' + _obj, "This is a .F file.\n") -test.must_match('test03' + _obj, "This is a .for file.\n") -test.must_match('test04' + _obj, "This is a .FOR file.\n") -test.must_match('test05' + _obj, "This is a .ftn file.\n") -test.must_match('test06' + _obj, "This is a .FTN file.\n") -test.must_match('test07' + _obj, "This is a .fpp file.\n") -test.must_match('test08' + _obj, "This is a .FPP file.\n") -test.must_match('test09' + _obj, "This is a .f77 file.\n") -test.must_match('test10' + _obj, "This is a .F77 file.\n") -test.must_match('test11' + _obj, "This is a .f90 file.\n") -test.must_match('test12' + _obj, "This is a .F90 file.\n") -test.must_match('test13' + _obj, "This is a .f95 file.\n") -test.must_match('test14' + _obj, "This is a .F95 file.\n") - -test.must_match('test21' + _obj, "This is a .f file.\n") -test.must_match('test22' + _obj, "This is a .F file.\n") -test.must_match('test23' + _obj, "This is a .for file.\n") -test.must_match('test24' + _obj, "This is a .FOR file.\n") -test.must_match('test25' + _obj, "This is a .ftn file.\n") -test.must_match('test26' + _obj, "This is a .FTN file.\n") -test.must_match('test27' + _obj, "This is a .fpp file.\n") -test.must_match('test28' + _obj, "This is a .FPP file.\n") -test.must_match('test29' + _obj, "This is a .f77 file.\n") -test.must_match('test30' + _obj, "This is a .F77 file.\n") +test.must_match(obj_ + 'test01' + _obj, "This is a .f file.\n") +test.must_match(obj_ + 'test02' + _obj, "This is a .F file.\n") +test.must_match(obj_ + 'test03' + _obj, "This is a .for file.\n") +test.must_match(obj_ + 'test04' + _obj, "This is a .FOR file.\n") +test.must_match(obj_ + 'test05' + _obj, "This is a .ftn file.\n") +test.must_match(obj_ + 'test06' + _obj, "This is a .FTN file.\n") +test.must_match(obj_ + 'test07' + _obj, "This is a .fpp file.\n") +test.must_match(obj_ + 'test08' + _obj, "This is a .FPP file.\n") +test.must_match(obj_ + 'test09' + _obj, "This is a .f77 file.\n") +test.must_match(obj_ + 'test10' + _obj, "This is a .F77 file.\n") test.pass_test() diff --git a/test/Fortran/SHF77COMSTR.py b/test/Fortran/SHF77COMSTR.py index 4f08e26..7a8cbe1 100644 --- a/test/Fortran/SHF77COMSTR.py +++ b/test/Fortran/SHF77COMSTR.py @@ -57,14 +57,6 @@ env = Environment(SHF77COM = r'%(_python_)s myfc.py f77 $TARGET $SOURCES', SHF77PPCOM = r'%(_python_)s myfc.py f77pp $TARGET $SOURCES', SHF77PPCOMSTR = 'Building f77pp $TARGET from $SOURCES', SHOBJPREFIX='', SHOBJSUFFIX='.shobj') -env.SharedObject(source = 'test01.f') -env.SharedObject(source = 'test02.F') -env.SharedObject(source = 'test03.for') -env.SharedObject(source = 'test04.FOR') -env.SharedObject(source = 'test05.ftn') -env.SharedObject(source = 'test06.FTN') -env.SharedObject(source = 'test07.fpp') -env.SharedObject(source = 'test08.FPP') env.SharedObject(source = 'test09.f77') env.SharedObject(source = 'test10.F77') """ % locals()) @@ -81,26 +73,10 @@ test.write('test09.f77', "A .f77 file.\n#f77\n") test.write('test10.F77', "A .F77 file.\n#%s\n" % f77pp) test.run(stdout = test.wrap_stdout("""\ -Building f77 test01.shobj from test01.f -Building %(f77pp)s test02.shobj from test02.F -Building f77 test03.shobj from test03.for -Building %(f77pp)s test04.shobj from test04.FOR -Building f77 test05.shobj from test05.ftn -Building %(f77pp)s test06.shobj from test06.FTN -Building f77pp test07.shobj from test07.fpp -Building f77pp test08.shobj from test08.FPP Building f77 test09.shobj from test09.f77 Building %(f77pp)s test10.shobj from test10.F77 """ % locals())) -test.must_match('test01.shobj', "A .f file.\n") -test.must_match('test02.shobj', "A .F file.\n") -test.must_match('test03.shobj', "A .for file.\n") -test.must_match('test04.shobj', "A .FOR file.\n") -test.must_match('test05.shobj', "A .ftn file.\n") -test.must_match('test06.shobj', "A .FTN file.\n") -test.must_match('test07.shobj', "A .fpp file.\n") -test.must_match('test08.shobj', "A .FPP file.\n") test.must_match('test09.shobj', "A .f77 file.\n") test.must_match('test10.shobj', "A .F77 file.\n") diff --git a/test/Fortran/SHF77FLAGS.py b/test/Fortran/SHF77FLAGS.py index 5099edf..4570ebc 100644 --- a/test/Fortran/SHF77FLAGS.py +++ b/test/Fortran/SHF77FLAGS.py @@ -31,13 +31,8 @@ import TestSCons _python_ = TestSCons._python_ -if sys.platform == 'win32': - _obj = '.obj' -else: - if string.find(sys.platform, 'irix') > -1: - _obj = '.o' - else: - _obj = '.os' +_obj = TestSCons._shobj +obj_ = TestSCons.shobj_ test = TestSCons.TestSCons() @@ -46,11 +41,11 @@ test = TestSCons.TestSCons() test.write('myg77.py', r""" import getopt import sys -opts, args = getopt.getopt(sys.argv[1:], 'co:x') +opts, args = getopt.getopt(sys.argv[1:], 'cf:o:x') optstring = '' for opt, arg in opts: if opt == '-o': out = arg - else: optstring = optstring + ' ' + opt + elif opt != '-f': optstring = optstring + ' ' + opt infile = open(args[0], 'rb') outfile = open(out, 'wb') outfile.write(optstring + "\n") @@ -63,48 +58,23 @@ sys.exit(0) test.write('SConstruct', """ -env = Environment(SHF77 = r'%(_python_)s myg77.py', - SHF77FLAGS = '-x') -env.SharedObject(target = 'test01', source = 'test01.f') -env.SharedObject(target = 'test02', source = 'test02.F') -env.SharedObject(target = 'test03', source = 'test03.for') -env.SharedObject(target = 'test04', source = 'test04.FOR') -env.SharedObject(target = 'test05', source = 'test05.ftn') -env.SharedObject(target = 'test06', source = 'test06.FTN') -env.SharedObject(target = 'test07', source = 'test07.fpp') -env.SharedObject(target = 'test08', source = 'test08.FPP') +env = Environment(SHF77 = r'%(_python_)s myg77.py') +env.Append(SHF77FLAGS = '-x') env.SharedObject(target = 'test09', source = 'test09.f77') env.SharedObject(target = 'test10', source = 'test10.F77') """ % locals()) -test.write('test01.f', "This is a .f file.\n#g77\n") -test.write('test02.F', "This is a .F file.\n#g77\n") -test.write('test03.for', "This is a .for file.\n#g77\n") -test.write('test04.FOR', "This is a .FOR file.\n#g77\n") -test.write('test05.ftn', "This is a .ftn file.\n#g77\n") -test.write('test06.FTN', "This is a .FTN file.\n#g77\n") -test.write('test07.fpp', "This is a .fpp file.\n#g77\n") -test.write('test08.FPP', "This is a .FPP file.\n#g77\n") test.write('test09.f77', "This is a .f77 file.\n#g77\n") test.write('test10.F77', "This is a .F77 file.\n#g77\n") test.run(arguments = '.', stderr = None) -test.must_match('test01' + _obj, " -c -x\nThis is a .f file.\n") -test.must_match('test02' + _obj, " -c -x\nThis is a .F file.\n") -test.must_match('test03' + _obj, " -c -x\nThis is a .for file.\n") -test.must_match('test04' + _obj, " -c -x\nThis is a .FOR file.\n") -test.must_match('test05' + _obj, " -c -x\nThis is a .ftn file.\n") -test.must_match('test06' + _obj, " -c -x\nThis is a .FTN file.\n") -test.must_match('test07' + _obj, " -c -x\nThis is a .fpp file.\n") -test.must_match('test08' + _obj, " -c -x\nThis is a .FPP file.\n") -test.must_match('test09' + _obj, " -c -x\nThis is a .f77 file.\n") -test.must_match('test10' + _obj, " -c -x\nThis is a .F77 file.\n") - +test.must_match(obj_ + 'test09' + _obj, " -c -x\nThis is a .f77 file.\n") +test.must_match(obj_ + 'test10' + _obj, " -c -x\nThis is a .F77 file.\n") -g77 = test.detect('F77', 'g77') -FTN_LIB = TestSCons.fortran_lib +fc = 'f77' +g77 = test.detect_tool(fc) if g77: @@ -117,9 +87,11 @@ os.system(string.join(sys.argv[1:], " ")) """ % string.replace(test.workpath('wrapper.out'), '\\', '\\\\')) test.write('SConstruct', """ -foo = Environment(LIBS = %(FTN_LIB)s) +foo = Environment(SHF77 = '%(fc)s') shf77 = foo.Dictionary('SHF77') -bar = foo.Clone(SHF77 = r'%(_python_)s wrapper.py ' + shf77, SHF77FLAGS = '-Ix') +bar = foo.Clone(SHF77 = r'%(_python_)s wrapper.py ' + shf77, + tools = ["default", 'f77'], F77FILESUFFIXES = [".f"]) +bar.Append(SHF77FLAGS = '-Ix') foo.SharedLibrary(target = 'foo/foo', source = 'foo.f') bar.SharedLibrary(target = 'bar/bar', source = 'bar.f') """ % locals()) @@ -143,7 +115,11 @@ bar.SharedLibrary(target = 'bar/bar', source = 'bar.f') test.must_not_exist('wrapper.out') - test.run(arguments = 'bar') + import sys + if sys.platform[:5] == 'sunos': + test.run(arguments = 'bar', stderr = None) + else: + test.run(arguments = 'bar') test.must_match('wrapper.out', "wrapper.py\n") diff --git a/test/Fortran/SHF90.py b/test/Fortran/SHF90.py index 36d0a31..a045acf 100644 --- a/test/Fortran/SHF90.py +++ b/test/Fortran/SHF90.py @@ -31,6 +31,7 @@ import TestSCons _python_ = TestSCons._python_ _obj = TestSCons._shobj +obj_ = TestSCons.shobj_ test = TestSCons.TestSCons() @@ -40,7 +41,7 @@ test.write('myfortran.py', r""" import getopt import sys comment = '#' + sys.argv[1] -opts, args = getopt.getopt(sys.argv[2:], 'cf:o:') +opts, args = getopt.getopt(sys.argv[2:], 'cf:o:K:') for opt, arg in opts: if opt == '-o': out = arg infile = open(args[0], 'rb') @@ -64,12 +65,8 @@ env.SharedObject(target = 'test05', source = 'test05.ftn') env.SharedObject(target = 'test06', source = 'test06.FTN') env.SharedObject(target = 'test07', source = 'test07.fpp') env.SharedObject(target = 'test08', source = 'test08.FPP') -env.SharedObject(target = 'test09', source = 'test09.f77') -env.SharedObject(target = 'test10', source = 'test10.F77') env.SharedObject(target = 'test11', source = 'test11.f90') env.SharedObject(target = 'test12', source = 'test12.F90') -env.SharedObject(target = 'test13', source = 'test13.f95') -env.SharedObject(target = 'test14', source = 'test14.F95') """ % locals()) test.write('test01.f', "This is a .f file.\n#fortran\n") @@ -80,33 +77,25 @@ test.write('test05.ftn', "This is a .ftn file.\n#fortran\n") test.write('test06.FTN', "This is a .FTN file.\n#fortran\n") test.write('test07.fpp', "This is a .fpp file.\n#fortran\n") test.write('test08.FPP', "This is a .FPP file.\n#fortran\n") -test.write('test09.f77', "This is a .f77 file.\n#fortran\n") -test.write('test10.F77', "This is a .F77 file.\n#fortran\n") test.write('test11.f90', "This is a .f90 file.\n#g90\n") test.write('test12.F90', "This is a .F90 file.\n#g90\n") -test.write('test13.f95', "This is a .f95 file.\n#fortran\n") -test.write('test14.F95', "This is a .F95 file.\n#fortran\n") test.run(arguments = '.', stderr = None) -test.must_match('test01' + _obj, "This is a .f file.\n") -test.must_match('test02' + _obj, "This is a .F file.\n") -test.must_match('test03' + _obj, "This is a .for file.\n") -test.must_match('test04' + _obj, "This is a .FOR file.\n") -test.must_match('test05' + _obj, "This is a .ftn file.\n") -test.must_match('test06' + _obj, "This is a .FTN file.\n") -test.must_match('test07' + _obj, "This is a .fpp file.\n") -test.must_match('test08' + _obj, "This is a .FPP file.\n") -test.must_match('test09' + _obj, "This is a .f77 file.\n") -test.must_match('test10' + _obj, "This is a .F77 file.\n") -test.must_match('test11' + _obj, "This is a .f90 file.\n") -test.must_match('test12' + _obj, "This is a .F90 file.\n") -test.must_match('test13' + _obj, "This is a .f95 file.\n") -test.must_match('test14' + _obj, "This is a .F95 file.\n") +test.must_match(obj_ + 'test01' + _obj, "This is a .f file.\n") +test.must_match(obj_ + 'test02' + _obj, "This is a .F file.\n") +test.must_match(obj_ + 'test03' + _obj, "This is a .for file.\n") +test.must_match(obj_ + 'test04' + _obj, "This is a .FOR file.\n") +test.must_match(obj_ + 'test05' + _obj, "This is a .ftn file.\n") +test.must_match(obj_ + 'test06' + _obj, "This is a .FTN file.\n") +test.must_match(obj_ + 'test07' + _obj, "This is a .fpp file.\n") +test.must_match(obj_ + 'test08' + _obj, "This is a .FPP file.\n") +test.must_match(obj_ + 'test11' + _obj, "This is a .f90 file.\n") +test.must_match(obj_ + 'test12' + _obj, "This is a .F90 file.\n") - -g90 = test.detect('F90', 'g90') +fc = 'f90' +g90 = test.detect_tool(fc) if g90: @@ -119,23 +108,23 @@ os.system(string.join(sys.argv[1:], " ")) """ % string.replace(test.workpath('wrapper.out'), '\\', '\\\\')) test.write('SConstruct', """ -foo = Environment(LIBS = 'g2c') +foo = Environment(SHF90 = '%(fc)s') shf90 = foo.Dictionary('SHF90') bar = foo.Clone(SHF90 = r'%(_python_)s wrapper.py ' + shf90) -foo.SharedObject(target = 'foo/foo', source = 'foo.f') -bar.SharedObject(target = 'bar/bar', source = 'bar.f') +foo.SharedObject(target = 'foo/foo', source = 'foo.f90') +bar.SharedObject(target = 'bar/bar', source = 'bar.f90') """ % locals()) - test.write('foo.f', r""" + test.write('foo.f90', r""" PROGRAM FOO - PRINT *,'foo.f' + PRINT *,'foo.f90' STOP END """) - test.write('bar.f', r""" + test.write('bar.f90', r""" PROGRAM BAR - PRINT *,'bar.f' + PRINT *,'bar.f90' STOP END """) @@ -145,7 +134,11 @@ bar.SharedObject(target = 'bar/bar', source = 'bar.f') test.must_not_exist('wrapper.out') - test.run(arguments = 'bar') + import sys + if sys.platform[:5] == 'sunos': + test.run(arguments = 'bar', stderr = None) + else: + test.run(arguments = 'bar') test.must_match('wrapper.out', "wrapper.py\n") diff --git a/test/Fortran/SHF90COM.py b/test/Fortran/SHF90COM.py index 13d9978..3c36f04 100644 --- a/test/Fortran/SHF90COM.py +++ b/test/Fortran/SHF90COM.py @@ -31,6 +31,7 @@ import TestSCons _python_ = TestSCons._python_ _obj = TestSCons._shobj +obj_ = TestSCons.shobj_ test = TestSCons.TestSCons() @@ -62,12 +63,8 @@ env.SharedObject(target = 'test05', source = 'test05.ftn') env.SharedObject(target = 'test06', source = 'test06.FTN') env.SharedObject(target = 'test07', source = 'test07.fpp') env.SharedObject(target = 'test08', source = 'test08.FPP') -env.SharedObject(target = 'test09', source = 'test09.f77') -env.SharedObject(target = 'test10', source = 'test10.F77') env.SharedObject(target = 'test11', source = 'test11.f90') env.SharedObject(target = 'test12', source = 'test12.F90') -env.SharedObject(target = 'test13', source = 'test13.f95') -env.SharedObject(target = 'test14', source = 'test14.F95') env2 = Environment(SHF90COM = r'%(_python_)s myfortran.py f90 $TARGET $SOURCES', SHF90PPCOM = r'%(_python_)s myfortran.py f90pp $TARGET $SOURCES') env2.SharedObject(target = 'test21', source = 'test21.f90') @@ -82,34 +79,26 @@ test.write('test05.ftn', "This is a .ftn file.\n#fortran\n") test.write('test06.FTN', "This is a .FTN file.\n#fortranpp\n") test.write('test07.fpp', "This is a .fpp file.\n#fortranpp\n") test.write('test08.FPP', "This is a .FPP file.\n#fortranpp\n") -test.write('test09.f77', "This is a .f77 file.\n#fortran\n") -test.write('test10.F77', "This is a .F77 file.\n#fortranpp\n") test.write('test11.f90', "This is a .f90 file.\n#f90\n") test.write('test12.F90', "This is a .F90 file.\n#f90pp\n") -test.write('test13.f95', "This is a .f95 file.\n#fortran\n") -test.write('test14.F95', "This is a .F95 file.\n#fortranpp\n") test.write('test21.f90', "This is a .f90 file.\n#f90\n") test.write('test22.F90', "This is a .F90 file.\n#f90pp\n") test.run(arguments = '.', stderr = None) -test.must_match('test01' + _obj, "This is a .f file.\n") -test.must_match('test02' + _obj, "This is a .F file.\n") -test.must_match('test03' + _obj, "This is a .for file.\n") -test.must_match('test04' + _obj, "This is a .FOR file.\n") -test.must_match('test05' + _obj, "This is a .ftn file.\n") -test.must_match('test06' + _obj, "This is a .FTN file.\n") -test.must_match('test07' + _obj, "This is a .fpp file.\n") -test.must_match('test08' + _obj, "This is a .FPP file.\n") -test.must_match('test09' + _obj, "This is a .f77 file.\n") -test.must_match('test10' + _obj, "This is a .F77 file.\n") -test.must_match('test11' + _obj, "This is a .f90 file.\n") -test.must_match('test12' + _obj, "This is a .F90 file.\n") -test.must_match('test13' + _obj, "This is a .f95 file.\n") -test.must_match('test14' + _obj, "This is a .F95 file.\n") - -test.must_match('test21' + _obj, "This is a .f90 file.\n") -test.must_match('test22' + _obj, "This is a .F90 file.\n") +test.must_match(obj_ + 'test01' + _obj, "This is a .f file.\n") +test.must_match(obj_ + 'test02' + _obj, "This is a .F file.\n") +test.must_match(obj_ + 'test03' + _obj, "This is a .for file.\n") +test.must_match(obj_ + 'test04' + _obj, "This is a .FOR file.\n") +test.must_match(obj_ + 'test05' + _obj, "This is a .ftn file.\n") +test.must_match(obj_ + 'test06' + _obj, "This is a .FTN file.\n") +test.must_match(obj_ + 'test07' + _obj, "This is a .fpp file.\n") +test.must_match(obj_ + 'test08' + _obj, "This is a .FPP file.\n") +test.must_match(obj_ + 'test11' + _obj, "This is a .f90 file.\n") +test.must_match(obj_ + 'test12' + _obj, "This is a .F90 file.\n") + +test.must_match(obj_ + 'test21' + _obj, "This is a .f90 file.\n") +test.must_match(obj_ + 'test22' + _obj, "This is a .F90 file.\n") test.pass_test() diff --git a/test/Fortran/SHF90FLAGS.py b/test/Fortran/SHF90FLAGS.py index daf6366..d98709c 100644 --- a/test/Fortran/SHF90FLAGS.py +++ b/test/Fortran/SHF90FLAGS.py @@ -31,13 +31,8 @@ import TestSCons _python_ = TestSCons._python_ -if sys.platform == 'win32': - _obj = '.obj' -else: - if string.find(sys.platform, 'irix') > -1: - _obj = '.o' - else: - _obj = '.os' +_obj = TestSCons._shobj +obj_ = TestSCons.shobj_ test = TestSCons.TestSCons() @@ -47,11 +42,11 @@ test.write('myfortran.py', r""" import getopt import sys comment = '#' + sys.argv[1] -opts, args = getopt.getopt(sys.argv[2:], 'co:xy') +opts, args = getopt.getopt(sys.argv[2:], 'cf:o:xy') optstring = '' for opt, arg in opts: if opt == '-o': out = arg - else: optstring = optstring + ' ' + opt + elif opt != '-f': optstring = optstring + ' ' + opt infile = open(args[0], 'rb') outfile = open(out, 'wb') outfile.write(optstring + "\n") @@ -65,9 +60,9 @@ sys.exit(0) test.write('SConstruct', """ env = Environment(SHF90 = r'%(_python_)s myfortran.py g90', - SHF90FLAGS = '-x', - SHFORTRAN = r'%(_python_)s myfortran.py fortran', - SHFORTRANFLAGS = '-y') + SHFORTRAN = r'%(_python_)s myfortran.py fortran') +env.Append(SHF90FLAGS = '-x', + SHFORTRANFLAGS = '-y') env.SharedObject(target = 'test01', source = 'test01.f') env.SharedObject(target = 'test02', source = 'test02.F') env.SharedObject(target = 'test03', source = 'test03.for') @@ -76,12 +71,8 @@ env.SharedObject(target = 'test05', source = 'test05.ftn') env.SharedObject(target = 'test06', source = 'test06.FTN') env.SharedObject(target = 'test07', source = 'test07.fpp') env.SharedObject(target = 'test08', source = 'test08.FPP') -env.SharedObject(target = 'test09', source = 'test09.f77') -env.SharedObject(target = 'test10', source = 'test10.F77') env.SharedObject(target = 'test11', source = 'test11.f90') env.SharedObject(target = 'test12', source = 'test12.F90') -env.SharedObject(target = 'test13', source = 'test13.f95') -env.SharedObject(target = 'test14', source = 'test14.F95') """ % locals()) test.write('test01.f', "This is a .f file.\n#fortran\n") @@ -92,34 +83,24 @@ test.write('test05.ftn', "This is a .ftn file.\n#fortran\n") test.write('test06.FTN', "This is a .FTN file.\n#fortran\n") test.write('test07.fpp', "This is a .fpp file.\n#fortran\n") test.write('test08.FPP', "This is a .FPP file.\n#fortran\n") -test.write('test09.f77', "This is a .f77 file.\n#fortran\n") -test.write('test10.F77', "This is a .F77 file.\n#fortran\n") test.write('test11.f90', "This is a .f90 file.\n#g90\n") test.write('test12.F90', "This is a .F90 file.\n#g90\n") -test.write('test13.f95', "This is a .f95 file.\n#fortran\n") -test.write('test14.F95', "This is a .F95 file.\n#fortran\n") test.run(arguments = '.', stderr = None) -test.must_match('test01' + _obj, " -c -y\nThis is a .f file.\n") -test.must_match('test02' + _obj, " -c -y\nThis is a .F file.\n") -test.must_match('test03' + _obj, " -c -y\nThis is a .for file.\n") -test.must_match('test04' + _obj, " -c -y\nThis is a .FOR file.\n") -test.must_match('test05' + _obj, " -c -y\nThis is a .ftn file.\n") -test.must_match('test06' + _obj, " -c -y\nThis is a .FTN file.\n") -test.must_match('test07' + _obj, " -c -y\nThis is a .fpp file.\n") -test.must_match('test08' + _obj, " -c -y\nThis is a .FPP file.\n") -test.must_match('test09' + _obj, " -c -y\nThis is a .f77 file.\n") -test.must_match('test10' + _obj, " -c -y\nThis is a .F77 file.\n") -test.must_match('test11' + _obj, " -c -x\nThis is a .f90 file.\n") -test.must_match('test12' + _obj, " -c -x\nThis is a .F90 file.\n") -test.must_match('test13' + _obj, " -c -y\nThis is a .f95 file.\n") -test.must_match('test14' + _obj, " -c -y\nThis is a .F95 file.\n") - +test.must_match(obj_ + 'test01' + _obj, " -c -y\nThis is a .f file.\n") +test.must_match(obj_ + 'test02' + _obj, " -c -y\nThis is a .F file.\n") +test.must_match(obj_ + 'test03' + _obj, " -c -y\nThis is a .for file.\n") +test.must_match(obj_ + 'test04' + _obj, " -c -y\nThis is a .FOR file.\n") +test.must_match(obj_ + 'test05' + _obj, " -c -y\nThis is a .ftn file.\n") +test.must_match(obj_ + 'test06' + _obj, " -c -y\nThis is a .FTN file.\n") +test.must_match(obj_ + 'test07' + _obj, " -c -y\nThis is a .fpp file.\n") +test.must_match(obj_ + 'test08' + _obj, " -c -y\nThis is a .FPP file.\n") +test.must_match(obj_ + 'test11' + _obj, " -c -x\nThis is a .f90 file.\n") +test.must_match(obj_ + 'test12' + _obj, " -c -x\nThis is a .F90 file.\n") - -g90 = test.detect('F90', 'g90') -FTN_LIB = TestSCons.fortran_lib +fc = 'f90' +g90 = test.detect_tool(fc) if g90: @@ -132,23 +113,24 @@ os.system(string.join(sys.argv[1:], " ")) """ % string.replace(test.workpath('wrapper.out'), '\\', '\\\\')) test.write('SConstruct', """ -foo = Environment(LIBS = %(FTN_LIB)s) +foo = Environment(SHF90 = '%(fc)s') shf90 = foo.Dictionary('SHF90') -bar = foo.Clone(SHF90 = r'%(_python_)s wrapper.py ' + shf90, SHF90FLAGS = '-Ix') -foo.SharedLibrary(target = 'foo/foo', source = 'foo.f') -bar.SharedLibrary(target = 'bar/bar', source = 'bar.f') +bar = foo.Clone(SHF90 = r'%(_python_)s wrapper.py ' + shf90) +bar.Append(SHF90FLAGS = '-Ix') +foo.SharedLibrary(target = 'foo/foo', source = 'foo.f90') +bar.SharedLibrary(target = 'bar/bar', source = 'bar.f90') """ % locals()) - test.write('foo.f', r""" + test.write('foo.f90', r""" PROGRAM FOO - PRINT *,'foo.f' + PRINT *,'foo.f90' STOP END """) - test.write('bar.f', r""" + test.write('bar.f90', r""" PROGRAM BAR - PRINT *,'bar.f' + PRINT *,'bar.f90' STOP END """) @@ -158,7 +140,11 @@ bar.SharedLibrary(target = 'bar/bar', source = 'bar.f') test.must_not_exist('wrapper.out') - test.run(arguments = 'bar') + import sys + if sys.platform[:5] == 'sunos': + test.run(arguments = 'bar', stderr = None) + else: + test.run(arguments = 'bar') test.must_match('wrapper.out', "wrapper.py\n") diff --git a/test/Fortran/SHF95.py b/test/Fortran/SHF95.py index b9db6ba..bf338e7 100644 --- a/test/Fortran/SHF95.py +++ b/test/Fortran/SHF95.py @@ -31,6 +31,7 @@ import TestSCons _python_ = TestSCons._python_ _obj = TestSCons._shobj +obj_ = TestSCons.shobj_ test = TestSCons.TestSCons() @@ -40,7 +41,7 @@ test.write('myfortran.py', r""" import getopt import sys comment = '#' + sys.argv[1] -opts, args = getopt.getopt(sys.argv[2:], 'cf:o:') +opts, args = getopt.getopt(sys.argv[2:], 'cf:o:K:') for opt, arg in opts: if opt == '-o': out = arg infile = open(args[0], 'rb') @@ -64,10 +65,6 @@ env.SharedObject(target = 'test05', source = 'test05.ftn') env.SharedObject(target = 'test06', source = 'test06.FTN') env.SharedObject(target = 'test07', source = 'test07.fpp') env.SharedObject(target = 'test08', source = 'test08.FPP') -env.SharedObject(target = 'test09', source = 'test09.f77') -env.SharedObject(target = 'test10', source = 'test10.F77') -env.SharedObject(target = 'test11', source = 'test11.f90') -env.SharedObject(target = 'test12', source = 'test12.F90') env.SharedObject(target = 'test13', source = 'test13.f95') env.SharedObject(target = 'test14', source = 'test14.F95') """ % locals()) @@ -80,33 +77,24 @@ test.write('test05.ftn', "This is a .ftn file.\n#fortran\n") test.write('test06.FTN', "This is a .FTN file.\n#fortran\n") test.write('test07.fpp', "This is a .fpp file.\n#fortran\n") test.write('test08.FPP', "This is a .FPP file.\n#fortran\n") -test.write('test09.f77', "This is a .f77 file.\n#fortran\n") -test.write('test10.F77', "This is a .F77 file.\n#fortran\n") -test.write('test11.f90', "This is a .f90 file.\n#fortran\n") -test.write('test12.F90', "This is a .F90 file.\n#fortran\n") test.write('test13.f95', "This is a .f95 file.\n#g95\n") test.write('test14.F95', "This is a .F95 file.\n#g95\n") test.run(arguments = '.', stderr = None) -test.must_match('test01' + _obj, "This is a .f file.\n") -test.must_match('test02' + _obj, "This is a .F file.\n") -test.must_match('test03' + _obj, "This is a .for file.\n") -test.must_match('test04' + _obj, "This is a .FOR file.\n") -test.must_match('test05' + _obj, "This is a .ftn file.\n") -test.must_match('test06' + _obj, "This is a .FTN file.\n") -test.must_match('test07' + _obj, "This is a .fpp file.\n") -test.must_match('test08' + _obj, "This is a .FPP file.\n") -test.must_match('test09' + _obj, "This is a .f77 file.\n") -test.must_match('test10' + _obj, "This is a .F77 file.\n") -test.must_match('test11' + _obj, "This is a .f90 file.\n") -test.must_match('test12' + _obj, "This is a .F90 file.\n") -test.must_match('test13' + _obj, "This is a .f95 file.\n") -test.must_match('test14' + _obj, "This is a .F95 file.\n") +test.must_match(obj_ + 'test01' + _obj, "This is a .f file.\n") +test.must_match(obj_ + 'test02' + _obj, "This is a .F file.\n") +test.must_match(obj_ + 'test03' + _obj, "This is a .for file.\n") +test.must_match(obj_ + 'test04' + _obj, "This is a .FOR file.\n") +test.must_match(obj_ + 'test05' + _obj, "This is a .ftn file.\n") +test.must_match(obj_ + 'test06' + _obj, "This is a .FTN file.\n") +test.must_match(obj_ + 'test07' + _obj, "This is a .fpp file.\n") +test.must_match(obj_ + 'test08' + _obj, "This is a .FPP file.\n") +test.must_match(obj_ + 'test13' + _obj, "This is a .f95 file.\n") +test.must_match(obj_ + 'test14' + _obj, "This is a .F95 file.\n") - - -g95 = test.detect('F95', 'g95') +fc = 'f95' +g95 = test.detect_tool(fc) if g95: @@ -119,23 +107,23 @@ os.system(string.join(sys.argv[1:], " ")) """ % string.replace(test.workpath('wrapper.out'), '\\', '\\\\')) test.write('SConstruct', """ -foo = Environment(LIBS = 'g2c') +foo = Environment(SHF95 = '%(fc)s') shf95 = foo.Dictionary('SHF95') bar = foo.Clone(SHF95 = r'%(_python_)s wrapper.py ' + shf95) -foo.SharedObject(target = 'foo/foo', source = 'foo.f') -bar.SharedObject(target = 'bar/bar', source = 'bar.f') +foo.SharedObject(target = 'foo/foo', source = 'foo.f95') +bar.SharedObject(target = 'bar/bar', source = 'bar.f95') """ % locals()) - test.write('foo.f', r""" + test.write('foo.f95', r""" PROGRAM FOO - PRINT *,'foo.f' + PRINT *,'foo.f95' STOP END """) - test.write('bar.f', r""" + test.write('bar.f95', r""" PROGRAM BAR - PRINT *,'bar.f' + PRINT *,'bar.f95' STOP END """) @@ -145,7 +133,11 @@ bar.SharedObject(target = 'bar/bar', source = 'bar.f') test.must_not_exist('wrapper.out') - test.run(arguments = 'bar') + import sys + if sys.platform[:5] == 'sunos': + test.run(arguments = 'bar', stderr = None) + else: + test.run(arguments = 'bar') test.must_match('wrapper.out', "wrapper.py\n") diff --git a/test/Fortran/SHF95COM.py b/test/Fortran/SHF95COM.py index b11933a..e02c264 100644 --- a/test/Fortran/SHF95COM.py +++ b/test/Fortran/SHF95COM.py @@ -31,6 +31,7 @@ import TestSCons _python_ = TestSCons._python_ _obj = TestSCons._shobj +obj_ = TestSCons.shobj_ test = TestSCons.TestSCons() @@ -62,10 +63,6 @@ env.SharedObject(target = 'test05', source = 'test05.ftn') env.SharedObject(target = 'test06', source = 'test06.FTN') env.SharedObject(target = 'test07', source = 'test07.fpp') env.SharedObject(target = 'test08', source = 'test08.FPP') -env.SharedObject(target = 'test09', source = 'test09.f77') -env.SharedObject(target = 'test10', source = 'test10.F77') -env.SharedObject(target = 'test11', source = 'test11.f90') -env.SharedObject(target = 'test12', source = 'test12.F90') env.SharedObject(target = 'test13', source = 'test13.f95') env.SharedObject(target = 'test14', source = 'test14.F95') env2 = Environment(SHF95COM = r'%(_python_)s myfortran.py f95 $TARGET $SOURCES', @@ -82,10 +79,6 @@ test.write('test05.ftn', "This is a .ftn file.\n#fortran\n") test.write('test06.FTN', "This is a .FTN file.\n#fortranpp\n") test.write('test07.fpp', "This is a .fpp file.\n#fortranpp\n") test.write('test08.FPP', "This is a .FPP file.\n#fortranpp\n") -test.write('test09.f77', "This is a .f77 file.\n#fortran\n") -test.write('test10.F77', "This is a .F77 file.\n#fortranpp\n") -test.write('test11.f90', "This is a .f90 file.\n#fortran\n") -test.write('test12.F90', "This is a .F90 file.\n#fortranpp\n") test.write('test13.f95', "This is a .f95 file.\n#f95\n") test.write('test14.F95', "This is a .F95 file.\n#f95pp\n") @@ -94,22 +87,18 @@ test.write('test22.F95', "This is a .F95 file.\n#f95pp\n") test.run(arguments = '.', stderr = None) -test.must_match('test01' + _obj, "This is a .f file.\n") -test.must_match('test02' + _obj, "This is a .F file.\n") -test.must_match('test03' + _obj, "This is a .for file.\n") -test.must_match('test04' + _obj, "This is a .FOR file.\n") -test.must_match('test05' + _obj, "This is a .ftn file.\n") -test.must_match('test06' + _obj, "This is a .FTN file.\n") -test.must_match('test07' + _obj, "This is a .fpp file.\n") -test.must_match('test08' + _obj, "This is a .FPP file.\n") -test.must_match('test09' + _obj, "This is a .f77 file.\n") -test.must_match('test10' + _obj, "This is a .F77 file.\n") -test.must_match('test11' + _obj, "This is a .f90 file.\n") -test.must_match('test12' + _obj, "This is a .F90 file.\n") -test.must_match('test13' + _obj, "This is a .f95 file.\n") -test.must_match('test14' + _obj, "This is a .F95 file.\n") - -test.must_match('test21' + _obj, "This is a .f95 file.\n") -test.must_match('test22' + _obj, "This is a .F95 file.\n") +test.must_match(obj_ + 'test01' + _obj, "This is a .f file.\n") +test.must_match(obj_ + 'test02' + _obj, "This is a .F file.\n") +test.must_match(obj_ + 'test03' + _obj, "This is a .for file.\n") +test.must_match(obj_ + 'test04' + _obj, "This is a .FOR file.\n") +test.must_match(obj_ + 'test05' + _obj, "This is a .ftn file.\n") +test.must_match(obj_ + 'test06' + _obj, "This is a .FTN file.\n") +test.must_match(obj_ + 'test07' + _obj, "This is a .fpp file.\n") +test.must_match(obj_ + 'test08' + _obj, "This is a .FPP file.\n") +test.must_match(obj_ + 'test13' + _obj, "This is a .f95 file.\n") +test.must_match(obj_ + 'test14' + _obj, "This is a .F95 file.\n") + +test.must_match(obj_ + 'test21' + _obj, "This is a .f95 file.\n") +test.must_match(obj_ + 'test22' + _obj, "This is a .F95 file.\n") test.pass_test() diff --git a/test/Fortran/SHF95FLAGS.py b/test/Fortran/SHF95FLAGS.py index 09f9b98..9da4afc 100644 --- a/test/Fortran/SHF95FLAGS.py +++ b/test/Fortran/SHF95FLAGS.py @@ -31,13 +31,8 @@ import TestSCons _python_ = TestSCons._python_ -if sys.platform == 'win32': - _obj = '.obj' -else: - if string.find(sys.platform, 'irix') > -1: - _obj = '.o' - else: - _obj = '.os' +_obj = TestSCons._shobj +obj_ = TestSCons.shobj_ test = TestSCons.TestSCons() @@ -47,11 +42,11 @@ test.write('myfortran.py', r""" import getopt import sys comment = '#' + sys.argv[1] -opts, args = getopt.getopt(sys.argv[2:], 'co:xy') +opts, args = getopt.getopt(sys.argv[2:], 'cf:o:xy') optstring = '' for opt, arg in opts: if opt == '-o': out = arg - else: optstring = optstring + ' ' + opt + elif opt != '-f': optstring = optstring + ' ' + opt infile = open(args[0], 'rb') outfile = open(out, 'wb') outfile.write(optstring + "\n") @@ -65,9 +60,9 @@ sys.exit(0) test.write('SConstruct', """ env = Environment(SHF95 = r'%(_python_)s myfortran.py g95', - SHF95FLAGS = '-x', - SHFORTRAN = r'%(_python_)s myfortran.py fortran', - SHFORTRANFLAGS = '-y') + SHFORTRAN = r'%(_python_)s myfortran.py fortran') +env.Append(SHF95FLAGS = '-x', + SHFORTRANFLAGS = '-y') env.SharedObject(target = 'test01', source = 'test01.f') env.SharedObject(target = 'test02', source = 'test02.F') env.SharedObject(target = 'test03', source = 'test03.for') @@ -76,10 +71,6 @@ env.SharedObject(target = 'test05', source = 'test05.ftn') env.SharedObject(target = 'test06', source = 'test06.FTN') env.SharedObject(target = 'test07', source = 'test07.fpp') env.SharedObject(target = 'test08', source = 'test08.FPP') -env.SharedObject(target = 'test09', source = 'test09.f77') -env.SharedObject(target = 'test10', source = 'test10.F77') -env.SharedObject(target = 'test11', source = 'test11.f90') -env.SharedObject(target = 'test12', source = 'test12.F90') env.SharedObject(target = 'test13', source = 'test13.f95') env.SharedObject(target = 'test14', source = 'test14.F95') """ % locals()) @@ -92,34 +83,26 @@ test.write('test05.ftn', "This is a .ftn file.\n#fortran\n") test.write('test06.FTN', "This is a .FTN file.\n#fortran\n") test.write('test07.fpp', "This is a .fpp file.\n#fortran\n") test.write('test08.FPP', "This is a .FPP file.\n#fortran\n") -test.write('test09.f77', "This is a .f77 file.\n#fortran\n") -test.write('test10.F77', "This is a .F77 file.\n#fortran\n") -test.write('test11.f90', "This is a .f90 file.\n#fortran\n") -test.write('test12.F90', "This is a .F90 file.\n#fortran\n") test.write('test13.f95', "This is a .f95 file.\n#g95\n") test.write('test14.F95', "This is a .F95 file.\n#g95\n") test.run(arguments = '.', stderr = None) -test.must_match('test01' + _obj, " -c -y\nThis is a .f file.\n") -test.must_match('test02' + _obj, " -c -y\nThis is a .F file.\n") -test.must_match('test03' + _obj, " -c -y\nThis is a .for file.\n") -test.must_match('test04' + _obj, " -c -y\nThis is a .FOR file.\n") -test.must_match('test05' + _obj, " -c -y\nThis is a .ftn file.\n") -test.must_match('test06' + _obj, " -c -y\nThis is a .FTN file.\n") -test.must_match('test07' + _obj, " -c -y\nThis is a .fpp file.\n") -test.must_match('test08' + _obj, " -c -y\nThis is a .FPP file.\n") -test.must_match('test09' + _obj, " -c -y\nThis is a .f77 file.\n") -test.must_match('test10' + _obj, " -c -y\nThis is a .F77 file.\n") -test.must_match('test11' + _obj, " -c -y\nThis is a .f90 file.\n") -test.must_match('test12' + _obj, " -c -y\nThis is a .F90 file.\n") -test.must_match('test13' + _obj, " -c -x\nThis is a .f95 file.\n") -test.must_match('test14' + _obj, " -c -x\nThis is a .F95 file.\n") +test.must_match(obj_ + 'test01' + _obj, " -c -y\nThis is a .f file.\n") +test.must_match(obj_ + 'test02' + _obj, " -c -y\nThis is a .F file.\n") +test.must_match(obj_ + 'test03' + _obj, " -c -y\nThis is a .for file.\n") +test.must_match(obj_ + 'test04' + _obj, " -c -y\nThis is a .FOR file.\n") +test.must_match(obj_ + 'test05' + _obj, " -c -y\nThis is a .ftn file.\n") +test.must_match(obj_ + 'test06' + _obj, " -c -y\nThis is a .FTN file.\n") +test.must_match(obj_ + 'test07' + _obj, " -c -y\nThis is a .fpp file.\n") +test.must_match(obj_ + 'test08' + _obj, " -c -y\nThis is a .FPP file.\n") +test.must_match(obj_ + 'test13' + _obj, " -c -x\nThis is a .f95 file.\n") +test.must_match(obj_ + 'test14' + _obj, " -c -x\nThis is a .F95 file.\n") -g95 = test.detect('F95', 'g95') -FTN_LIB = TestSCons.fortran_lib +fc = 'f95' +g95 = test.detect_tool(fc) if g95: @@ -132,23 +115,24 @@ os.system(string.join(sys.argv[1:], " ")) """ % string.replace(test.workpath('wrapper.out'), '\\', '\\\\')) test.write('SConstruct', """ -foo = Environment(LIBS = %(FTN_LIB)s) +foo = Environment(SHF95 = '%(fc)s') shf95 = foo.Dictionary('SHF95') -bar = foo.Clone(SHF95 = r'%(_python_)s wrapper.py ' + shf95, SHF95FLAGS = '-Ix') -foo.SharedLibrary(target = 'foo/foo', source = 'foo.f') -bar.SharedLibrary(target = 'bar/bar', source = 'bar.f') +bar = foo.Clone(SHF95 = r'%(_python_)s wrapper.py ' + shf95) +bar.Append(SHF95FLAGS = '-Ix') +foo.SharedLibrary(target = 'foo/foo', source = 'foo.f95') +bar.SharedLibrary(target = 'bar/bar', source = 'bar.f95') """ % locals()) - test.write('foo.f', r""" + test.write('foo.f95', r""" PROGRAM FOO - PRINT *,'foo.f' + PRINT *,'foo.f95' STOP END """) - test.write('bar.f', r""" + test.write('bar.f95', r""" PROGRAM BAR - PRINT *,'bar.f' + PRINT *,'bar.f95' STOP END """) @@ -158,7 +142,11 @@ bar.SharedLibrary(target = 'bar/bar', source = 'bar.f') test.must_not_exist('wrapper.out') - test.run(arguments = 'bar') + import sys + if sys.platform[:5] == 'sunos': + test.run(arguments = 'bar', stderr = None) + else: + test.run(arguments = 'bar') test.must_match('wrapper.out', "wrapper.py\n") diff --git a/test/Fortran/SHFORTRAN.py b/test/Fortran/SHFORTRAN.py index 5b9cfc6..ad575dd 100644 --- a/test/Fortran/SHFORTRAN.py +++ b/test/Fortran/SHFORTRAN.py @@ -31,6 +31,7 @@ import TestSCons _python_ = TestSCons._python_ _obj = TestSCons._shobj +obj_ = TestSCons.shobj_ test = TestSCons.TestSCons() @@ -39,7 +40,7 @@ test = TestSCons.TestSCons() test.write('myfortran.py', r""" import getopt import sys -opts, args = getopt.getopt(sys.argv[1:], 'cf:o:') +opts, args = getopt.getopt(sys.argv[1:], 'cf:o:K:') for opt, arg in opts: if opt == '-o': out = arg infile = open(args[0], 'rb') @@ -62,12 +63,6 @@ env.SharedObject(target = 'test05', source = 'test05.ftn') env.SharedObject(target = 'test06', source = 'test06.FTN') env.SharedObject(target = 'test07', source = 'test07.fpp') env.SharedObject(target = 'test08', source = 'test08.FPP') -env.SharedObject(target = 'test09', source = 'test09.f77') -env.SharedObject(target = 'test10', source = 'test10.F77') -env.SharedObject(target = 'test11', source = 'test11.f90') -env.SharedObject(target = 'test12', source = 'test12.F90') -env.SharedObject(target = 'test13', source = 'test13.f95') -env.SharedObject(target = 'test14', source = 'test14.F95') """ % locals()) test.write('test01.f', "This is a .f file.\n#fortran\n") @@ -78,33 +73,22 @@ test.write('test05.ftn', "This is a .ftn file.\n#fortran\n") test.write('test06.FTN', "This is a .FTN file.\n#fortran\n") test.write('test07.fpp', "This is a .fpp file.\n#fortran\n") test.write('test08.FPP', "This is a .FPP file.\n#fortran\n") -test.write('test09.f77', "This is a .f77 file.\n#fortran\n") -test.write('test10.F77', "This is a .F77 file.\n#fortran\n") -test.write('test11.f90', "This is a .f90 file.\n#fortran\n") -test.write('test12.F90', "This is a .F90 file.\n#fortran\n") -test.write('test13.f95', "This is a .f95 file.\n#fortran\n") -test.write('test14.F95', "This is a .F95 file.\n#fortran\n") test.run(arguments = '.', stderr = None) -test.must_match('test01' + _obj, "This is a .f file.\n") -test.must_match('test02' + _obj, "This is a .F file.\n") -test.must_match('test03' + _obj, "This is a .for file.\n") -test.must_match('test04' + _obj, "This is a .FOR file.\n") -test.must_match('test05' + _obj, "This is a .ftn file.\n") -test.must_match('test06' + _obj, "This is a .FTN file.\n") -test.must_match('test07' + _obj, "This is a .fpp file.\n") -test.must_match('test08' + _obj, "This is a .FPP file.\n") -test.must_match('test09' + _obj, "This is a .f77 file.\n") -test.must_match('test10' + _obj, "This is a .F77 file.\n") -test.must_match('test11' + _obj, "This is a .f90 file.\n") -test.must_match('test12' + _obj, "This is a .F90 file.\n") -test.must_match('test13' + _obj, "This is a .f95 file.\n") -test.must_match('test14' + _obj, "This is a .F95 file.\n") +test.must_match(obj_ + 'test01' + _obj, "This is a .f file.\n") +test.must_match(obj_ + 'test02' + _obj, "This is a .F file.\n") +test.must_match(obj_ + 'test03' + _obj, "This is a .for file.\n") +test.must_match(obj_ + 'test04' + _obj, "This is a .FOR file.\n") +test.must_match(obj_ + 'test05' + _obj, "This is a .ftn file.\n") +test.must_match(obj_ + 'test06' + _obj, "This is a .FTN file.\n") +test.must_match(obj_ + 'test07' + _obj, "This is a .fpp file.\n") +test.must_match(obj_ + 'test08' + _obj, "This is a .FPP file.\n") -fortran = test.detect('FORTRAN', 'g77') +fc = 'f77' +fortran = test.detect_tool(fc) if fortran: @@ -117,7 +101,7 @@ os.system(string.join(sys.argv[1:], " ")) """ % string.replace(test.workpath('wrapper.out'), '\\', '\\\\')) test.write('SConstruct', """ -foo = Environment(LIBS = 'g2c') +foo = Environment(SHFORTRAN = '%(fc)s') shfortran = foo.Dictionary('SHFORTRAN') bar = foo.Clone(SHFORTRAN = r'%(_python_)s wrapper.py ' + shfortran) foo.SharedObject(target = 'foo/foo', source = 'foo.f') @@ -141,9 +125,13 @@ bar.SharedObject(target = 'bar/bar', source = 'bar.f') test.run(arguments = 'foo', stderr = None) - test.must_exist('wrapper.out') + test.must_not_exist('wrapper.out') - test.run(arguments = 'bar') + import sys + if sys.platform[:5] == 'sunos': + test.run(arguments = 'bar', stderr = None) + else: + test.run(arguments = 'bar') test.must_match('wrapper.out', "wrapper.py\n") diff --git a/test/Fortran/SHFORTRANCOM.py b/test/Fortran/SHFORTRANCOM.py index 21942cf..3aca02c 100644 --- a/test/Fortran/SHFORTRANCOM.py +++ b/test/Fortran/SHFORTRANCOM.py @@ -31,6 +31,7 @@ import TestSCons _python_ = TestSCons._python_ _obj = TestSCons._shobj +obj_ = TestSCons.shobj_ test = TestSCons.TestSCons() @@ -60,12 +61,6 @@ env.SharedObject(target = 'test05', source = 'test05.ftn') env.SharedObject(target = 'test06', source = 'test06.FTN') env.SharedObject(target = 'test07', source = 'test07.fpp') env.SharedObject(target = 'test08', source = 'test08.FPP') -env.SharedObject(target = 'test09', source = 'test09.f77') -env.SharedObject(target = 'test10', source = 'test10.F77') -env.SharedObject(target = 'test11', source = 'test11.f90') -env.SharedObject(target = 'test12', source = 'test12.F90') -env.SharedObject(target = 'test13', source = 'test13.f95') -env.SharedObject(target = 'test14', source = 'test14.F95') """ % locals()) test.write('test01.f', "This is a .f file.\n#fortran\n") @@ -76,28 +71,16 @@ test.write('test05.ftn', "This is a .ftn file.\n#fortran\n") test.write('test06.FTN', "This is a .FTN file.\n#fortranpp\n") test.write('test07.fpp', "This is a .fpp file.\n#fortranpp\n") test.write('test08.FPP', "This is a .FPP file.\n#fortranpp\n") -test.write('test09.f77', "This is a .f77 file.\n#fortran\n") -test.write('test10.F77', "This is a .F77 file.\n#fortranpp\n") -test.write('test11.f90', "This is a .f90 file.\n#fortran\n") -test.write('test12.F90', "This is a .F90 file.\n#fortranpp\n") -test.write('test13.f95', "This is a .f95 file.\n#fortran\n") -test.write('test14.F95', "This is a .F95 file.\n#fortranpp\n") test.run(arguments = '.', stderr = None) -test.must_match('test01' + _obj, "This is a .f file.\n") -test.must_match('test02' + _obj, "This is a .F file.\n") -test.must_match('test03' + _obj, "This is a .for file.\n") -test.must_match('test04' + _obj, "This is a .FOR file.\n") -test.must_match('test05' + _obj, "This is a .ftn file.\n") -test.must_match('test06' + _obj, "This is a .FTN file.\n") -test.must_match('test07' + _obj, "This is a .fpp file.\n") -test.must_match('test08' + _obj, "This is a .FPP file.\n") -test.must_match('test09' + _obj, "This is a .f77 file.\n") -test.must_match('test10' + _obj, "This is a .F77 file.\n") -test.must_match('test11' + _obj, "This is a .f90 file.\n") -test.must_match('test12' + _obj, "This is a .F90 file.\n") -test.must_match('test13' + _obj, "This is a .f95 file.\n") -test.must_match('test14' + _obj, "This is a .F95 file.\n") +test.must_match(obj_ + 'test01' + _obj, "This is a .f file.\n") +test.must_match(obj_ + 'test02' + _obj, "This is a .F file.\n") +test.must_match(obj_ + 'test03' + _obj, "This is a .for file.\n") +test.must_match(obj_ + 'test04' + _obj, "This is a .FOR file.\n") +test.must_match(obj_ + 'test05' + _obj, "This is a .ftn file.\n") +test.must_match(obj_ + 'test06' + _obj, "This is a .FTN file.\n") +test.must_match(obj_ + 'test07' + _obj, "This is a .fpp file.\n") +test.must_match(obj_ + 'test08' + _obj, "This is a .FPP file.\n") test.pass_test() diff --git a/test/Fortran/SHFORTRANCOMSTR.py b/test/Fortran/SHFORTRANCOMSTR.py index 13e76e3..e0e17b5 100644 --- a/test/Fortran/SHFORTRANCOMSTR.py +++ b/test/Fortran/SHFORTRANCOMSTR.py @@ -65,12 +65,6 @@ env.SharedObject(source = 'test05.ftn') env.SharedObject(source = 'test06.FTN') env.SharedObject(source = 'test07.fpp') env.SharedObject(source = 'test08.FPP') -env.SharedObject(source = 'test09.f77') -env.SharedObject(source = 'test10.F77') -env.SharedObject(source = 'test11.f90') -env.SharedObject(source = 'test12.F90') -env.SharedObject(source = 'test13.f95') -env.SharedObject(source = 'test14.F95') """ % locals()) test.write('test01.f', "A .f file.\n#fortran\n") @@ -81,12 +75,6 @@ test.write('test05.ftn', "A .ftn file.\n#fortran\n") test.write('test06.FTN', "A .FTN file.\n#%s\n" % fortranpp) test.write('test07.fpp', "A .fpp file.\n#fortranpp\n") test.write('test08.FPP', "A .FPP file.\n#fortranpp\n") -test.write('test09.f77', "A .f77 file.\n#fortran\n") -test.write('test10.F77', "A .F77 file.\n#%s\n" % fortranpp) -test.write('test11.f90', "A .f90 file.\n#fortran\n") -test.write('test12.F90', "A .F90 file.\n#%s\n" % fortranpp) -test.write('test13.f95', "A .f95 file.\n#fortran\n") -test.write('test14.F95', "A .F95 file.\n#%s\n" % fortranpp) test.run(stdout = test.wrap_stdout("""\ Building fortran test01.shobj from test01.f @@ -97,12 +85,6 @@ Building fortran test05.shobj from test05.ftn Building %(fortranpp)s test06.shobj from test06.FTN Building fortranpp test07.shobj from test07.fpp Building fortranpp test08.shobj from test08.FPP -Building fortran test09.shobj from test09.f77 -Building %(fortranpp)s test10.shobj from test10.F77 -Building fortran test11.shobj from test11.f90 -Building %(fortranpp)s test12.shobj from test12.F90 -Building fortran test13.shobj from test13.f95 -Building %(fortranpp)s test14.shobj from test14.F95 """ % locals())) test.must_match('test01.shobj', "A .f file.\n") @@ -113,11 +95,5 @@ test.must_match('test05.shobj', "A .ftn file.\n") test.must_match('test06.shobj', "A .FTN file.\n") test.must_match('test07.shobj', "A .fpp file.\n") test.must_match('test08.shobj', "A .FPP file.\n") -test.must_match('test09.shobj', "A .f77 file.\n") -test.must_match('test10.shobj', "A .F77 file.\n") -test.must_match('test11.shobj', "A .f90 file.\n") -test.must_match('test12.shobj', "A .F90 file.\n") -test.must_match('test13.shobj', "A .f95 file.\n") -test.must_match('test14.shobj', "A .F95 file.\n") test.pass_test() diff --git a/test/Fortran/SHFORTRANFLAGS.py b/test/Fortran/SHFORTRANFLAGS.py index ec74061..1369cdd 100644 --- a/test/Fortran/SHFORTRANFLAGS.py +++ b/test/Fortran/SHFORTRANFLAGS.py @@ -30,14 +30,8 @@ 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' +_obj = TestSCons._shobj +obj_ = TestSCons.shobj_ test = TestSCons.TestSCons() @@ -46,11 +40,11 @@ test = TestSCons.TestSCons() test.write('myfortran.py', r""" import getopt import sys -opts, args = getopt.getopt(sys.argv[1:], 'co:x') +opts, args = getopt.getopt(sys.argv[1:], 'cf:o:x') optstring = '' for opt, arg in opts: if opt == '-o': out = arg - else: optstring = optstring + ' ' + opt + elif opt != '-f': optstring = optstring + ' ' + opt infile = open(args[0], 'rb') outfile = open(out, 'wb') outfile.write(optstring + "\n") @@ -63,8 +57,8 @@ sys.exit(0) test.write('SConstruct', """ -env = Environment(SHFORTRAN = r'%(_python_)s myfortran.py', - SHFORTRANFLAGS = '-x') +env = Environment(SHFORTRAN = r'%(_python_)s myfortran.py') +env.Append(SHFORTRANFLAGS = '-x') env.SharedObject(target = 'test01', source = 'test01.f') env.SharedObject(target = 'test02', source = 'test02.F') env.SharedObject(target = 'test03', source = 'test03.for') @@ -73,12 +67,6 @@ env.SharedObject(target = 'test05', source = 'test05.ftn') env.SharedObject(target = 'test06', source = 'test06.FTN') env.SharedObject(target = 'test07', source = 'test07.fpp') env.SharedObject(target = 'test08', source = 'test08.FPP') -env.SharedObject(target = 'test09', source = 'test09.f77') -env.SharedObject(target = 'test10', source = 'test10.F77') -env.SharedObject(target = 'test11', source = 'test11.f90') -env.SharedObject(target = 'test12', source = 'test12.F90') -env.SharedObject(target = 'test13', source = 'test13.f95') -env.SharedObject(target = 'test14', source = 'test14.F95') """ % locals()) test.write('test01.f', "This is a .f file.\n#fortran\n") @@ -89,34 +77,20 @@ test.write('test05.ftn', "This is a .ftn file.\n#fortran\n") test.write('test06.FTN', "This is a .FTN file.\n#fortran\n") test.write('test07.fpp', "This is a .fpp file.\n#fortran\n") test.write('test08.FPP', "This is a .FPP file.\n#fortran\n") -test.write('test09.f77', "This is a .f77 file.\n#fortran\n") -test.write('test10.F77', "This is a .F77 file.\n#fortran\n") -test.write('test11.f90', "This is a .f90 file.\n#fortran\n") -test.write('test12.F90', "This is a .F90 file.\n#fortran\n") -test.write('test13.f95', "This is a .f95 file.\n#fortran\n") -test.write('test14.F95', "This is a .F95 file.\n#fortran\n") test.run(arguments = '.', stderr = None) -test.must_match('test01' + _obj, " -c -x\nThis is a .f file.\n") -test.must_match('test02' + _obj, " -c -x\nThis is a .F file.\n") -test.must_match('test03' + _obj, " -c -x\nThis is a .for file.\n") -test.must_match('test04' + _obj, " -c -x\nThis is a .FOR file.\n") -test.must_match('test05' + _obj, " -c -x\nThis is a .ftn file.\n") -test.must_match('test06' + _obj, " -c -x\nThis is a .FTN file.\n") -test.must_match('test07' + _obj, " -c -x\nThis is a .fpp file.\n") -test.must_match('test08' + _obj, " -c -x\nThis is a .FPP file.\n") -test.must_match('test09' + _obj, " -c -x\nThis is a .f77 file.\n") -test.must_match('test10' + _obj, " -c -x\nThis is a .F77 file.\n") -test.must_match('test11' + _obj, " -c -x\nThis is a .f90 file.\n") -test.must_match('test12' + _obj, " -c -x\nThis is a .F90 file.\n") -test.must_match('test13' + _obj, " -c -x\nThis is a .f95 file.\n") -test.must_match('test14' + _obj, " -c -x\nThis is a .F95 file.\n") - +test.must_match(obj_ + 'test01' + _obj, " -c -x\nThis is a .f file.\n") +test.must_match(obj_ + 'test02' + _obj, " -c -x\nThis is a .F file.\n") +test.must_match(obj_ + 'test03' + _obj, " -c -x\nThis is a .for file.\n") +test.must_match(obj_ + 'test04' + _obj, " -c -x\nThis is a .FOR file.\n") +test.must_match(obj_ + 'test05' + _obj, " -c -x\nThis is a .ftn file.\n") +test.must_match(obj_ + 'test06' + _obj, " -c -x\nThis is a .FTN file.\n") +test.must_match(obj_ + 'test07' + _obj, " -c -x\nThis is a .fpp file.\n") +test.must_match(obj_ + 'test08' + _obj, " -c -x\nThis is a .FPP file.\n") - -fortran = test.detect('FORTRAN', 'g77') -FTN_LIB = TestSCons.fortran_lib +fc = 'f77' +fortran = test.detect_tool(fc) if fortran: @@ -129,10 +103,10 @@ os.system(string.join(sys.argv[1:], " ")) """ % string.replace(test.workpath('wrapper.out'), '\\', '\\\\')) test.write('SConstruct', """ -foo = Environment(LIBS = %(FTN_LIB)s) +foo = Environment(SHFORTRAN = '%(fc)s') shfortran = foo.Dictionary('SHFORTRAN') -bar = foo.Clone(SHFORTRAN = r'%(_python_)s wrapper.py ' + shfortran, - SHFORTRANFLAGS = '-Ix') +bar = foo.Clone(SHFORTRAN = r'%(_python_)s wrapper.py ' + shfortran) +bar.Append(SHFORTRANFLAGS = '-Ix') foo.SharedLibrary(target = 'foo/foo', source = 'foo.f') bar.SharedLibrary(target = 'bar/bar', source = 'bar.f') """ % locals()) @@ -156,7 +130,11 @@ bar.SharedLibrary(target = 'bar/bar', source = 'bar.f') test.must_not_exist('wrapper.out') - test.run(arguments = 'bar') + import sys + if sys.platform[:5] == 'sunos': + test.run(arguments = 'bar', stderr = None) + else: + test.run(arguments = 'bar') test.must_match('wrapper.out', "wrapper.py\n") diff --git a/test/Fortran/common.py b/test/Fortran/common.py new file mode 100644 index 0000000..0d991b6 --- /dev/null +++ b/test/Fortran/common.py @@ -0,0 +1,66 @@ +#!/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__" + + +"""This module implements common code to all fortran tests.""" + +import sys + +def write_fake_link(t): + """Writes a mylink.py script to remove the link step for 'fake' (e.g. + non-compiled) tests.""" + if sys.platform == 'win32': + t.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: + t.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) + """) diff --git a/test/Fortran/module-subdir.py b/test/Fortran/module-subdir.py index 88d0888..35f3c6f 100644 --- a/test/Fortran/module-subdir.py +++ b/test/Fortran/module-subdir.py @@ -75,7 +75,6 @@ sys.exit(0) test.write('SConstruct', """\ env = Environment(FORTRANMODDIRPREFIX = '-M', FORTRANMODDIR = 'modules', - F90 = r'%(_python_)s myfortran.py f90', FORTRAN = r'%(_python_)s myfortran.py fortran', AR = 'myar.py', ARCOM = r'%(_python_)s $AR $TARGET $SOURCES', @@ -89,13 +88,13 @@ test.write(['subdir', 'SConscript'], """\ Import('env') env['FORTRANMODDIR'] = 'build' -sources = ['src/modfile.f90'] +sources = ['src/modfile.f'] objs = env.Object(sources) Return("objs") """) -test.write(['subdir', 'src', 'modfile.f90'], """\ -#f90 comment +test.write(['subdir', 'src', 'modfile.f'], """\ +#fortran comment module somemodule integer :: nothing |