summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMats Wichmann <mats@linux.com>2022-01-18 23:15:50 (GMT)
committerMats Wichmann <mats@linux.com>2022-01-18 23:15:50 (GMT)
commitb54e9d95e0ee70460cdb86773f31660f2c16d650 (patch)
treedf09e9a1e9cc8ee3f4804cce5bcf7e4766d95066
parent8c9ff2495360cdf0928ba13dfa8149f86abe1bc6 (diff)
downloadSCons-b54e9d95e0ee70460cdb86773f31660f2c16d650.zip
SCons-b54e9d95e0ee70460cdb86773f31660f2c16d650.tar.gz
SCons-b54e9d95e0ee70460cdb86773f31660f2c16d650.tar.bz2
Also move CC and CXX mock compiler to fixture
CC/CC.py uses a local mycc.py and CXX/CXX.py uses a local myc++.py. These could not be replaced by mycompile.py because theu usage model is different, but these two are moved to a local (to the test) fixture directory instead of being inline. Signed-off-by: Mats Wichmann <mats@linux.com>
-rw-r--r--test/CC/CC-fixture/.exclude_tests1
-rw-r--r--test/CC/CC-fixture/mycc.py55
-rw-r--r--test/CC/CC.py48
-rw-r--r--test/CXX/CXX-fixture/.exclude_tests1
-rw-r--r--test/CXX/CXX-fixture/myc++.py55
-rw-r--r--test/CXX/CXX.py47
6 files changed, 113 insertions, 94 deletions
diff --git a/test/CC/CC-fixture/.exclude_tests b/test/CC/CC-fixture/.exclude_tests
new file mode 100644
index 0000000..3f2bc0f
--- /dev/null
+++ b/test/CC/CC-fixture/.exclude_tests
@@ -0,0 +1 @@
+mycc.py
diff --git a/test/CC/CC-fixture/mycc.py b/test/CC/CC-fixture/mycc.py
new file mode 100644
index 0000000..78017f4
--- /dev/null
+++ b/test/CC/CC-fixture/mycc.py
@@ -0,0 +1,55 @@
+"""
+Phony cc command for testing SCons.
+
+Copies its source file to the target file, dropping lines that match
+a pattern, so we can recognize the tool has made a modification.
+Intended for use as the $CXX construction variable.
+
+Note: mycc.py differs from the general fixture file mycompile.py
+in arg handling: that one is intended for use as a *COM consvar,
+where no compiler consvars will be passed on, this one is intended
+for use as $CC, where arguments like -o come into play.
+"""
+import getopt
+import sys
+
+def fake_win32_cc():
+ args = sys.argv[1:]
+ inf = None
+ while args:
+ a = args[0]
+ if a == '-o':
+ out = args[1]
+ args = args[2:]
+ continue
+ args = args[1:]
+ if a[0] not in '/-':
+ if not inf:
+ inf = a
+ continue
+ if a[:3] == '/Fo':
+ out = a[3:]
+
+ with open(inf, 'rb') as infile, open(out, 'wb') as outfile:
+ for line in infile:
+ if not line.startswith(b'/*cc*/'):
+ outfile.write(line)
+
+def fake_cc():
+ opts, args = getopt.getopt(sys.argv[1:], 'co:')
+ for opt, arg in opts:
+ if opt == '-o':
+ out = arg
+
+ with open(args[0], 'rb') as infile, open(out, 'wb') as outfile:
+ for line in infile:
+ if not line.startswith(b'/*cc*/'):
+ outfile.write(line)
+
+if __name__ == '__main__':
+ print(f"DEBUG: {sys.argv[0]}: {sys.argv[1:]}")
+ if sys.platform == 'win32':
+ fake_win32_cc()
+ else:
+ fake_cc()
+ sys.exit(0)
diff --git a/test/CC/CC.py b/test/CC/CC.py
index c2562d5..a548421 100644
--- a/test/CC/CC.py
+++ b/test/CC/CC.py
@@ -35,54 +35,6 @@ test = TestSCons.TestSCons()
test.dir_fixture('CC-fixture')
test.file_fixture('mylink.py')
-# Note: mycc.py differs from the general fixture file mycompile.py
-# in arg handling: that one is intended for use as a *COM consvar,
-# where no compiler consvars will be passed on, this one is intended
-# for use as $CC, where arguments like -o come into play.
-if sys.platform == 'win32':
- test.write('mycc.py', r"""
-import sys
-
-args = sys.argv[1:]
-inf = None
-while args:
- a = args[0]
- if a == '-o':
- out = args[1]
- args = args[2:]
- continue
- args = args[1:]
- if a[0] not in '-/':
- if not inf:
- inf = a
- continue
- if a.startswith('/Fo'):
- out = a[3:]
-
-with open(inf, 'rb') as infile, open(out, 'wb') as outfile:
- for line in infile:
- if not line.startswith(b'/*cc*/'):
- outfile.write(line)
-sys.exit(0)
-""")
-
-else:
- test.write('mycc.py', r"""
-import getopt
-import sys
-
-opts, args = getopt.getopt(sys.argv[1:], 'co:')
-for opt, arg in opts:
- if opt == '-o':
- out = arg
-
-with open(args[0], 'rb') as infile, open(out, 'wb') as outfile:
- for line in infile:
- if not line.startswith(b'/*cc*/'):
- outfile.write(line)
-sys.exit(0)
-""")
-
test.write('SConstruct', """
cc = Environment().Dictionary('CC')
env = Environment(
diff --git a/test/CXX/CXX-fixture/.exclude_tests b/test/CXX/CXX-fixture/.exclude_tests
new file mode 100644
index 0000000..9e0e6ff
--- /dev/null
+++ b/test/CXX/CXX-fixture/.exclude_tests
@@ -0,0 +1 @@
+myc++.py
diff --git a/test/CXX/CXX-fixture/myc++.py b/test/CXX/CXX-fixture/myc++.py
new file mode 100644
index 0000000..06565c7
--- /dev/null
+++ b/test/CXX/CXX-fixture/myc++.py
@@ -0,0 +1,55 @@
+"""
+Phony c++ command for testing SCons.
+
+Copies its source file to the target file, dropping lines that match
+a pattern, so we can recognize the tool has made a modification.
+Intended for use as the $CXX construction variable.
+
+Note: mycxx.py differs from the general fixture file mycompile.py
+in arg handling: that one is intended for use as a *COM consvar,
+where no compiler consvars will be passed on, this one is intended
+for use as $CXX, where arguments like -o come into play.
+"""
+import getopt
+import sys
+
+def fake_win32_cxx():
+ args = sys.argv[1:]
+ inf = None
+ while args:
+ a = args[0]
+ if a == '-o':
+ out = args[1]
+ args = args[2:]
+ continue
+ args = args[1:]
+ if a[0] not in '/-':
+ if not inf:
+ inf = a
+ continue
+ if a[:3] == '/Fo':
+ out = a[3:]
+
+ with open(inf, 'rb') as infile, open(out, 'wb') as outfile:
+ for line in infile:
+ if not line.startswith(b'/*c++*/'):
+ outfile.write(line)
+
+def fake_cxx():
+ opts, args = getopt.getopt(sys.argv[1:], 'co:')
+ for opt, arg in opts:
+ if opt == '-o':
+ out = arg
+
+ with open(args[0], 'rb') as infile, open(out, 'wb') as outfile:
+ for line in infile:
+ if not line.startswith(b'/*c++*/'):
+ outfile.write(line)
+
+if __name__ == '__main__':
+ print(f"DEBUG: {sys.argv[0]}: {sys.argv[1:]}")
+ if sys.platform == 'win32':
+ fake_win32_cxx()
+ else:
+ fake_cxx()
+ sys.exit(0)
diff --git a/test/CXX/CXX.py b/test/CXX/CXX.py
index 836324f..ad00b55 100644
--- a/test/CXX/CXX.py
+++ b/test/CXX/CXX.py
@@ -32,52 +32,7 @@ _exe = TestSCons._exe
test = TestSCons.TestSCons()
test.file_fixture('mylink.py')
-
-# Note: mycxx.py differs from the general fixture file mycompile.py
-# in arg handling: that one is intended for use as a *COM consvar,
-# where no compiler consvars will be passed on, this one is intended
-# for use as $CXX, where arguments like -o come into play.
-if sys.platform == 'win32':
- test.write('myc++.py', r"""
-import sys
-
-args = sys.argv[1:]
-inf = None
-while args:
- a = args[0]
- if a == '-o':
- out = args[1]
- args = args[2:]
- continue
- args = args[1:]
- if not a[0] in '/-':
- if not inf:
- inf = a
- continue
- if a[:3] == '/Fo': out = a[3:]
-
-with open(inf, 'rb') as infile, open(out, 'wb') as outfile:
- for line in infile:
- if not line.startswith(b'/*c++*/'):
- outfile.write(line)
-sys.exit(0)
-""")
-
-else:
- test.write('myc++.py', r"""
-import getopt
-import sys
-
-opts, args = getopt.getopt(sys.argv[1:], 'co:')
-for opt, arg in opts:
- if opt == '-o': out = arg
-
-with open(args[0], 'rb') as infile, open(out, 'wb') as outfile:
- for line in infile:
- if not line.startswith(b'/*c++*/'):
- outfile.write(line)
-sys.exit(0)
-""")
+test.dir_fixture('CXX-fixture')
test.write('SConstruct', """
env = Environment(