aboutsummaryrefslogtreecommitdiff
path: root/run_unittests.py
diff options
context:
space:
mode:
authorJon Turney <jon.turney@dronecode.org.uk>2020-02-14 02:36:04 +0000
committerJon Turney <jon.turney@dronecode.org.uk>2020-02-28 11:54:07 +0000
commit585bf2b86726373f58224f005bfb5ec6f07c2a46 (patch)
tree9f73c2164552fe67e0a895f8ca732ab191279caa /run_unittests.py
parentc8e9142917aa561106234cfb7abb5f6c7f168b80 (diff)
downloadmeson-585bf2b86726373f58224f005bfb5ec6f07c2a46.zip
meson-585bf2b86726373f58224f005bfb5ec6f07c2a46.tar.gz
meson-585bf2b86726373f58224f005bfb5ec6f07c2a46.tar.bz2
Add unit test of cwd-relative error location formatting
Diffstat (limited to 'run_unittests.py')
-rwxr-xr-xrun_unittests.py37
1 files changed, 34 insertions, 3 deletions
diff --git a/run_unittests.py b/run_unittests.py
index 0861f59..2e32b51 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -56,7 +56,7 @@ from mesonbuild.mesonlib import (
BuildDirLock, LibType, MachineChoice, PerMachine, Version, is_windows,
is_osx, is_cygwin, is_dragonflybsd, is_openbsd, is_haiku, is_sunos,
windows_proof_rmtree, python_command, version_compare, split_args,
- quote_arg
+ quote_arg, relpath
)
from mesonbuild.environment import detect_ninja
from mesonbuild.mesonlib import MesonException, EnvironmentException
@@ -1512,7 +1512,8 @@ class BasePlatformTests(unittest.TestCase):
extra_args=None,
default_args=True,
inprocess=False,
- override_envvars=None):
+ override_envvars=None,
+ workdir=None):
self.assertPathExists(srcdir)
if extra_args is None:
extra_args = []
@@ -1553,7 +1554,7 @@ class BasePlatformTests(unittest.TestCase):
mesonbuild.mlog.log_file = None
else:
try:
- out = self._run(self.setup_command + args + extra_args, override_envvars=override_envvars)
+ out = self._run(self.setup_command + args + extra_args, override_envvars=override_envvars, workdir=workdir)
except unittest.SkipTest:
raise unittest.SkipTest('Project requested skipping: ' + srcdir)
except Exception:
@@ -3171,6 +3172,36 @@ int main(int argc, char **argv) {
]:
self.assertRegex(out, re.escape(expected))
+ def test_error_location_path(self):
+ '''Test locations in meson errors contain correct paths'''
+ # this list contains errors from all the different steps in the
+ # lexer/parser/interpreter we have tests for.
+ for (t, f) in [
+ ('10 out of bounds', 'meson.build'),
+ ('18 wrong plusassign', 'meson.build'),
+ ('61 bad option argument', 'meson_options.txt'),
+ ('100 subdir parse error', os.path.join('subdir', 'meson.build')),
+ ('101 invalid option file', 'meson_options.txt'),
+ ]:
+ tdir = os.path.join(self.src_root, 'test cases', 'failing', t)
+
+ for wd in [
+ self.src_root,
+ self.builddir,
+ os.getcwd(),
+ ]:
+ try:
+ self.init(tdir, workdir=wd)
+ except subprocess.CalledProcessError as e:
+ expected = os.path.join('test cases', 'failing', t, f)
+ relwd = relpath(self.src_root, wd)
+ if relwd != '.':
+ expected = os.path.join(relwd, expected)
+ expected = '\n' + expected + ':'
+ self.assertIn(expected, e.output)
+ else:
+ self.fail('configure unexpectedly succeeded')
+
def test_permitted_method_kwargs(self):
tdir = os.path.join(self.unit_test_dir, '25 non-permitted kwargs')
out = self.init(tdir)