summaryrefslogtreecommitdiff
path: root/test cases
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2022-05-05 23:39:34 -0400
committerXavier Claessens <xclaesse@gmail.com>2023-02-24 20:45:00 -0500
commitcf07596cf6bc280dac0afff505147ca626c79453 (patch)
treeef7a4ab1e652bca9131f5b53eedcc056b86aa6e1 /test cases
parent9f05d45b7084866f0b306f4685a118e5fea138af (diff)
downloadmeson-cf07596cf6bc280dac0afff505147ca626c79453.tar.gz
test cases: use best practices method to find the python3 program
We do not need the python module's find_installation() for this, as this does various things to set up building and installing python modules (pure python and C-API). This functionality is already tested in the python tests. Elsewhere, when we just need an interpreter capable of running python scripts in order to guarantee a useful scripting language for custom commands, it suffices to use find_program(), which does not run an introspection script or do module imports, and is thus faster and a bit cleaner. Either way, both methods are guaranteed to find the python3 interpreter, deferring to mesonlib.python_command for that guarantee. test "71 summary" can sometimes return the python command with the ".exe" part all uppercased for mysterious Windows reasons. Smooth this over with ExternalProgram.
Diffstat (limited to 'test cases')
-rw-r--r--test cases/common/257 generated header dep/meson.build2
-rw-r--r--test cases/common/44 pkgconfig-gen/meson.build2
-rw-r--r--test cases/failing/115 run_target in test/meson.build4
-rw-r--r--test cases/failing/116 run_target in add_install_script/meson.build4
-rw-r--r--test cases/java/8 codegen custom target/com/mesonbuild/meson.build2
-rw-r--r--test cases/unit/64 alias target/meson.build2
-rw-r--r--test cases/unit/70 cross test passed/meson.build2
-rw-r--r--test cases/unit/71 summary/meson.build2
-rw-r--r--test cases/unit/71 summary/meson_options.txt1
-rw-r--r--test cases/unit/73 dep files/meson.build2
-rw-r--r--test cases/unit/99 custom target name/meson.build2
-rw-r--r--test cases/windows/13 test argument extra paths/test/meson.build2
12 files changed, 14 insertions, 13 deletions
diff --git a/test cases/common/257 generated header dep/meson.build b/test cases/common/257 generated header dep/meson.build
index 195d082ac..82db3b228 100644
--- a/test cases/common/257 generated header dep/meson.build
+++ b/test cases/common/257 generated header dep/meson.build
@@ -8,7 +8,7 @@ project('generated header dep', 'c')
# dependency on the header file. This happened in GLib:
# https://gitlab.gnome.org/GNOME/glib/-/merge_requests/2917.
-python = import('python').find_installation()
+python = find_program('python3')
header = custom_target(
output: 'foo.h',
capture: true,
diff --git a/test cases/common/44 pkgconfig-gen/meson.build b/test cases/common/44 pkgconfig-gen/meson.build
index 12a110e25..e093e6f87 100644
--- a/test cases/common/44 pkgconfig-gen/meson.build
+++ b/test cases/common/44 pkgconfig-gen/meson.build
@@ -18,7 +18,7 @@ if v.version_compare('<0.29')
error('MESON_SKIP_TEST: pkg-config version \'' + v + '\' too old')
endif
-python = import('python').find_installation()
+python = find_program('python3')
fs = import('fs')
pkgg = import('pkgconfig')
diff --git a/test cases/failing/115 run_target in test/meson.build b/test cases/failing/115 run_target in test/meson.build
index 1d448ecc5..117009e3f 100644
--- a/test cases/failing/115 run_target in test/meson.build
+++ b/test cases/failing/115 run_target in test/meson.build
@@ -1,7 +1,7 @@
project('trivial test', 'c')
-py_inst = import('python').find_installation()
+python = find_program('python3')
exe = executable('trivialprog', 'trivial.c')
-runt = run_target('invalid', command: [py_inst, '--version'])
+runt = run_target('invalid', command: [python, '--version'])
test('runtest', exe, args: runt)
diff --git a/test cases/failing/116 run_target in add_install_script/meson.build b/test cases/failing/116 run_target in add_install_script/meson.build
index f8ae3a1c4..d3634bfb5 100644
--- a/test cases/failing/116 run_target in add_install_script/meson.build
+++ b/test cases/failing/116 run_target in add_install_script/meson.build
@@ -1,7 +1,7 @@
project('trivial test', 'c')
-py_inst = import('python').find_installation()
+python = find_program('python3')
exe = executable('trivialprog', 'trivial.c')
-runt = run_target('invalid', command: [py_inst, '--version'])
+runt = run_target('invalid', command: [python, '--version'])
meson.add_install_script(exe, runt)
diff --git a/test cases/java/8 codegen custom target/com/mesonbuild/meson.build b/test cases/java/8 codegen custom target/com/mesonbuild/meson.build
index 030994154..5188f0ab2 100644
--- a/test cases/java/8 codegen custom target/com/mesonbuild/meson.build
+++ b/test cases/java/8 codegen custom target/com/mesonbuild/meson.build
@@ -1,4 +1,4 @@
-python = import('python').find_installation('python3')
+python = find_program('python3')
config_file = custom_target('confgen',
input : 'Config.java.in',
diff --git a/test cases/unit/64 alias target/meson.build b/test cases/unit/64 alias target/meson.build
index bcd4005f4..197897b5f 100644
--- a/test cases/unit/64 alias target/meson.build
+++ b/test cases/unit/64 alias target/meson.build
@@ -1,6 +1,6 @@
project('alias target', 'c')
-python3 = import('python').find_installation()
+python3 = find_program('python3')
exe_target = executable('prog', 'main.c',
build_by_default : false)
diff --git a/test cases/unit/70 cross test passed/meson.build b/test cases/unit/70 cross test passed/meson.build
index 4deb74baf..3a09a7771 100644
--- a/test cases/unit/70 cross test passed/meson.build
+++ b/test cases/unit/70 cross test passed/meson.build
@@ -6,7 +6,7 @@ project(
e = executable('exec', 'src/main.c')
-py = import('python').find_installation()
+py = find_program('python3')
test('root', e)
test('main', py, args : [meson.current_source_dir() / 'script.py', e])
diff --git a/test cases/unit/71 summary/meson.build b/test cases/unit/71 summary/meson.build
index ce97fb376..76fc545f4 100644
--- a/test cases/unit/71 summary/meson.build
+++ b/test cases/unit/71 summary/meson.build
@@ -11,7 +11,7 @@ summary({'Some boolean': false,
'enabled_opt': get_option('enabled_opt'),
}, section: 'Configuration')
summary({'missing prog': find_program('xyzzy', required: false),
- 'existing prog': import('python').find_installation(),
+ 'existing prog': find_program(get_option('python')).full_path(),
'missing dep': dependency('', required: false),
'external dep': dependency('zlib', required: false),
'internal dep': declare_dependency(),
diff --git a/test cases/unit/71 summary/meson_options.txt b/test cases/unit/71 summary/meson_options.txt
index 281c3b672..cf3f32c90 100644
--- a/test cases/unit/71 summary/meson_options.txt
+++ b/test cases/unit/71 summary/meson_options.txt
@@ -1 +1,2 @@
option('enabled_opt', type: 'feature', value: 'auto')
+option('python', type: 'string')
diff --git a/test cases/unit/73 dep files/meson.build b/test cases/unit/73 dep files/meson.build
index 4829f563f..af7f6e47b 100644
--- a/test cases/unit/73 dep files/meson.build
+++ b/test cases/unit/73 dep files/meson.build
@@ -1,6 +1,6 @@
project('test', 'c')
-python = import('python').find_installation()
+python = find_program('python3')
lib = library('foo', 'foo.c')
diff --git a/test cases/unit/99 custom target name/meson.build b/test cases/unit/99 custom target name/meson.build
index 8d148a88d..82876149f 100644
--- a/test cases/unit/99 custom target name/meson.build
+++ b/test cases/unit/99 custom target name/meson.build
@@ -1,6 +1,6 @@
project('custom target name', 'c')
-python = import('python').find_installation()
+python = find_program('python3')
# Name argument is optional and should default to 'file.txt'
custom_target(
diff --git a/test cases/windows/13 test argument extra paths/test/meson.build b/test cases/windows/13 test argument extra paths/test/meson.build
index 2e608be5d..4daccaea6 100644
--- a/test cases/windows/13 test argument extra paths/test/meson.build
+++ b/test cases/windows/13 test argument extra paths/test/meson.build
@@ -1,3 +1,3 @@
-python3 = import('python').find_installation('')
+python3 = find_program('python3')
test('run_exe', python3, args: [files('test_run_exe.py')[0], barexe])