summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--QMTest/TestCmd.py10
-rw-r--r--QMTest/TestSCons.py2
-rw-r--r--fixture/mylink.py31
-rw-r--r--fixture/wrapper.py5
-rwxr-xr-xruntest.py4
-rw-r--r--src/engine/SCons/Scanner/Fortran.py12
-rw-r--r--src/engine/SCons/Tool/FortranCommon.py2
-rw-r--r--test/Fortran/F03.py14
-rw-r--r--test/Fortran/common.py75
9 files changed, 54 insertions, 101 deletions
diff --git a/QMTest/TestCmd.py b/QMTest/TestCmd.py
index 109c83a..370101b 100644
--- a/QMTest/TestCmd.py
+++ b/QMTest/TestCmd.py
@@ -1251,12 +1251,12 @@ class TestCmd(object):
if srcdir and self.fixture_dirs and not os.path.isabs(srcdir):
for dir in self.fixture_dirs:
- spath = os.path.join(self.fixture_dirs, srcdir)
+ spath = os.path.join(dir, srcdir)
if os.path.isdir(spath):
- continue
-
+ break
else:
spath = srcdir
+
if dstdir:
dstdir = self.canonicalize(dstdir)
else:
@@ -1295,9 +1295,9 @@ class TestCmd(object):
spath = srcfile
else:
for dir in self.fixture_dirs:
- spath = os.path.join(self.fixture_dirs, srcfile)
+ spath = os.path.join(dir, srcfile)
if os.path.isfile(spath):
- continue
+ break
if not dstfile:
if srctail:
diff --git a/QMTest/TestSCons.py b/QMTest/TestSCons.py
index f02ddd8..a987c5a 100644
--- a/QMTest/TestSCons.py
+++ b/QMTest/TestSCons.py
@@ -268,7 +268,7 @@ class TestSCons(TestCommon):
SCons.Node.FS.default_fs = SCons.Node.FS.FS()
try:
- self.fixture_dirs = os.environ['FIXTURE_DIRS'].split(':')
+ self.fixture_dirs = (os.environ['FIXTURE_DIRS']).split(':')
except KeyError:
pass
diff --git a/fixture/mylink.py b/fixture/mylink.py
new file mode 100644
index 0000000..7c03f00
--- /dev/null
+++ b/fixture/mylink.py
@@ -0,0 +1,31 @@
+import sys
+
+if sys.platform == 'win32':
+ args = sys.argv[1:]
+ while args:
+ a = args[0]
+ if a == '-o':
+ out = args[1]
+ args = args[2:]
+ continue
+ if not a[0] in '/-':
+ break
+ args = args[1:]
+ if a[:5].lower() == '/out:': out = a[5:]
+ infile = open(args[0], 'rb')
+ outfile = open(out, 'wb')
+ for l in infile.readlines():
+ if l[:5] != b'#link':
+ outfile.write(l)
+ sys.exit(0)
+else:
+ import getopt
+ 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] != b'#link':
+ outfile.write(l)
+ sys.exit(0)
diff --git a/fixture/wrapper.py b/fixture/wrapper.py
new file mode 100644
index 0000000..a797434
--- /dev/null
+++ b/fixture/wrapper.py
@@ -0,0 +1,5 @@
+import os
+import sys
+path = os.path.join(os.path.abspath(__file__), 'wrapper.out')
+open(path, 'wb').write(b"wrapper.py\n")
+os.system(" ".join(sys.argv[1:]))
diff --git a/runtest.py b/runtest.py
index dec8f9f..c856740 100755
--- a/runtest.py
+++ b/runtest.py
@@ -789,8 +789,8 @@ def run_test(t, io_lock, async=True):
fixture_dirs = []
if head:
fixture_dirs.append(head)
- fixture_dirs.append(os.path.join(os.path.split(os.path.abspath(__file__))[0], 'fixture'))
- os.environ['PYTHON_SCRIPT_DIR'] = ':'.join(fixture_dirs)
+ fixture_dirs.append(os.path.join(scriptpath, 'fixture'))
+ os.environ['FIXTURE_DIRS'] = ':'.join(fixture_dirs)
test_start_time = time_func()
if execute_tests:
diff --git a/src/engine/SCons/Scanner/Fortran.py b/src/engine/SCons/Scanner/Fortran.py
index 1b55130..9082015 100644
--- a/src/engine/SCons/Scanner/Fortran.py
+++ b/src/engine/SCons/Scanner/Fortran.py
@@ -82,11 +82,11 @@ class F90Scanner(SCons.Scanner.Classic):
mods_and_includes = node.includes
else:
# retrieve all included filenames
- includes = self.cre_incl.findall(node.get_text_contents())
+ includes = self.cre_incl.findall(node.get_contents())
# retrieve all USE'd module names
- modules = self.cre_use.findall(node.get_text_contents())
+ modules = self.cre_use.findall(node.get_contents())
# retrieve all defined module names
- defmodules = self.cre_def.findall(node.get_text_contents())
+ defmodules = self.cre_def.findall(node.get_contents())
# Remove all USE'd module names that are defined in the same file
# (case-insensitively)
@@ -187,7 +187,7 @@ def FortranScan(path_variable="FORTRANPATH"):
# (\w+) : match the module name that is being USE'd
#
#
- use_regex = "(?i)(?:^|;)\s*USE(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(\w+)"
+ use_regex = b"(?i)(?:^|;)\s*USE(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(\w+)"
# The INCLUDE statement regex matches the following:
@@ -275,7 +275,7 @@ def FortranScan(path_variable="FORTRANPATH"):
# set of semicolon-separated INCLUDE statements
# (as allowed by the F2003 standard)
- include_regex = """(?i)(?:^|['">]\s*;)\s*INCLUDE\s+(?:\w+_)?[<"'](.+?)(?=["'>])"""
+ include_regex = b"(?i)(?:^|['\">]\s*;)\s*INCLUDE\s+(?:\w+_)?[<\"'](.+?)(?=[\"'>])"
# The MODULE statement regex finds module definitions by matching
# the following:
@@ -299,7 +299,7 @@ def FortranScan(path_variable="FORTRANPATH"):
# that make up the defined module name and
# save it in a group
- def_regex = """(?i)^\s*MODULE\s+(?!PROCEDURE)(\w+)"""
+ def_regex = b"(?i)^\s*MODULE\s+(?!PROCEDURE)(\w+)"
scanner = F90Scanner("FortranScan",
"$FORTRANSUFFIXES",
diff --git a/src/engine/SCons/Tool/FortranCommon.py b/src/engine/SCons/Tool/FortranCommon.py
index e450730..1503639 100644
--- a/src/engine/SCons/Tool/FortranCommon.py
+++ b/src/engine/SCons/Tool/FortranCommon.py
@@ -64,7 +64,7 @@ def _fortranEmitter(target, source, env):
if not node.exists() and not node.is_derived():
print("Could not locate " + str(node.name))
return ([], [])
- mod_regex = """(?i)^\s*MODULE\s+(?!PROCEDURE)(\w+)"""
+ mod_regex = b"(?i)^\s*MODULE\s+(?!PROCEDURE)(\w+)"
cre = re.compile(mod_regex,re.M)
# Retrieve all USE'd module names
modules = cre.findall(node.get_text_contents())
diff --git a/test/Fortran/F03.py b/test/Fortran/F03.py
index ea706a9..3c6bba4 100644
--- a/test/Fortran/F03.py
+++ b/test/Fortran/F03.py
@@ -26,14 +26,12 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
import TestSCons
-from common import write_fake_link
-
_python_ = TestSCons._python_
_exe = TestSCons._exe
test = TestSCons.TestSCons()
-write_fake_link(test)
+test.file_fixture('mylink.py')
test.write('myfortran.py', r"""
import getopt
@@ -46,7 +44,7 @@ for opt, arg in opts:
infile = open(args[0], 'rb')
outfile = open(out, 'wb')
for l in infile.readlines():
- if l[:length] != comment:
+ if l[:length] != comment.encode():
outfile.write(l)
sys.exit(0)
""")
@@ -97,13 +95,7 @@ fc = 'f03'
g03 = test.detect_tool(fc)
if g03:
-
- test.write("wrapper.py",
-"""import os
-import sys
-open('%s', 'wb').write("wrapper.py\\n")
-os.system(" ".join(sys.argv[1:]))
-""" % test.workpath('wrapper.out').replace('\\', '\\\\'))
+ test.file_fixture('wrapper.py')
test.write('SConstruct', """
foo = Environment(F03 = '%(fc)s')
diff --git a/test/Fortran/common.py b/test/Fortran/common.py
deleted file mode 100644
index 6763ef4..0000000
--- a/test/Fortran/common.py
+++ /dev/null
@@ -1,75 +0,0 @@
-#!/usr/bin/env python
-#
-# __COPYRIGHT__
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be included
-# in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
-# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
-# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-#
-
-__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
-
-
-"""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 sys
-args = sys.argv[1:]
-while args:
- a = args[0]
- if a == '-o':
- out = args[1]
- args = args[2:]
- continue
- if not a[0] in '/-':
- break
- args = args[1:]
- if a[:5].lower() == '/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)
- """)
-
-# Local Variables:
-# tab-width:4
-# indent-tabs-mode:nil
-# End:
-# vim: set expandtab tabstop=4 shiftwidth=4: