aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2023-03-01 23:09:48 -0500
committerEli Schwartz <eschwartz@archlinux.org>2023-03-01 23:36:31 -0500
commit314382d6ff06d1fb59118492cbd5a65fd3c58e5c (patch)
treeb613b55db0811e2a3755e0290606690b7c508ced
parent878c1604e6348f98602bbdd16d92fc63ed15ebea (diff)
downloadmeson-314382d6ff06d1fb59118492cbd5a65fd3c58e5c.zip
meson-314382d6ff06d1fb59118492cbd5a65fd3c58e5c.tar.gz
meson-314382d6ff06d1fb59118492cbd5a65fd3c58e5c.tar.bz2
handle meson_version after parsing but before invalid project() kwargs
If we add new kwargs to a function invoked on the first line, we also need to validate the meson_version before erroring out due to unknown kwargs. Even if the AST was successfully built. Amusingly, we also get to improve the error message a bit. By passing the AST node instead of an interpreter node, we get not just line numbers, but also column offsets of the issueful meson_version. That broke the stdout of another failing test; adapt it.
-rw-r--r--mesonbuild/interpreterbase/interpreterbase.py1
-rw-r--r--test cases/failing/131 invalid project function/meson.build1
-rw-r--r--test cases/failing/131 invalid project function/test.json9
-rw-r--r--test cases/failing/20 version/test.json2
4 files changed, 12 insertions, 1 deletions
diff --git a/mesonbuild/interpreterbase/interpreterbase.py b/mesonbuild/interpreterbase/interpreterbase.py
index 666045f..61b3f90 100644
--- a/mesonbuild/interpreterbase/interpreterbase.py
+++ b/mesonbuild/interpreterbase/interpreterbase.py
@@ -117,6 +117,7 @@ class InterpreterBase:
assert isinstance(code, str)
try:
self.ast = mparser.Parser(code, mesonfile).parse()
+ self.handle_meson_version_from_ast()
except mparser.ParseException as me:
me.file = mesonfile
# try to detect parser errors from new syntax added by future
diff --git a/test cases/failing/131 invalid project function/meson.build b/test cases/failing/131 invalid project function/meson.build
new file mode 100644
index 0000000..0032c9c
--- /dev/null
+++ b/test cases/failing/131 invalid project function/meson.build
@@ -0,0 +1 @@
+project('invalid project function with bad kwargs', meson_version: '0.1.0', unknown_kwarg: 'val')
diff --git a/test cases/failing/131 invalid project function/test.json b/test cases/failing/131 invalid project function/test.json
new file mode 100644
index 0000000..429fa18
--- /dev/null
+++ b/test cases/failing/131 invalid project function/test.json
@@ -0,0 +1,9 @@
+{
+ "stdout": [
+ {
+ "match": "re",
+ "line": "test cases/failing/131 invalid project function/meson.build:1:67: ERROR: Meson version is [0-9.]+ but project requires 0.1.0"
+ }
+ ]
+}
+
diff --git a/test cases/failing/20 version/test.json b/test cases/failing/20 version/test.json
index f330624..565fbf2 100644
--- a/test cases/failing/20 version/test.json
+++ b/test cases/failing/20 version/test.json
@@ -2,7 +2,7 @@
"stdout": [
{
"match": "re",
- "line": "test cases/failing/20 version/meson\\.build:1:0: ERROR: Meson version is .* but project requires >100\\.0\\.0"
+ "line": "test cases/failing/20 version/meson\\.build:1:44: ERROR: Meson version is .* but project requires >100\\.0\\.0"
}
]
}