diff options
author | Mats Wichmann <mats@linux.com> | 2020-01-29 12:37:08 -0700 |
---|---|---|
committer | Mats Wichmann <mats@linux.com> | 2020-02-12 10:47:46 -0700 |
commit | 4814146dc3f69729e22f89078a5783a82e9df039 (patch) | |
tree | 9981cdd637b16dc1eeeb0c16405061540b15be15 /test/fixture | |
parent | eebcc30c898269ddb2fcfff846544a077059d10b (diff) | |
download | scons-git-4814146dc3f69729e22f89078a5783a82e9df039.tar.gz |
test cleanups: use harness python
In a few places, a command line was built to execute a wrapper
script written in Python, but the Python used was not the one used
to invoke the test run (which is made available by TestSCons), but
the result of running test.where_is('python'). On a system which
still has the thing named 'python' resolve to Python 2, this fails,
through no fault of scons itself.
The two fixture wrapper scripts used occasionally by the tests
used subprocess.call; this is considered "old" though not marked
as deprecated at this time. Switched to subprocess.run. See:
https://docs.python.org/3/library/subprocess.html#older-high-level-api
One of these scripts was doing unnecessary bytes-twiddling.
Modernized the inline myswig.py script (in test/SWIG/SWIG.py).
This script was reformatted using Black along the way.
Signed-off-by: Mats Wichmann <mats@linux.com>
Diffstat (limited to 'test/fixture')
-rw-r--r-- | test/fixture/mycompile.py | 2 | ||||
-rw-r--r-- | test/fixture/mylink.py | 12 | ||||
-rw-r--r-- | test/fixture/myrewrite.py | 2 | ||||
-rw-r--r-- | test/fixture/wrapper.py | 6 | ||||
-rw-r--r-- | test/fixture/wrapper_with_args.py | 2 |
5 files changed, 12 insertions, 12 deletions
diff --git a/test/fixture/mycompile.py b/test/fixture/mycompile.py index 27bf840e9..0f37d19a0 100644 --- a/test/fixture/mycompile.py +++ b/test/fixture/mycompile.py @@ -13,7 +13,7 @@ if __name__ == '__main__': with open(sys.argv[2], 'wb') as ofp: for f in sys.argv[3:]: with open(f, 'rb') as ifp: - lines = [ln for ln in ifp.readlines() if ln != line] + lines = [ln for ln in ifp if ln != line] for ln in lines: ofp.write(ln) sys.exit(0) diff --git a/test/fixture/mylink.py b/test/fixture/mylink.py index b56711816..38d984643 100644 --- a/test/fixture/mylink.py +++ b/test/fixture/mylink.py @@ -23,9 +23,9 @@ if __name__ == '__main__': args = args[1:] if a[:5].lower() == '/out:': out = a[5:] with open(args[0], 'rb') as ifp, open(out, 'wb') as ofp: - for l in ifp.readlines(): - if not l.startswith(b'#link'): - ofp.write(l) + for line in ifp: + if not line.startswith(b'#link'): + ofp.write(line) sys.exit(0) else: import getopt @@ -33,7 +33,7 @@ if __name__ == '__main__': for opt, arg in opts: if opt == '-o': out = arg with open(args[0], 'rb') as ifp, open(out, 'wb') as ofp: - for l in ifp.readlines(): - if not l.startswith(b'#link'): - ofp.write(l) + for line in ifp: + if not line.startswith(b'#link'): + ofp.write(line) sys.exit(0) diff --git a/test/fixture/myrewrite.py b/test/fixture/myrewrite.py index ad4609197..691461147 100644 --- a/test/fixture/myrewrite.py +++ b/test/fixture/myrewrite.py @@ -10,7 +10,7 @@ import sys if __name__ == '__main__': line = ('/*' + sys.argv[1] + '*/\n').encode() with open(sys.argv[2], 'rb') as ifp: - lines = [ln for ln in ifp.readlines() if ln != line] + lines = [ln for ln in ifp if ln != line] with open(sys.argv[2], 'wb') as ofp: for ln in lines: ofp.write(ln) diff --git a/test/fixture/wrapper.py b/test/fixture/wrapper.py index a02368996..d9bcefe2f 100644 --- a/test/fixture/wrapper.py +++ b/test/fixture/wrapper.py @@ -5,6 +5,6 @@ import subprocess if __name__ == '__main__': path = os.path.join(os.path.dirname(os.path.relpath(__file__)), 'wrapper.out') if '--version' not in sys.argv and '-dumpversion' not in sys.argv: - with open(path, 'wb') as f: - f.write(b"wrapper.py\n") - subprocess.call(sys.argv[1:]) + with open(path, 'w') as f: + f.write("wrapper.py\n") + subprocess.run(sys.argv[1:]) diff --git a/test/fixture/wrapper_with_args.py b/test/fixture/wrapper_with_args.py index f9e4d2210..b8d6ae519 100644 --- a/test/fixture/wrapper_with_args.py +++ b/test/fixture/wrapper_with_args.py @@ -6,4 +6,4 @@ if __name__ == '__main__': path = os.path.join(os.path.dirname(os.path.relpath(__file__)), 'wrapper.out') with open(path, 'a') as f: f.write("wrapper_with_args.py %s\n" % " ".join(sys.argv[1:])) - subprocess.call(sys.argv[1:]) + subprocess.run(sys.argv[1:]) |