Skip to content

Commit

Permalink
Fix test() accepting configure files for exe
Browse files Browse the repository at this point in the history
  • Loading branch information
TingPing committed Jul 31, 2017
1 parent 7f307fd commit fab99d0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
10 changes: 7 additions & 3 deletions mesonbuild/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2303,8 +2303,12 @@ def add_test(self, node, args, kwargs, is_base_test):
raise InterpreterException('Incorrect number of arguments')
if not isinstance(args[0], str):
raise InterpreterException('First argument of test must be a string.')
if not isinstance(args[1], (ExecutableHolder, JarHolder, ExternalProgramHolder)):
raise InterpreterException('Second argument must be executable.')
exe = args[1]
if not isinstance(exe, (ExecutableHolder, JarHolder, ExternalProgramHolder)):
if isinstance(exe, mesonlib.File):
exe = self.func_find_program(node, (args[1], ), {})
else:
raise InterpreterException('Second argument must be executable.')
par = kwargs.get('is_parallel', True)
if not isinstance(par, bool):
raise InterpreterException('Keyword argument is_parallel must be a boolean.')
Expand Down Expand Up @@ -2338,7 +2342,7 @@ def add_test(self, node, args, kwargs, is_base_test):
suite.append(self.subproject.replace(' ', '_').replace(':', '_') + s)
else:
suite.append(self.build.project_name.replace(' ', '_').replace(':', '_') + s)
t = Test(args[0], suite, args[1].held_object, par, cmd_args, env, should_fail, timeout, workdir)
t = Test(args[0], suite, exe.held_object, par, cmd_args, env, should_fail, timeout, workdir)
if is_base_test:
self.build.tests.append(t)
mlog.debug('Adding test "', mlog.bold(args[0]), '".', sep='')
Expand Down
9 changes: 9 additions & 0 deletions test cases/common/157 configure file in test/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
project('conf file in test')

test_file = configure_file(
input: 'test.py.in',
output: 'test.py',
configuration: configuration_data()
)

test('configure-file', test_file)
4 changes: 4 additions & 0 deletions test cases/common/157 configure file in test/test.py.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env python3

import sys
sys.exit(0)

0 comments on commit fab99d0

Please sign in to comment.