Skip to content

Commit

Permalink
Fix run_targets running scripts from different subdirs.
Browse files Browse the repository at this point in the history
  • Loading branch information
jpakkane committed Mar 14, 2021
1 parent 1f3bf0f commit be86199
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions mesonbuild/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4008,6 +4008,8 @@ def func_run_target(self, node, args, kwargs):
if isinstance(i, dependencies.ExternalProgram) and not i.found():
raise InterpreterException(f'Tried to use non-existing executable {i.name!r}')
cleaned_args.append(i)
if isinstance(cleaned_args[0], str):
cleaned_args[0] = self.func_find_program(node, cleaned_args[0], {})
name = args[0]
if not isinstance(name, str):
raise InterpreterException('First argument must be a string.')
Expand Down
9 changes: 9 additions & 0 deletions run_unittests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2385,6 +2385,15 @@ def test_run_target_files_path(self):
self.run_target('check-env')
self.run_target('check-env-ct')

def test_run_target_subdir(self):
'''
Test that run_targets are run from the correct directory
https://github.com/mesonbuild/meson/issues/957
'''
testdir = os.path.join(self.common_test_dir, '52 run target')
self.init(testdir)
self.run_target('textprinter')

def test_install_introspection(self):
'''
Tests that the Meson introspection API exposes install filenames correctly
Expand Down
2 changes: 2 additions & 0 deletions test cases/common/52 run target/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,5 @@ custom_target('check-env-ct',
'MY_ENV': '1'},
output: 'check-env-ct',
)

run_target('textprinter', command: ['subdir/textprinter.py'])
3 changes: 3 additions & 0 deletions test cases/common/52 run target/subdir/textprinter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env python3

print('I am a script. Being run.')

0 comments on commit be86199

Please sign in to comment.