diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2018-01-01 02:09:45 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-01 02:09:45 +0200 |
commit | f2b33b8dcba7e8d948982cfb682e003d57e0f696 (patch) | |
tree | 9be32002857e496701a622935c6587c682944c53 | |
parent | dd3f49af0d8c94033e6db68b25c23ea9e63e9c5c (diff) | |
parent | ad5cc2ce5523d38578e9ca19179687434d050f3d (diff) | |
download | meson-f2b33b8dcba7e8d948982cfb682e003d57e0f696.zip meson-f2b33b8dcba7e8d948982cfb682e003d57e0f696.tar.gz meson-f2b33b8dcba7e8d948982cfb682e003d57e0f696.tar.bz2 |
Merge pull request #2852 from jon-turney/warning-location
Add filename and lineno to duplicate kwargs warning
-rw-r--r-- | mesonbuild/interpreter.py | 2 | ||||
-rw-r--r-- | mesonbuild/mparser.py | 4 | ||||
-rwxr-xr-x | run_unittests.py | 8 | ||||
-rw-r--r-- | test cases/unit/20 warning location/a.c | 0 | ||||
-rw-r--r-- | test cases/unit/20 warning location/b.c | 0 | ||||
-rw-r--r-- | test cases/unit/20 warning location/main.c | 0 | ||||
-rw-r--r-- | test cases/unit/20 warning location/meson.build | 6 | ||||
-rw-r--r-- | test cases/unit/20 warning location/sub/c.c | 0 | ||||
-rw-r--r-- | test cases/unit/20 warning location/sub/d.c | 0 | ||||
-rw-r--r-- | test cases/unit/20 warning location/sub/meson.build | 4 | ||||
-rw-r--r-- | test cases/unit/20 warning location/sub/sub.c | 0 |
11 files changed, 21 insertions, 3 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index e5238a7..e8fb081 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 0465d24..782b7a7 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 184386c..84f9a0a 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 0000000..e69de29 --- /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 0000000..e69de29 --- /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 0000000..e69de29 --- /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 0000000..e26c6c9 --- /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 0000000..e69de29 --- /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 0000000..e69de29 --- /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 0000000..27f6778 --- /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 0000000..e69de29 --- /dev/null +++ b/test cases/unit/20 warning location/sub/sub.c |