New Custom Testing Framework
This commit is contained in:
@@ -68,7 +68,10 @@ class EnvironmentProcessor(object):
|
||||
if "clean" not in build_targets:
|
||||
install_project_env_dependencies(
|
||||
self.name,
|
||||
{"project_targets": build_targets},
|
||||
{
|
||||
"project_targets": build_targets,
|
||||
"piotest_running_name": build_vars.get("piotest_running_name"),
|
||||
},
|
||||
)
|
||||
|
||||
result = PlatformFactory.new(self.options["platform"], autoinstall=True).run(
|
||||
|
||||
@@ -216,7 +216,9 @@ def _install_project_env_libraries(project_env, options):
|
||||
|
||||
lib_deps = config.get(f"env:{project_env}", "lib_deps")
|
||||
if "__test" in options.get("project_targets", []):
|
||||
test_runner = TestRunnerFactory.new(TestSuite(project_env, "*"), config)
|
||||
test_runner = TestRunnerFactory.new(
|
||||
TestSuite(project_env, options.get("piotest_running_name", "*")), config
|
||||
)
|
||||
lib_deps.extend(test_runner.EXTRA_LIB_DEPS or [])
|
||||
|
||||
for library in lib_deps:
|
||||
|
||||
@@ -41,14 +41,24 @@ class TestRunnerFactory(object):
|
||||
module_name = f"platformio.test.runners.{test_framework}"
|
||||
runner_cls = None
|
||||
if test_framework == "custom":
|
||||
custom_runner_path = os.path.join(
|
||||
project_config.get("platformio", "test_dir"), "custom_runner.py"
|
||||
)
|
||||
test_dir = project_config.get("platformio", "test_dir")
|
||||
custom_runner_path = os.path.join(test_dir, "custom_test_runner.py")
|
||||
test_name = test_suite.test_name if test_suite.test_name != "*" else None
|
||||
while test_name:
|
||||
if os.path.isfile(
|
||||
os.path.join(test_dir, test_name, "custom_test_runner.py")
|
||||
):
|
||||
custom_runner_path = os.path.join(
|
||||
test_dir, test_name, "custom_test_runner.py"
|
||||
)
|
||||
break
|
||||
test_name = os.path.dirname(test_name) # parent dir
|
||||
|
||||
try:
|
||||
mod = load_python_module(module_name, custom_runner_path)
|
||||
except ImportError:
|
||||
except (FileNotFoundError, ImportError):
|
||||
raise UserSideException(
|
||||
"Could not find custom unit testing runner "
|
||||
"Could not find custom test runner "
|
||||
f"by this path -> {custom_runner_path}"
|
||||
)
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user