diff options
Diffstat (limited to 'unittests')
-rw-r--r-- | unittests/allplatformstests.py | 2 | ||||
-rw-r--r-- | unittests/linuxcrosstests.py | 8 | ||||
-rw-r--r-- | unittests/machinefiletests.py | 9 |
3 files changed, 18 insertions, 1 deletions
diff --git a/unittests/allplatformstests.py b/unittests/allplatformstests.py index 60ff12314..6f722c76d 100644 --- a/unittests/allplatformstests.py +++ b/unittests/allplatformstests.py @@ -3597,6 +3597,8 @@ class AllPlatformTests(BasePlatformTests): machinefile = os.path.join(self.builddir, 'machine.txt') with open(machinefile, 'w', encoding='utf-8') as f: f.write(textwrap.dedent(''' + [binaries] + c = 'cc' [properties] c_stdlib = 'mylibc' ''')) diff --git a/unittests/linuxcrosstests.py b/unittests/linuxcrosstests.py index 16f7c2454..0c0355a26 100644 --- a/unittests/linuxcrosstests.py +++ b/unittests/linuxcrosstests.py @@ -125,6 +125,14 @@ class LinuxCrossArmTests(BaseLinuxCrossTests): self.run_tests() self.assertPathExists(stamp_file) + def test_missing_compilers(self): + ''' + Requesting a compiler that is not in the cross file must be an error. + ''' + testdir = os.path.join(self.common_test_dir, '1 trivial') + self.meson_cross_files = [os.path.join(self.src_root, 'cross', 'noexes.txt')] + with self.assertRaises(subprocess.CalledProcessError, msg='compiler binary not defined in a cross file'): + self.init(testdir) def should_run_cross_mingw_tests(): return shutil.which('x86_64-w64-mingw32-gcc') and not (is_windows() or is_cygwin()) diff --git a/unittests/machinefiletests.py b/unittests/machinefiletests.py index 0a756b572..a124b64a7 100644 --- a/unittests/machinefiletests.py +++ b/unittests/machinefiletests.py @@ -740,7 +740,7 @@ class CrossFileTests(BasePlatformTests): self.init(testdir, extra_args=['--cross-file=' + name], inprocess=True) self.wipe() - def helper_create_cross_file(self, values): + def helper_create_cross_file(self, values, *, add_fake_compilers=True): """Create a config file as a temporary file. values should be a nested dictionary structure of {section: {key: @@ -748,6 +748,13 @@ class CrossFileTests(BasePlatformTests): """ filename = os.path.join(self.builddir, f'generated{self.current_config}.config') self.current_config += 1 + if add_fake_compilers: + if is_windows() and shutil.which('cl'): + base = {'binaries': {'c': 'cl', 'cpp': 'cl'}} + else: + base = {'binaries': {'c': 'cc', 'cpp': 'c++'}} + base.update(values) + values = base with open(filename, 'wt', encoding='utf-8') as f: for section, entries in values.items(): f.write(f'[{section}]\n') |