Currently the unittests are not runnable with pytest or unittest without going through the run_unittests.py wrapper. This has that downside that the common "pytest ..." fails and integration with things like VSCode fails too. To work around that we set everything that is needed to run the tests in __init__.py and run_unittests is only one more variant to invoke them by providing different defaults and settings. To make sure that pytest/unittest discover and run_unittests don't diverge implement an automatic test discovery in run_unittests to avoid hardcoding the tests to run there. There shouldn't be any functional changes.pull/13423/head
parent
8e89a38737
commit
626811d00a
2 changed files with 49 additions and 40 deletions
@ -0,0 +1,23 @@ |
||||
import os |
||||
|
||||
import mesonbuild.compilers |
||||
from mesonbuild.mesonlib import setup_vsenv |
||||
|
||||
def unset_envs(): |
||||
# For unit tests we must fully control all command lines |
||||
# so that there are no unexpected changes coming from the |
||||
# environment, for example when doing a package build. |
||||
varnames = ['CPPFLAGS', 'LDFLAGS'] + list(mesonbuild.compilers.compilers.CFLAGS_MAPPING.values()) |
||||
for v in varnames: |
||||
if v in os.environ: |
||||
del os.environ[v] |
||||
|
||||
def set_envs(): |
||||
os.environ.setdefault('MESON_UNIT_TEST_BACKEND', 'ninja') |
||||
|
||||
def init(): |
||||
setup_vsenv() |
||||
unset_envs() |
||||
set_envs() |
||||
|
||||
init() |
Loading…
Reference in new issue