diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2020-03-12 10:55:58 -0700 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2020-03-17 10:40:39 -0700 |
commit | 9074c7f8a43e6a50ff255a9974adc20887a3001f (patch) | |
tree | 014a1e95737d4eae9aab4ffe76849519c0beca54 /run_unittests.py | |
parent | 0fa70325ed479cc4d61755dd376a8b7ce5a12db0 (diff) | |
download | meson-9074c7f8a43e6a50ff255a9974adc20887a3001f.zip meson-9074c7f8a43e6a50ff255a9974adc20887a3001f.tar.gz meson-9074c7f8a43e6a50ff255a9974adc20887a3001f.tar.bz2 |
envconfig: Make compiler and linker environment variables match
Diffstat (limited to 'run_unittests.py')
-rwxr-xr-x | run_unittests.py | 46 |
1 files changed, 30 insertions, 16 deletions
diff --git a/run_unittests.py b/run_unittests.py index ee6ec7e..2f7ad43 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -4972,14 +4972,21 @@ class WindowsTests(BasePlatformTests): def _check_ld(self, name: str, lang: str, expected: str) -> None: if not shutil.which(name): raise unittest.SkipTest('Could not find {}.'.format(name)) - envvar = mesonbuild.envconfig.BinaryTable.evarMap['{}_ld'.format(lang)] - with mock.patch.dict(os.environ, {envvar: name}): - env = get_fake_env() - try: - comp = getattr(env, 'detect_{}_compiler'.format(lang))(MachineChoice.HOST) - except EnvironmentException: - raise unittest.SkipTest('Could not find a compiler for {}'.format(lang)) - self.assertEqual(comp.linker.id, expected) + envvars = [mesonbuild.envconfig.BinaryTable.evarMap['{}_ld'.format(lang)]] + + # Also test a deprecated variable if there is one. + if envvars[0] in mesonbuild.envconfig.BinaryTable.DEPRECATION_MAP: + envvars.append( + mesonbuild.envconfig.BinaryTable.DEPRECATION_MAP[envvars[0]]) + + for envvar in envvars: + with mock.patch.dict(os.environ, {envvar: name}): + env = get_fake_env() + try: + comp = getattr(env, 'detect_{}_compiler'.format(lang))(MachineChoice.HOST) + except EnvironmentException: + raise unittest.SkipTest('Could not find a compiler for {}'.format(lang)) + self.assertEqual(comp.linker.id, expected) def test_link_environment_variable_lld_link(self): self._check_ld('lld-link', 'c', 'lld-link') @@ -6333,14 +6340,21 @@ c = ['{0}'] raise unittest.SkipTest('Solaris currently cannot override the linker.') if not shutil.which(check): raise unittest.SkipTest('Could not find {}.'.format(check)) - envvar = mesonbuild.envconfig.BinaryTable.evarMap['{}_ld'.format(lang)] - with mock.patch.dict(os.environ, {envvar: name}): - env = get_fake_env() - comp = getattr(env, 'detect_{}_compiler'.format(lang))(MachineChoice.HOST) - if lang != 'rust' and comp.use_linker_args('foo') == []: - raise unittest.SkipTest( - 'Compiler {} does not support using alternative linkers'.format(comp.id)) - self.assertEqual(comp.linker.id, expected) + envvars = [mesonbuild.envconfig.BinaryTable.evarMap['{}_ld'.format(lang)]] + + # Also test a deprecated variable if there is one. + if envvars[0] in mesonbuild.envconfig.BinaryTable.DEPRECATION_MAP: + envvars.append( + mesonbuild.envconfig.BinaryTable.DEPRECATION_MAP[envvars[0]]) + + for envvar in envvars: + with mock.patch.dict(os.environ, {envvar: name}): + env = get_fake_env() + comp = getattr(env, 'detect_{}_compiler'.format(lang))(MachineChoice.HOST) + if lang != 'rust' and comp.use_linker_args('bfd') == []: + raise unittest.SkipTest( + 'Compiler {} does not support using alternative linkers'.format(comp.id)) + self.assertEqual(comp.linker.id, expected) def test_ld_environment_variable_bfd(self): self._check_ld('ld.bfd', 'bfd', 'c', 'ld.bfd') |