aboutsummaryrefslogtreecommitdiff
path: root/run_unittests.py
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2019-10-01 11:02:50 -0700
committerDylan Baker <dylan@pnwbakers.com>2020-05-18 13:53:58 -0700
commitcb6662b57299c3644719593115b2ffb828679c36 (patch)
tree27d15098799552bb16c501eafa7d4e5c807111fe /run_unittests.py
parente822889754a3f9ba1a1c9d9179dd24d102db3969 (diff)
downloadmeson-cb6662b57299c3644719593115b2ffb828679c36.zip
meson-cb6662b57299c3644719593115b2ffb828679c36.tar.gz
meson-cb6662b57299c3644719593115b2ffb828679c36.tar.bz2
backends: ensure that test executables can be run when passed as arguments
If an executable is passed as an argument to a script in the build directory that it resides in then it will not execute (on *nix) due to a lack of ./. Ie, `foo` must be called as `./foo`. If it is called from a different directory it will work. Ie `../foo` or `bar/foo`. Fixes #5984
Diffstat (limited to 'run_unittests.py')
-rwxr-xr-xrun_unittests.py25
1 files changed, 14 insertions, 11 deletions
diff --git a/run_unittests.py b/run_unittests.py
index 7467107..f8ca253 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -7560,19 +7560,28 @@ class CrossFileTests(BasePlatformTests):
c = '/usr/bin/{}'
ar = '/usr/bin/ar'
strip = '/usr/bin/ar'
+ {}
[properties]
needs_exe_wrapper = {}
- {}
[host_machine]
system = 'linux'
cpu_family = 'x86'
cpu = 'i686'
endian = 'little'
- """.format(cc, needs_exe_wrapper,
- 'exe_wrapper = {}'.format(str(exe_wrapper))
- if exe_wrapper is not None else ''))
+ """.format(cc,
+ 'exe_wrapper = {}'.format(str(exe_wrapper)) if exe_wrapper is not None else '',
+ needs_exe_wrapper))
+
+ def _stub_exe_wrapper(self) -> str:
+ return textwrap.dedent('''\
+ #!/usr/bin/env python3
+ import subprocess
+ import sys
+
+ sys.exit(subprocess.run(sys.argv[1:]).returncode)
+ ''')
def test_needs_exe_wrapper_true(self):
testdir = os.path.join(self.common_test_dir, '1 trivial')
@@ -7599,13 +7608,7 @@ class CrossFileTests(BasePlatformTests):
with tempfile.TemporaryDirectory() as d:
s = Path(d) / 'wrapper.py'
with s.open('wt') as f:
- f.write(textwrap.dedent('''
- #!/usr/bin/env python3
- import subprocess
- import sys
-
- return subprocess.run(sys.argv[1:]).returnncode
- '''))
+ f.write(self._stub_exe_wrapper())
p = Path(d) / 'crossfile'
with p.open('wt') as f:
f.write(self._cross_file_generator(