summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMats Wichmann <mats@linux.com>2022-06-09 17:30:47 (GMT)
committerMats Wichmann <mats@linux.com>2022-06-16 17:07:08 (GMT)
commite2033e5f52002d404383c97e3a6a010efef174c8 (patch)
tree0f6ed23b38cf5f213b1497c6d1989b23f7d45ba8 /test
parent067e290d832e17158aeb068bddb39dc9ad46d5cc (diff)
downloadSCons-e2033e5f52002d404383c97e3a6a010efef174c8.zip
SCons-e2033e5f52002d404383c97e3a6a010efef174c8.tar.gz
SCons-e2033e5f52002d404383c97e3a6a010efef174c8.tar.bz2
Fortran vairants now include FORTRANCOMMONFLAGS
The documentation suggested $FORTRANFLAGS was included in the build lines for all variants, but it was not. Turns out the test suite quite explicitly checks that FORTRANFLAGS doesn't leak through to other variants, so instead define a new FORTRANCOMMONFLAGS to serve the purpose of a flag that applies to all variants. Assorted cleanup. And f-strings. Fixes #2257 Signed-off-by: Mats Wichmann <mats@linux.com>
Diffstat (limited to 'test')
-rw-r--r--test/Fortran/F77PATH.py78
-rw-r--r--test/Fortran/F90PATH.py66
-rw-r--r--test/Fortran/FORTRANCOMMONFLAGS.py132
-rw-r--r--test/Fortran/FORTRANFILESUFFIXES2.py43
-rw-r--r--test/Fortran/FORTRANPATH.py54
-rw-r--r--test/Fortran/fixture/myfortran.py17
-rw-r--r--test/Fortran/fixture/myfortran_flags.py17
7 files changed, 255 insertions, 152 deletions
diff --git a/test/Fortran/F77PATH.py b/test/Fortran/F77PATH.py
index 260782c..e594978 100644
--- a/test/Fortran/F77PATH.py
+++ b/test/Fortran/F77PATH.py
@@ -1,6 +1,8 @@
#!/usr/bin/env python
#
-# __COPYRIGHT__
+# MIT License
+#
+# Copyright The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
@@ -20,9 +22,6 @@
# 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
@@ -39,30 +38,27 @@ test = TestSCons.TestSCons()
fc = 'f77'
if not test.detect_tool(fc):
- test.skip_test('Could not find a f77 tool; skipping test.\n')
-
-test.subdir('include',
- 'subdir',
- ['subdir', 'include'],
- 'foobar',
- 'inc2')
-
-
-
-test.write('SConstruct', """
-env = Environment(F77 = '%s',
- F77PATH = ['$FOO', '${TARGET.dir}', '${SOURCE.dir}'],
- FOO='include',
- F77FLAGS = '-x f77')
+ # gfortran names all variants the same, try it too
+ fc = 'gfortran'
+ if not test.detect_tool(fc):
+ test.skip_test('Could not find a f77 tool; skipping test.\n')
+
+test.subdir('include', 'subdir', ['subdir', 'include'], 'foobar', 'inc2')
+
+test.write('SConstruct', """\
+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')
env.Program(target='prog', source=obj)
SConscript('subdir/SConscript', "env")
VariantDir('variant', 'subdir', 0)
include = Dir('include')
-env = Environment(F77 = '%s',
- F77PATH=[include, '#foobar', '#subdir'],
- F77FLAGS = '-x f77')
+env = Environment(F77='%s', F77PATH=[include, '#foobar', '#subdir'], F77FLAGS='-x f77')
SConscript('variant/SConscript', "env")
""" % (fc, fc))
@@ -115,8 +111,6 @@ r"""
PRINT *, 'subdir/ttt.f77'
""")
-
-
test.run(arguments = args)
test.run(program = test.workpath(prog),
@@ -151,8 +145,6 @@ test.must_not_exist(test.workpath('variant', 'prog.f77'))
test.up_to_date(arguments = args)
-
-
test.write(['include', 'foo.f77'],
r"""
PRINT *, 'include/foo.f77 2'
@@ -193,9 +185,6 @@ test.must_not_exist(test.workpath('variant', 'prog.f77'))
test.up_to_date(arguments = args)
-
-
-#
test.write(['include', 'bar.f77'],
r"""
PRINT *, 'include/bar.f77 2'
@@ -235,22 +224,22 @@ test.must_not_exist(test.workpath('variant', 'prog.f77'))
test.up_to_date(arguments = args)
-
-
# Change F77PATH and make sure we don't rebuild because of it.
-test.write('SConstruct', """
-env = Environment(F77 = '%s',
- F77PATH = Split('inc2 include ${TARGET.dir} ${SOURCE.dir}'),
- F77FLAGS = '-x f77')
+test.write('SConstruct', """\
+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)
SConscript('subdir/SConscript', "env")
VariantDir('variant', 'subdir', 0)
include = Dir('include')
-env = Environment(F77 = '%s',
- F77PATH=['inc2', include, '#foobar', '#subdir'],
- F77FLAGS = '-x f77')
+env = Environment(
+ F77='%s', F77PATH=['inc2', include, '#foobar', '#subdir'], F77FLAGS='-x f77'
+)
SConscript('variant/SConscript', "env")
""" % (fc, fc))
@@ -294,20 +283,15 @@ test.run(program = test.workpath(variant_prog),
test.up_to_date(arguments = args)
-
-
# Check that a null-string F77PATH doesn't blow up.
-test.write('SConstruct', """
-env = Environment(tools = ['f77'], F77PATH = '', F77FLAGS = '-x f77')
-env.Object('foo', source = 'empty.f77')
-""")
+test.write('SConstruct', """\
+env = Environment(tools=['%s'], F77PATH='', F77FLAGS='-x f77')
+env.Object('foo', source='empty.f77')
+""" % fc)
test.write('empty.f77', '')
-
test.run(arguments = '.')
-
-
test.pass_test()
# Local Variables:
diff --git a/test/Fortran/F90PATH.py b/test/Fortran/F90PATH.py
index 341b241..58c6c90 100644
--- a/test/Fortran/F90PATH.py
+++ b/test/Fortran/F90PATH.py
@@ -1,6 +1,8 @@
#!/usr/bin/env python
#
-# __COPYRIGHT__
+# MIT License
+#
+# Copyright The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
@@ -20,9 +22,6 @@
# 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
@@ -39,32 +38,29 @@ test = TestSCons.TestSCons()
fc = 'f90'
if not test.detect_tool(fc):
- test.skip_test('Could not find a f90 tool; skipping test.\n')
-
-test.subdir('include',
- 'subdir',
- ['subdir', 'include'],
- 'foobar',
- 'inc2')
-
+ # gfortran names all variants the same, try it too
+ fc = 'gfortran'
+ if not test.detect_tool(fc):
+ test.skip_test('Could not find a f90 tool; skipping test.\n')
+test.subdir('include', 'subdir', ['subdir', 'include'], 'foobar', 'inc2')
test.write('SConstruct', """
-env = Environment(F90 = r'%s',
- F90PATH = ['$FOO', '${TARGET.dir}', '${SOURCE.dir}'],
- LINK = '$F90',
- FOO='include')
+env = Environment(
+ F90=r'%s',
+ F90PATH=['$FOO', '${TARGET.dir}', '${SOURCE.dir}'],
+ LINK='$F90',
+ FOO='include',
+)
obj = env.Object(target='foobar/prog', source='subdir/prog.f90')
env.Program(target='prog', source=obj)
SConscript('subdir/SConscript', "env")
VariantDir('variant', 'subdir', 0)
include = Dir('include')
-env = Environment(F90 = r'%s',
- F90PATH=[include, '#foobar', '#subdir'],
- LINK = '$F90')
+env = Environment(F90=r'%s', F90PATH=[include, '#foobar', '#subdir'], LINK='$F90')
SConscript('variant/SConscript', "env")
-""" % (fc, fc, ))
+""" % (fc, fc))
test.write(['subdir', 'SConscript'],
"""
@@ -115,8 +111,6 @@ r"""
PRINT *, 'subdir/ttt.f90'
""")
-
-
test.run(arguments = args)
test.run(program = test.workpath(prog),
@@ -151,8 +145,6 @@ test.must_not_exist(test.workpath('variant', 'prog.f90'))
test.up_to_date(arguments = args)
-
-
test.write(['include', 'foo.f90'],
r"""
PRINT *, 'include/foo.f90 2'
@@ -193,9 +185,6 @@ test.must_not_exist(test.workpath('variant', 'prog.f90'))
test.up_to_date(arguments = args)
-
-
-#
test.write(['include', 'bar.f90'],
r"""
PRINT *, 'include/bar.f90 2'
@@ -238,27 +227,28 @@ test.up_to_date(arguments = args)
# Change F90PATH and make sure we don't rebuild because of it.
-test.write('SConstruct', """
-env = Environment(F90 = r'%s',
- F90PATH = Split('inc2 include ${TARGET.dir} ${SOURCE.dir}'),
- LINK = '$F90')
+test.write('SConstruct', """\
+env = Environment(
+ F90=r'%s',
+ F90PATH=Split('inc2 include ${TARGET.dir} ${SOURCE.dir}'),
+ LINK='$F90'
+)
obj = env.Object(target='foobar/prog', source='subdir/prog.f90')
env.Program(target='prog', source=obj)
SConscript('subdir/SConscript', "env")
VariantDir('variant', 'subdir', 0)
include = Dir('include')
-env = Environment(F90 = r'%s',
- F90PATH=['inc2', include, '#foobar', '#subdir'],
- LINK = '$F90')
+env = Environment(
+ F90=r'%s',
+ F90PATH=['inc2', include, '#foobar', '#subdir'],
+ LINK='$F90',
+)
SConscript('variant/SConscript', "env")
""" % (fc, fc))
test.up_to_date(arguments = args)
-
-
-#
test.write(['inc2', 'foo.f90'],
r"""
PRINT *, 'inc2/foo.f90 1'
@@ -296,8 +286,6 @@ test.run(program = test.workpath(variant_prog),
test.up_to_date(arguments = args)
-
-
test.pass_test()
# Local Variables:
diff --git a/test/Fortran/FORTRANCOMMONFLAGS.py b/test/Fortran/FORTRANCOMMONFLAGS.py
new file mode 100644
index 0000000..9030709
--- /dev/null
+++ b/test/Fortran/FORTRANCOMMONFLAGS.py
@@ -0,0 +1,132 @@
+#!/usr/bin/env python
+#
+# MIT License
+#
+# Copyright The SCons Foundation
+#
+# 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.
+
+"""
+Test that while FORTRANFLAGS is not passed to another dialect,
+FORTRANCOMMONFLAGS is passed to both.
+"""
+
+import TestSCons
+
+_python_ = TestSCons._python_
+
+test = TestSCons.TestSCons()
+_exe = TestSCons._exe
+
+test.file_fixture('mylink.py')
+test.file_fixture(['fixture', 'myfortran_flags.py'])
+
+test.write('SConstruct', """
+env = Environment(
+ LINK=r'%(_python_)s mylink.py',
+ LINKFLAGS=[],
+ F90=r'%(_python_)s myfortran_flags.py g90',
+ F90FLAGS='-x',
+ FORTRAN=r'%(_python_)s myfortran_flags.py fortran',
+ FORTRANFLAGS='-y',
+ FORTRANCOMMONFLAGS='-z',
+)
+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='test11', source='test11.f90')
+env.Program(target='test12', source='test12.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('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.run(arguments = '.', stderr = None)
+
+test.must_match('test01' + _exe, " -c -z -y\nThis is a .f file.\n")
+test.must_match('test02' + _exe, " -c -z -y\nThis is a .F file.\n")
+test.must_match('test03' + _exe, " -c -z -y\nThis is a .for file.\n")
+test.must_match('test04' + _exe, " -c -z -y\nThis is a .FOR file.\n")
+test.must_match('test05' + _exe, " -c -z -y\nThis is a .ftn file.\n")
+test.must_match('test06' + _exe, " -c -z -y\nThis is a .FTN file.\n")
+test.must_match('test07' + _exe, " -c -z -y\nThis is a .fpp file.\n")
+test.must_match('test08' + _exe, " -c -z -y\nThis is a .FPP file.\n")
+test.must_match('test11' + _exe, " -c -z -x\nThis is a .f90 file.\n")
+test.must_match('test12' + _exe, " -c -z -x\nThis is a .F90 file.\n")
+
+
+fc = 'f90'
+g90 = test.detect_tool(fc)
+if g90:
+ test.file_fixture('wrapper.py')
+
+ test.write('SConstruct', """
+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.f90')
+bar.Program(target='bar', source='bar.f90')
+""" % locals())
+
+ test.write('foo.f90', r"""
+ PROGRAM FOO
+ PRINT *,'foo.f90'
+ END
+""")
+
+ test.write('bar.f90', r"""
+ PROGRAM BAR
+ PRINT *,'bar.f90'
+ END
+""")
+
+ test.run(arguments='foo' + _exe, stderr=None)
+ test.run(program=test.workpath('foo'), stdout=" foo.f90\n")
+ test.must_not_exist('wrapper.out')
+
+ 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.f90\n")
+ test.must_match('wrapper.out', "wrapper.py\n")
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/Fortran/FORTRANFILESUFFIXES2.py b/test/Fortran/FORTRANFILESUFFIXES2.py
index a57dd2a..4ec4260 100644
--- a/test/Fortran/FORTRANFILESUFFIXES2.py
+++ b/test/Fortran/FORTRANFILESUFFIXES2.py
@@ -1,6 +1,8 @@
#!/usr/bin/env python
#
-# __COPYRIGHT__
+# MIT License
+#
+# Copyright The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
@@ -20,14 +22,11 @@
# 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 TestSCons
_python_ = TestSCons._python_
-_exe = TestSCons._exe
+_exe = TestSCons._exe
test = TestSCons.TestSCons()
@@ -35,28 +34,30 @@ test.file_fixture('mylink.py')
test.file_fixture(['fixture', 'myfortran.py'])
# 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')
+test.write( 'SConstruct', """\
+DefaultEnvironment(tools=[])
+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'],
+)
+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('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.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")
diff --git a/test/Fortran/FORTRANPATH.py b/test/Fortran/FORTRANPATH.py
index d80a825..3a62c45 100644
--- a/test/Fortran/FORTRANPATH.py
+++ b/test/Fortran/FORTRANPATH.py
@@ -37,28 +37,26 @@ test = TestSCons.TestSCons()
fc = 'f77'
if not test.detect_tool(fc):
- test.skip_test('Could not find a f77 tool; skipping test.\n')
-
-test.subdir('include',
- 'subdir',
- ['subdir', 'include'],
- 'foobar',
- 'inc2')
-
-
-
-test.write('SConstruct', """
-env = Environment(FORTRAN = '%s',
- FORTRANPATH = ['$FOO', '${TARGET.dir}', '${SOURCE.dir}'],
- FOO='include')
+ # gfortran names all variants the same, try it too
+ fc = 'gfortran'
+ if not test.detect_tool(fc):
+ test.skip_test('Could not find a f77 tool; skipping test.\n')
+
+test.subdir('include', 'subdir', ['subdir', 'include'], 'foobar', 'inc2')
+
+test.write('SConstruct', """\
+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(FORTRAN = '%s',
- FORTRANPATH=[include, '#foobar', '#subdir'])
+env = Environment(FORTRAN='%s', FORTRANPATH=[include, '#foobar', '#subdir'])
SConscript('variant/SConscript', "env")
""" % (fc, fc))
@@ -151,8 +149,6 @@ test.must_not_exist(test.workpath('variant', 'prog.f'))
test.up_to_date(arguments = args)
-
-
test.write(['include', 'foo.f'],
r"""
PRINT *, 'include/foo.f 2'
@@ -197,9 +193,6 @@ test.must_not_exist(test.workpath('variant', 'prog.f'))
test.up_to_date(arguments = args)
-
-
-#
test.write(['include', 'bar.f'],
r"""
PRINT *, 'include/bar.f 2'
@@ -247,25 +240,26 @@ test.up_to_date(arguments = args)
# Change FORTRANPATH and make sure we don't rebuild because of it.
-test.write('SConstruct', """
-env = Environment(FORTRAN = '%s',
- FORTRANPATH = Split('inc2 include ${TARGET.dir} ${SOURCE.dir}'))
+test.write('SConstruct', """\
+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(FORTRAN = '%s',
- FORTRANPATH=['inc2', include, '#foobar', '#subdir'])
+env = Environment(
+ FORTRAN='%s',
+ FORTRANPATH=['inc2', include, '#foobar', '#subdir'],
+)
SConscript('variant/SConscript', "env")
""" % (fc, fc))
test.up_to_date(arguments = args)
-
-
-#
test.write(['inc2', 'foo.f'],
r"""
PRINT *, 'inc2/foo.f 1'
@@ -308,8 +302,6 @@ test.run(program = test.workpath(variant_prog),
test.up_to_date(arguments = args)
-
-
# Check that a null-string FORTRANPATH doesn't blow up.
test.write('SConstruct', """
env = Environment(FORTRANPATH = '')
diff --git a/test/Fortran/fixture/myfortran.py b/test/Fortran/fixture/myfortran.py
index 08d1489..6b4e5ef 100644
--- a/test/Fortran/fixture/myfortran.py
+++ b/test/Fortran/fixture/myfortran.py
@@ -1,14 +1,17 @@
import getopt
import sys
+
print(sys.argv)
comment = ('#' + sys.argv[1]).encode()
-length = len(comment)
+
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')
-outfile = open(out, 'wb')
-for l in infile.readlines():
- if l[:length] != comment:
- outfile.write(l)
+ if opt == '-o':
+ out = arg
+
+with open(args[0], 'rb') as infile, open(out, 'wb') as outfile:
+ for l in infile:
+ if not l.startswith(comment):
+ outfile.write(l)
+
sys.exit(0)
diff --git a/test/Fortran/fixture/myfortran_flags.py b/test/Fortran/fixture/myfortran_flags.py
index b972e35..2b433ea 100644
--- a/test/Fortran/fixture/myfortran_flags.py
+++ b/test/Fortran/fixture/myfortran_flags.py
@@ -1,16 +1,19 @@
import getopt
import sys
+
comment = ('#' + sys.argv[1]).encode()
-opts, args = getopt.getopt(sys.argv[2:], 'cf:o:xy')
+
+opts, args = getopt.getopt(sys.argv[2:], 'cf:o:xyz')
optstring = ''
length = len(comment)
for opt, arg in opts:
if opt == '-o': out = arg
elif opt not in ('-f', '-K'): optstring = optstring + ' ' + opt
-infile = open(args[0], 'rb')
-outfile = open(out, 'wb')
-outfile.write((optstring + "\n").encode())
-for l in infile.readlines():
- if l[:length] != comment:
- outfile.write(l)
+
+with open(args[0], 'rb') as infile, open(out, 'wb') as outfile:
+ outfile.write((optstring + "\n").encode())
+ for l in infile:
+ if not l.startswith(comment):
+ outfile.write(l)
+
sys.exit(0)