unitests: dont assume cc exists or is valid

On illumos (and presumably Solaris, though I can't test) cc normally
points to Sun CC, which we don't support. So ensure that gcc is used
explicitly in that case.
pull/5911/head
Dylan Baker 6 years ago
parent 52aba19b17
commit 3a011df4df
  1. 47
      run_unittests.py

@ -48,9 +48,10 @@ import mesonbuild.modules.gnome
from mesonbuild.interpreter import Interpreter, ObjectHolder from mesonbuild.interpreter import Interpreter, ObjectHolder
from mesonbuild.ast import AstInterpreter from mesonbuild.ast import AstInterpreter
from mesonbuild.mesonlib import ( from mesonbuild.mesonlib import (
BuildDirLock, LibType, MachineChoice, PerMachine, Version, BuildDirLock, LibType, MachineChoice, PerMachine, Version, is_windows,
is_windows, is_osx, is_cygwin, is_dragonflybsd, is_openbsd, is_haiku, is_osx, is_cygwin, is_dragonflybsd, is_openbsd, is_haiku, is_sunos,
windows_proof_rmtree, python_command, version_compare, split_args, quote_arg windows_proof_rmtree, python_command, version_compare, split_args,
quote_arg
) )
from mesonbuild.environment import detect_ninja from mesonbuild.environment import detect_ninja
from mesonbuild.mesonlib import MesonException, EnvironmentException from mesonbuild.mesonlib import MesonException, EnvironmentException
@ -2955,11 +2956,15 @@ int main(int argc, char **argv) {
def test_cross_file_system_paths(self): def test_cross_file_system_paths(self):
if is_windows(): if is_windows():
raise unittest.SkipTest('system crossfile paths not defined for Windows (yet)') raise unittest.SkipTest('system crossfile paths not defined for Windows (yet)')
if is_sunos():
cc = 'gcc'
else:
cc = 'cc'
testdir = os.path.join(self.common_test_dir, '1 trivial') testdir = os.path.join(self.common_test_dir, '1 trivial')
cross_content = textwrap.dedent("""\ cross_content = textwrap.dedent("""\
[binaries] [binaries]
c = '/usr/bin/cc' c = '/usr/bin/{}'
ar = '/usr/bin/ar' ar = '/usr/bin/ar'
strip = '/usr/bin/ar' strip = '/usr/bin/ar'
@ -2970,7 +2975,7 @@ int main(int argc, char **argv) {
cpu_family = 'x86' cpu_family = 'x86'
cpu = 'i686' cpu = 'i686'
endian = 'little' endian = 'little'
""") """.format(cc))
with tempfile.TemporaryDirectory() as d: with tempfile.TemporaryDirectory() as d:
dir_ = os.path.join(d, 'meson', 'cross') dir_ = os.path.join(d, 'meson', 'cross')
@ -5154,21 +5159,23 @@ class LinuxlikeTests(BasePlatformTests):
testdir = os.path.join(self.unit_test_dir, '11 cross prog') testdir = os.path.join(self.unit_test_dir, '11 cross prog')
crossfile = tempfile.NamedTemporaryFile(mode='w') crossfile = tempfile.NamedTemporaryFile(mode='w')
print(os.path.join(testdir, 'some_cross_tool.py')) print(os.path.join(testdir, 'some_cross_tool.py'))
crossfile.write('''[binaries] crossfile.write(textwrap.dedent('''\
c = '/usr/bin/cc' [binaries]
ar = '/usr/bin/ar' c = '/usr/bin/{1}'
strip = '/usr/bin/ar' ar = '/usr/bin/ar'
sometool.py = ['{0}'] strip = '/usr/bin/ar'
someothertool.py = '{0}' sometool.py = ['{0}']
someothertool.py = '{0}'
[properties]
[properties]
[host_machine]
system = 'linux' [host_machine]
cpu_family = 'arm' system = 'linux'
cpu = 'armv7' # Not sure if correct. cpu_family = 'arm'
endian = 'little' cpu = 'armv7' # Not sure if correct.
'''.format(os.path.join(testdir, 'some_cross_tool.py'))) endian = 'little'
''').format(os.path.join(testdir, 'some_cross_tool.py'),
'gcc' if is_sunos() else 'cc'))
crossfile.flush() crossfile.flush()
self.meson_cross_file = crossfile.name self.meson_cross_file = crossfile.name
self.init(testdir) self.init(testdir)

Loading…
Cancel
Save