diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2019-10-01 09:41:03 -0700 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2020-05-18 13:53:58 -0700 |
commit | e822889754a3f9ba1a1c9d9179dd24d102db3969 (patch) | |
tree | e54eaf7f28c89bb44aad05192533a2983e60abc2 | |
parent | 88f4bc6b55f5fb77e69796b5bee92f109a0ab160 (diff) | |
download | meson-e822889754a3f9ba1a1c9d9179dd24d102db3969.zip meson-e822889754a3f9ba1a1c9d9179dd24d102db3969.tar.gz meson-e822889754a3f9ba1a1c9d9179dd24d102db3969.tar.bz2 |
tests: Add tests for cross file exe_wrapper
tests needs_exe wrapper but doesn't have one, !needs_exe_wrapper, and
needs_exe_wrapper and has one.
-rwxr-xr-x | run_unittests.py | 54 |
1 files changed, 52 insertions, 2 deletions
diff --git a/run_unittests.py b/run_unittests.py index 6712343..7467107 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -40,6 +40,7 @@ from contextlib import contextmanager from glob import glob from pathlib import (PurePath, Path) from distutils.dir_util import copy_tree +import typing import mesonbuild.mlog import mesonbuild.depfile @@ -7545,7 +7546,10 @@ class CrossFileTests(BasePlatformTests): This is mainly aimed to testing overrides from cross files. """ - def _cross_file_generator(self) -> str: + def _cross_file_generator(self, *, needs_exe_wrapper: bool = False, + exe_wrapper: typing.Optional[typing.List[str]] = None) -> str: + if is_windows(): + raise unittest.SkipTest('Cannot run this test on non-mingw/non-cygwin windows') if is_sunos(): cc = 'gcc' else: @@ -7558,13 +7562,59 @@ class CrossFileTests(BasePlatformTests): strip = '/usr/bin/ar' [properties] + needs_exe_wrapper = {} + {} [host_machine] system = 'linux' cpu_family = 'x86' cpu = 'i686' endian = 'little' - """.format(cc)) + """.format(cc, needs_exe_wrapper, + 'exe_wrapper = {}'.format(str(exe_wrapper)) + if exe_wrapper is not None else '')) + + def test_needs_exe_wrapper_true(self): + testdir = os.path.join(self.common_test_dir, '1 trivial') + with tempfile.TemporaryDirectory() as d: + p = Path(d) / 'crossfile' + with p.open('wt') as f: + f.write(self._cross_file_generator(needs_exe_wrapper=True)) + self.init(testdir, extra_args=['--cross-file=' + str(p)]) + out = self.run_target('test') + self.assertRegex(out, r'Skipped:\s*1\n') + + def test_needs_exe_wrapper_false(self): + testdir = os.path.join(self.common_test_dir, '1 trivial') + with tempfile.TemporaryDirectory() as d: + p = Path(d) / 'crossfile' + with p.open('wt') as f: + f.write(self._cross_file_generator(needs_exe_wrapper=False)) + self.init(testdir, extra_args=['--cross-file=' + str(p)]) + out = self.run_target('test') + self.assertNotRegex(out, r'Skipped:\s*1\n') + + def test_needs_exe_wrapper_true_wrapper(self): + testdir = os.path.join(self.common_test_dir, '1 trivial') + 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 + ''')) + p = Path(d) / 'crossfile' + with p.open('wt') as f: + f.write(self._cross_file_generator( + needs_exe_wrapper=True, + exe_wrapper=[str(s)])) + + self.init(testdir, extra_args=['--cross-file=' + str(p)]) + out = self.run_target('test') + self.assertNotRegex(out, r'Skipped:\s*1\n') # The test uses mocking and thus requires that the current process is the # one to run the Meson steps. If we are using an external test executable |