wasp-os/wasp/boards/simulator/conftest.py
Daniel Thompson 2034340f3b tests: Auto-discover applications and try to switch to them
Currently `make check` doesn't test any not-default applications.
Fix this by automatically discovering constructors and ensure that the
application can be started and stopped without generating an exception.

Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
2020-12-26 18:07:45 +00:00

26 lines
741 B
Python

import glob
import importlib
import inspect
import pytest
def discover_app_constructors():
apps = []
globs = glob.glob('wasp/apps/*.py')
names = [ g[5:-3].replace('/', '.') for g in globs ]
modules = [ importlib.import_module(n) for n in names ]
for m in modules:
for sym in m.__dict__.keys():
if len(sym) > 3 and sym[-3:] == 'App':
constructor = m.__dict__[sym]
sig = inspect.signature(constructor)
if len(sig.parameters) == 0:
apps.append(constructor)
return apps
def pytest_generate_tests(metafunc):
if 'constructor' in metafunc.fixturenames:
metafunc.parametrize('constructor', discover_app_constructors())