summaryrefslogtreecommitdiff
path: root/unittests/internaltests.py
diff options
context:
space:
mode:
authorMads Andreasen <github@andreasen.cc>2024-04-07 16:12:50 +0200
committerJussi Pakkanen <jpakkane@gmail.com>2024-07-10 21:47:46 +0300
commit50704bced3775e9bc5b34f4295e282bfac7253f0 (patch)
tree01a0c0294f1f58e4efffee0c7e5abad35c638c6e /unittests/internaltests.py
parentf01ae52bc224e46661e0ee4404c949e4e27773a8 (diff)
downloadmeson-50704bced3775e9bc5b34f4295e282bfac7253f0.tar.gz
Replace exe_exists function with shutil.which()
The documentation for subprocess.run at https://docs.python.org/3/library/subprocess.html#popen-constructor has a warning, pointing to using shutil.which() instead of subprocess.run for detecting if exe files exists on the path. shutil.which() is used in many places already.
Diffstat (limited to 'unittests/internaltests.py')
-rw-r--r--unittests/internaltests.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/unittests/internaltests.py b/unittests/internaltests.py
index fe9f0d4f5..2c3bcfda3 100644
--- a/unittests/internaltests.py
+++ b/unittests/internaltests.py
@@ -39,6 +39,7 @@ from mesonbuild.interpreter.type_checking import in_set_validator, NoneType
from mesonbuild.dependencies.pkgconfig import PkgConfigDependency, PkgConfigInterface, PkgConfigCLI
from mesonbuild.programs import ExternalProgram
import mesonbuild.modules.pkgconfig
+from mesonbuild import utils
from run_tests import (
@@ -813,6 +814,10 @@ class InternalTests(unittest.TestCase):
self.assertTrue(vctools_ver.startswith(toolset_ver),
msg=f'{vctools_ver!r} does not start with {toolset_ver!r}')
+ def test_exe_exists(self):
+ self.assertTrue(utils.universal.exe_exists('python3'))
+ self.assertFalse(utils.universal.exe_exists('command_that_does_not_exist'))
+
def test_split_args(self):
split_args = mesonbuild.mesonlib.split_args
join_args = mesonbuild.mesonlib.join_args