aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2017-12-28 10:14:30 +0530
committerJussi Pakkanen <jpakkane@gmail.com>2017-12-30 18:02:28 +0200
commitae0f4ef055de22996808714d3c42017605a18b3a (patch)
treeda371623071dc1ee1578c808536aea04d627e9fa
parent6f3e2a0a0753ad0a4fc84a74fdc6209f436d4371 (diff)
downloadmeson-ae0f4ef055de22996808714d3c42017605a18b3a.zip
meson-ae0f4ef055de22996808714d3c42017605a18b3a.tar.gz
meson-ae0f4ef055de22996808714d3c42017605a18b3a.tar.bz2
compilers: Fix error when objc/objc++ compilers are not found
Earlier it would exit with a traceback: UnboundLocalError: local variable 'out' referenced before assignment
-rw-r--r--mesonbuild/environment.py2
-rwxr-xr-xrun_unittests.py19
2 files changed, 19 insertions, 2 deletions
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py
index 858d31d..0c9a2f3 100644
--- a/mesonbuild/environment.py
+++ b/mesonbuild/environment.py
@@ -608,6 +608,7 @@ class Environment:
p, out, err = Popen_safe(compiler + arg)
except OSError as e:
popen_exceptions[' '.join(compiler + arg)] = e
+ continue
version = search_version(out)
if 'Free Software Foundation' in out:
defines = self.get_gnu_compiler_defines(compiler)
@@ -634,6 +635,7 @@ class Environment:
p, out, err = Popen_safe(compiler + arg)
except OSError as e:
popen_exceptions[' '.join(compiler + arg)] = e
+ continue
version = search_version(out)
if 'Free Software Foundation' in out:
defines = self.get_gnu_compiler_defines(compiler)
diff --git a/run_unittests.py b/run_unittests.py
index cf229da..61ee770 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -37,7 +37,7 @@ from mesonbuild.interpreter import ObjectHolder
from mesonbuild.mesonlib import is_linux, is_windows, is_osx, is_cygwin, windows_proof_rmtree
from mesonbuild.mesonlib import python_command, meson_command, version_compare
from mesonbuild.environment import Environment
-from mesonbuild.dependencies import DependencyException
+from mesonbuild.mesonlib import MesonException, EnvironmentException
from mesonbuild.dependencies import PkgConfigDependency, ExternalProgram
from run_tests import exe_suffix, get_fake_options
@@ -1744,7 +1744,7 @@ class FailureTests(BasePlatformTests):
f.write(contents)
# Force tracebacks so we can detect them properly
os.environ['MESON_FORCE_BACKTRACE'] = '1'
- with self.assertRaisesRegex(DependencyException, match, msg=contents):
+ with self.assertRaisesRegex(MesonException, match, msg=contents):
# Must run in-process or we'll get a generic CalledProcessError
self.init(self.srcdir, extra_args=extra_args, inprocess=True)
@@ -1865,6 +1865,21 @@ class FailureTests(BasePlatformTests):
out,
r'In subproject one: Unknown command line options: "one:two"')
+ def test_objc_cpp_detection(self):
+ '''
+ Test that when we can't detect objc or objcpp, we fail gracefully.
+ '''
+ env = Environment('', self.builddir, self.meson_command,
+ get_fake_options(self.prefix), [])
+ try:
+ objc = env.detect_objc_compiler(False)
+ objcpp = env.detect_objcpp_compiler(False)
+ except EnvironmentException:
+ code = "add_languages('objc')\nadd_languages('objcpp')"
+ self.assertMesonRaises(code, "Unknown compiler")
+ return
+ raise unittest.SkipTest("objc and objcpp found, can't test detection failure")
+
class WindowsTests(BasePlatformTests):
'''