summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2018-01-01 02:09:45 +0200
committerGitHub <noreply@github.com>2018-01-01 02:09:45 +0200
commitf2b33b8dcba7e8d948982cfb682e003d57e0f696 (patch)
tree9be32002857e496701a622935c6587c682944c53
parentdd3f49af0d8c94033e6db68b25c23ea9e63e9c5c (diff)
parentad5cc2ce5523d38578e9ca19179687434d050f3d (diff)
downloadmeson-f2b33b8dcba7e8d948982cfb682e003d57e0f696.tar.gz
Merge pull request #2852 from jon-turney/warning-location
Add filename and lineno to duplicate kwargs warning
-rw-r--r--mesonbuild/interpreter.py2
-rw-r--r--mesonbuild/mparser.py4
-rwxr-xr-xrun_unittests.py8
-rw-r--r--test cases/unit/20 warning location/a.c0
-rw-r--r--test cases/unit/20 warning location/b.c0
-rw-r--r--test cases/unit/20 warning location/main.c0
-rw-r--r--test cases/unit/20 warning location/meson.build6
-rw-r--r--test cases/unit/20 warning location/sub/c.c0
-rw-r--r--test cases/unit/20 warning location/sub/d.c0
-rw-r--r--test cases/unit/20 warning location/sub/meson.build4
-rw-r--r--test cases/unit/20 warning location/sub/sub.c0
11 files changed, 21 insertions, 3 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index e5238a7ea..e8fb08154 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -1935,7 +1935,7 @@ to directly access options of other subprojects.''')
@noKwargs
def func_warning(self, node, args, kwargs):
argstr = self.get_message_string_arg(node)
- mlog.warning(argstr)
+ mlog.warning('%s in file %s, line %d' % (argstr, os.path.join(node.subdir, 'meson.build'), node.lineno))
@noKwargs
def func_error(self, node, args, kwargs):
diff --git a/mesonbuild/mparser.py b/mesonbuild/mparser.py
index 0465d2436..782b7a7b1 100644
--- a/mesonbuild/mparser.py
+++ b/mesonbuild/mparser.py
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import re
+import os, re
from .mesonlib import MesonException
from . import mlog
@@ -368,7 +368,7 @@ class ArgumentNode:
def set_kwarg(self, name, value):
if name in self.kwargs:
- mlog.warning('Keyword argument "%s" defined multiple times. This will be a an error in future Meson releases.' % name)
+ mlog.warning('Keyword argument "%s" defined multiple times in file %s, line %d. This will be an error in future Meson releases.' % (name, os.path.join(self.subdir, 'meson.build'), self.lineno))
self.kwargs[name] = value
def num_args(self):
diff --git a/run_unittests.py b/run_unittests.py
index 184386cb7..84f9a0a59 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -1707,6 +1707,14 @@ int main(int argc, char **argv) {
self.init(workdir)
self.build()
+ def test_warning_location(self):
+ tdir = os.path.join(self.unit_test_dir, '20 warning location')
+ out = self.init(tdir)
+ self.assertRegex(out, r'WARNING: Keyword argument "link_with" defined multiple times in file meson.build, line 4')
+ self.assertRegex(out, r'WARNING: Keyword argument "link_with" defined multiple times in file sub' + re.escape(os.path.sep) + r'meson.build, line 3')
+ self.assertRegex(out, r'WARNING: a warning of some sort in file meson.build, line 6')
+ self.assertRegex(out, r'WARNING: subdir warning in file sub' + re.escape(os.path.sep) + r'meson.build, line 4')
+
class FailureTests(BasePlatformTests):
'''
diff --git a/test cases/unit/20 warning location/a.c b/test cases/unit/20 warning location/a.c
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/test cases/unit/20 warning location/a.c
diff --git a/test cases/unit/20 warning location/b.c b/test cases/unit/20 warning location/b.c
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/test cases/unit/20 warning location/b.c
diff --git a/test cases/unit/20 warning location/main.c b/test cases/unit/20 warning location/main.c
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/test cases/unit/20 warning location/main.c
diff --git a/test cases/unit/20 warning location/meson.build b/test cases/unit/20 warning location/meson.build
new file mode 100644
index 000000000..e26c6c9df
--- /dev/null
+++ b/test cases/unit/20 warning location/meson.build
@@ -0,0 +1,6 @@
+project('duplicate kwarg', 'c')
+a = library('liba', 'a.c')
+b = library('libb', 'b.c')
+executable('main', 'main.c', link_with: a, link_with: b)
+subdir('sub')
+warning('a warning of some sort')
diff --git a/test cases/unit/20 warning location/sub/c.c b/test cases/unit/20 warning location/sub/c.c
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/test cases/unit/20 warning location/sub/c.c
diff --git a/test cases/unit/20 warning location/sub/d.c b/test cases/unit/20 warning location/sub/d.c
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/test cases/unit/20 warning location/sub/d.c
diff --git a/test cases/unit/20 warning location/sub/meson.build b/test cases/unit/20 warning location/sub/meson.build
new file mode 100644
index 000000000..27f67783c
--- /dev/null
+++ b/test cases/unit/20 warning location/sub/meson.build
@@ -0,0 +1,4 @@
+c = library('libc', 'c.c')
+d = library('libd', 'd.c')
+executable('sub', 'sub.c', link_with: c, link_with: d)
+warning('subdir warning')
diff --git a/test cases/unit/20 warning location/sub/sub.c b/test cases/unit/20 warning location/sub/sub.c
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/test cases/unit/20 warning location/sub/sub.c