Skip to content

Commit ea9a5b7

Browse files
committed
Run Mono tests in subprocesses for proper isolation
1 parent 961b1b0 commit ea9a5b7

1 file changed

Lines changed: 21 additions & 31 deletions

File tree

‎tests/test_common.py‎

Lines changed: 21 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,59 +6,49 @@
66

77

88
def test_mono(example_netstandard: Path):
9-
from clr_loader import get_mono
10-
11-
mono = get_mono()
12-
asm = mono.get_assembly(example_netstandard / "example.dll")
13-
14-
run_tests(asm)
9+
run_in_subprocess(_do_test_mono, example_netstandard)
1510

1611

1712
def test_mono_debug(example_netstandard: Path):
18-
from clr_loader import get_mono
19-
20-
mono = get_mono(
13+
run_in_subprocess(
14+
_do_test_mono,
15+
example_netstandard,
2116
debug=True,
2217
jit_options=[
23-
"--debugger-agent=address=0.0.0.0:5831,transport=dt_socket,server=y"
18+
"--debugger-agent=address=0.0.0.0:5831,transport=dt_socket,server=y,suspend=n"
2419
],
2520
)
26-
asm = mono.get_assembly(example_netstandard / "example.dll")
27-
28-
run_tests(asm)
2921

3022

3123
def test_mono_signal_chaining(example_netstandard: Path):
32-
from clr_loader import get_mono
33-
34-
mono = get_mono(set_signal_chaining=True)
35-
asm = mono.get_assembly(example_netstandard / "example.dll")
36-
37-
run_tests(asm)
24+
run_in_subprocess(_do_test_mono, example_netstandard, set_signal_chaining=True)
3825

3926

4027
def test_mono_trace_mask(example_netstandard: Path):
41-
from clr_loader import get_mono
42-
43-
mono = get_mono(trace_mask="all")
44-
asm = mono.get_assembly(example_netstandard / "example.dll")
45-
46-
run_tests(asm)
28+
run_in_subprocess(_do_test_mono, example_netstandard, trace_mask="all")
4729

4830

4931
def test_mono_trace_level(example_netstandard: Path):
50-
from clr_loader import get_mono
32+
run_in_subprocess(_do_test_mono, example_netstandard, trace_level="message")
5133

52-
mono = get_mono(trace_level="message")
53-
asm = mono.get_assembly(example_netstandard / "example.dll")
5434

55-
run_tests(asm)
35+
def test_mono_set_dir(example_netstandard: Path):
36+
for candidate in ["/usr/lib", "/usr/lib64", "/usr/local/lib", "/opt/homebrew/lib"]:
37+
if (Path(candidate) / "mono").is_dir():
38+
assembly_dir = candidate
39+
break
40+
else:
41+
pytest.skip("Could not find a valid mono assembly dir")
5642

43+
run_in_subprocess(
44+
_do_test_mono, example_netstandard, assembly_dir=assembly_dir, config_dir="/etc"
45+
)
5746

58-
def test_mono_set_dir(example_netstandard: Path):
47+
48+
def _do_test_mono(example_netstandard: Path, **kwargs):
5949
from clr_loader import get_mono
6050

61-
mono = get_mono(assembly_dir="/usr", config_dir="/etc")
51+
mono = get_mono(**kwargs)
6252
asm = mono.get_assembly(example_netstandard / "example.dll")
6353

6454
run_tests(asm)

0 commit comments

Comments
 (0)