Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from pathlib import Path
from subprocess import check_call

import pytest

NETCORE_VERSION = "net10.0"


@pytest.fixture(scope="session")
def example_netstandard(tmp_path_factory: pytest.TempPathFactory) -> Path:
return build_example(tmp_path_factory, "netstandard2.0")


@pytest.fixture(scope="session")
def example_netcore(tmp_path_factory: pytest.TempPathFactory) -> Path:
return build_example(tmp_path_factory, NETCORE_VERSION)


def build_example(tmp_path_factory: pytest.TempPathFactory, framework: str) -> Path:
out = tmp_path_factory.mktemp(f"example-{framework}")
proj_path = Path(__file__).parent.parent / "example" / "example.csproj"

_ = check_call(["dotnet", "build", str(proj_path), "-o", str(out), "-f", framework])

return out
31 changes: 7 additions & 24 deletions tests/test_common.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,9 @@
import shutil
import sys
from pathlib import Path
from subprocess import check_call

import pytest

NETCORE_VERSION = "net10.0"


@pytest.fixture(scope="session")
def example_netstandard(tmp_path_factory: pytest.TempPathFactory) -> Path:
return build_example(tmp_path_factory, "netstandard2.0")


@pytest.fixture(scope="session")
def example_netcore(tmp_path_factory: pytest.TempPathFactory) -> Path:
return build_example(tmp_path_factory, NETCORE_VERSION)


def build_example(tmp_path_factory: pytest.TempPathFactory, framework: str) -> Path:
out = tmp_path_factory.mktemp(f"example-{framework}")
proj_path = Path(__file__).parent.parent / "example" / "example.csproj"

_ = check_call(["dotnet", "build", str(proj_path), "-o", str(out), "-f", framework])

return out


def test_mono(example_netstandard: Path):
from clr_loader import get_mono
Expand Down Expand Up @@ -112,7 +90,7 @@ def test_coreclr_properties(example_netcore: Path):
run_in_subprocess(
_do_test_coreclr_autogenerated_runtimeconfig,
example_netcore,
properties=dict(APP_CONTEXT_BASE_DIRECTORY=str(example_netcore)),
APP_CONTEXT_BASE_DIRECTORY=str(example_netcore),
)


Expand Down Expand Up @@ -177,4 +155,9 @@ def run_in_subprocess(func, *args, **kwargs):
p = get_context("spawn").Process(target=func, args=args, kwargs=kwargs)
p.start()
p.join()
p.close()
try:
assert p.exitcode == 0, (
f"Subprocess {func.__name__!r} failed with exit code {p.exitcode}"
)
finally:
p.close()
Loading