aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2021-03-12 19:53:29 +0200
committerJussi Pakkanen <jpakkane@gmail.com>2021-03-12 19:53:29 +0200
commitb04272f1216d129d4e4ebe2c6cb07f98d86a962e (patch)
tree57defbe4583ec310dfed3108972839c7d7cffcd9
parent88013815633759fd499bde9e0173aaf9024604b1 (diff)
downloadmeson-b04272f1216d129d4e4ebe2c6cb07f98d86a962e.zip
meson-b04272f1216d129d4e4ebe2c6cb07f98d86a962e.tar.gz
meson-b04272f1216d129d4e4ebe2c6cb07f98d86a962e.tar.bz2
Fix run_targets running scripts from different subdirs.runsubdir
-rw-r--r--mesonbuild/interpreter.py2
-rwxr-xr-xrun_unittests.py9
-rw-r--r--test cases/common/52 run target/meson.build2
-rw-r--r--test cases/common/52 run target/subdir/textprinter.py3
4 files changed, 16 insertions, 0 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index 68744ef..d688b6a 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -4008,6 +4008,8 @@ This will become a hard error in the future.''' % kwargs['input'], location=self
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.')
diff --git a/run_unittests.py b/run_unittests.py
index 759aa96..7e7ec93 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -2385,6 +2385,15 @@ class AllPlatformTests(BasePlatformTests):
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
diff --git a/test cases/common/52 run target/meson.build b/test cases/common/52 run target/meson.build
index df0a1a5..85d30f0 100644
--- a/test cases/common/52 run target/meson.build
+++ b/test cases/common/52 run target/meson.build
@@ -103,3 +103,5 @@ custom_target('check-env-ct',
'MY_ENV': '1'},
output: 'check-env-ct',
)
+
+run_target('textprinter', command: ['subdir/textprinter.py'])
diff --git a/test cases/common/52 run target/subdir/textprinter.py b/test cases/common/52 run target/subdir/textprinter.py
new file mode 100644
index 0000000..3159c08
--- /dev/null
+++ b/test cases/common/52 run target/subdir/textprinter.py
@@ -0,0 +1,3 @@
+#!/usr/bin/env python3
+
+print('I am a script. Being run.')