aboutsummaryrefslogtreecommitdiff
path: root/run_tests.py
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2022-03-01 19:00:31 -0500
committerEli Schwartz <eschwartz@archlinux.org>2022-03-01 21:42:52 -0500
commita6e08e8fa7052c776989bf9410b87bf4d1f2ad49 (patch)
tree9ca2fb4bbb78b058c7d1ed925eef0b95c86b3554 /run_tests.py
parent530338782cce2f3380011c5f3e34050edf4e9243 (diff)
downloadmeson-a6e08e8fa7052c776989bf9410b87bf4d1f2ad49.zip
meson-a6e08e8fa7052c776989bf9410b87bf4d1f2ad49.tar.gz
meson-a6e08e8fa7052c776989bf9410b87bf4d1f2ad49.tar.bz2
use a more sane check instead of run_custom_lint
Unfortunately, checking for strings without context is exceedingly prone to false positives, while missing anything that indirectly opens a file. Python 3.10 has a feature to warn about this though -- and it uses a runtime check which runs at the same time that the code fails to open files in the broken Windows locale. Set this up automatically when running the testsuite. Sadly, Python's builtin feature to change the warning level, e.g. by setting EncodingWarning to error at startup, is utterly broken if you want to limit it to only certain modules. This is tracked in order to be more efficiently ignored at https://bugs.python.org/issue34624 and https://github.com/python/cpython/pull/9358 It is also very trigger happy and passing stuff around via environment variable either messes with the testsuite, or with thirdparty programs which are implemented in python *such as lots of gnome*, or perhaps both. Instead, add runtime code to meson itself, to add a hidden "feature". In the application source code, running the 'warnings' module, you can actually get the expected behavior that $PYTHONWARNINGS doesn't have. So check for a magic testsuite variable every time meson starts up, and if it does, then go ahead and initialize a warnings filter that makes EncodingWarning fatal, but *only* when triggered via Meson and not arbitrary subprocess scripts.
Diffstat (limited to 'run_tests.py')
-rwxr-xr-xrun_tests.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/run_tests.py b/run_tests.py
index 6867ce6..dc7a8f9 100755
--- a/run_tests.py
+++ b/run_tests.py
@@ -68,6 +68,14 @@ if NINJA_CMD is not None:
else:
raise RuntimeError('Could not find Ninja v1.7 or newer')
+# Emulate running meson with -X utf8 by making sure all open() calls have a
+# sane encoding. This should be a python default, but PEP 540 considered it not
+# backwards compatible. Instead, much line noise in diffs to update this, and in
+# python 3.10 we can also make it a warning when absent.
+os.environ['PYTHONWARNDEFAULTENCODING'] = '1'
+# work around https://bugs.python.org/issue34624
+os.environ['MESON_RUNNING_IN_PROJECT_TESTS'] = '1'
+
def guess_backend(backend_str: str, msbuild_exe: str) -> T.Tuple['Backend', T.List[str]]:
# Auto-detect backend if unspecified
backend_flags = []