diff options
author | Mats Wichmann <mats@linux.com> | 2022-06-09 17:30:47 (GMT) |
---|---|---|
committer | Mats Wichmann <mats@linux.com> | 2022-06-16 17:07:08 (GMT) |
commit | e2033e5f52002d404383c97e3a6a010efef174c8 (patch) | |
tree | 0f6ed23b38cf5f213b1497c6d1989b23f7d45ba8 /test/Fortran/fixture | |
parent | 067e290d832e17158aeb068bddb39dc9ad46d5cc (diff) | |
download | SCons-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/Fortran/fixture')
-rw-r--r-- | test/Fortran/fixture/myfortran.py | 17 | ||||
-rw-r--r-- | test/Fortran/fixture/myfortran_flags.py | 17 |
2 files changed, 20 insertions, 14 deletions
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) |