modify harness framework
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
from uuid import uuid4
|
||||
|
||||
from .base import AdapterError
|
||||
from ..models import (CommandSpec, ProjectKind, ResultCheck, ResultCheckKind,
|
||||
ValidationPlan, ValidationStep)
|
||||
|
||||
|
||||
class DotnetAdapter:
|
||||
def create_plan(self, root, selection, config, tools):
|
||||
root = root.resolve()
|
||||
if not config.dotnet.test_projects:
|
||||
raise AdapterError("dotnet.testProjects must specify the product tests")
|
||||
tests = tuple(dict.fromkeys(config.dotnet.test_projects))
|
||||
targets = tuple(dict.fromkeys((selection.project_file, *tests)))
|
||||
configuration = config.dotnet.configuration
|
||||
steps = []
|
||||
for action in ("restore", "build"):
|
||||
for target in targets:
|
||||
argv = (str(tools.dotnet), action, str(target))
|
||||
# Restore and build must evaluate the same conditional references.
|
||||
if action == "restore":
|
||||
argv += (f"-p:Configuration={configuration}",)
|
||||
else:
|
||||
argv += ("-c", configuration, "--no-restore", "-warnaserror")
|
||||
steps.append(ValidationStep(CommandSpec(argv, root, f"{action}: {target.name}")))
|
||||
results = root / ".harness/test-results" / uuid4().hex
|
||||
for index, target in enumerate(tests):
|
||||
directory = results / str(index)
|
||||
argv = (str(tools.dotnet), "test", str(target), "-c", configuration,
|
||||
"--no-build", "--no-restore", "--logger", "trx",
|
||||
"--results-directory", str(directory))
|
||||
steps.append(ValidationStep(
|
||||
CommandSpec(argv, root, f"test: {target.name}"),
|
||||
(ResultCheck(ResultCheckKind.TRX_HAS_TESTS, directory),),
|
||||
))
|
||||
return ValidationPlan(ProjectKind.DOTNET, tuple(steps))
|
||||
Reference in New Issue
Block a user