Merge pull request #2852 from jon-turney/warning-location

Add filename and lineno to duplicate kwargs warning
This commit is contained in:
Jussi Pakkanen 2018-01-01 02:09:45 +02:00 committed by GitHub
commit f2b33b8dcb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 21 additions and 3 deletions

View File

@ -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):

View File

@ -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):

View File

@ -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):
'''

View File

View File

View File

@ -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')

View File

@ -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')