summaryrefslogtreecommitdiff
path: root/wasp/boards/simulator/conftest.py
diff options
context:
space:
mode:
authorDaniel Thompson <daniel@redfelineninja.org.uk>2020-12-26 18:07:45 (GMT)
committerDaniel Thompson <daniel@redfelineninja.org.uk>2020-12-26 18:07:45 (GMT)
commit2034340f3bc4fc97cb8d097d7e1a1d810028fb0f (patch)
tree21af07a7748af6d6fab6d4aea9363be5984eeaa3 /wasp/boards/simulator/conftest.py
parent421a32de58afb8932bdee5b3ad95ad2059bf5951 (diff)
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>
Diffstat (limited to 'wasp/boards/simulator/conftest.py')
-rw-r--r--wasp/boards/simulator/conftest.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/wasp/boards/simulator/conftest.py b/wasp/boards/simulator/conftest.py
new file mode 100644
index 0000000..ffd2344
--- /dev/null
+++ b/wasp/boards/simulator/conftest.py
@@ -0,0 +1,25 @@
+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())