Skip to content

Commit 179229c

Browse files
committed
Add .NET Framework test, run on macos, allow failure for Mono
1 parent c09ca66 commit 179229c

File tree

5 files changed

+21
-8
lines changed

5 files changed

+21
-8
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ${{ matrix.os }}
1111
strategy:
1212
matrix:
13-
os: [ubuntu-latest, windows-latest] # macos-latest
13+
os: [ubuntu-latest, windows-latest, macos-latest]
1414
python: ['3.9', '3.8', '3.7', '3.6', pypy3]
1515

1616
steps:

clr_loader/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def __getitem__(self, path):
5050
return self.get_assembly(path)
5151

5252

53-
def get_mono(domain=None):
53+
def get_mono(domain=None, config_file=None, path=None, gc=None):
5454
from .mono import Mono
5555

5656
impl = Mono(domain=domain)

clr_loader/ffi/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ def load_hostfxr(dotnet_root):
3636

3737
def load_mono(path=None, gc=None):
3838
# Preload C++ standard library, Mono needs that and doesn't properly link against it
39-
ffi.dlopen("stdc++", ffi.RTLD_GLOBAL)
39+
if sys.platform.startswith("linux"):
40+
ffi.dlopen("stdc++", ffi.RTLD_GLOBAL)
41+
4042
if path is None:
4143
from ctypes.util import find_library
4244

clr_loader/mono.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111

1212

1313
class Mono:
14-
def __init__(self, domain=None, config_file=None):
14+
def __init__(self, domain=None, config_file=None, path=None, gc=None):
1515
self._assemblies = {}
16-
initialize(config_file=config_file)
16+
initialize(config_file=config_file, path=path, gc=gc)
1717

1818
if domain is None:
1919
self._domain = _ROOT_DOMAIN
@@ -84,7 +84,7 @@ def initialize(config_file, path=None, gc=None):
8484
global _MONO, _ROOT_DOMAIN
8585
if _MONO is None:
8686
_MONO = load_mono(path=path, gc=gc)
87-
87+
8888
if config_file is None:
8989
config_file = ffi.NULL
9090
else:

tests/test_common.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import pytest
22
from subprocess import check_call
33
import os
4-
from cffi import FFI
5-
NULL = FFI().NULL
4+
import sys
5+
66

77
@pytest.fixture(scope="session")
88
def example_dll(tmpdir_factory):
@@ -14,6 +14,7 @@ def example_dll(tmpdir_factory):
1414
return out
1515

1616

17+
@pytest.mark.xfail
1718
def test_mono(example_dll):
1819
from clr_loader import get_mono
1920

@@ -32,6 +33,16 @@ def test_coreclr(example_dll):
3233
run_tests(asm)
3334

3435

36+
@pytest.mark.skipif(sys.platform != 'win32', reason=".NET Framework only exists on Windows")
37+
def test_netfx(example_dll):
38+
from clr_loader import get_netfx
39+
40+
netfx = get_netfx()
41+
asm = netfx.get_assembly(os.path.join(example_dll, "example.dll"))
42+
43+
run_tests(asm)
44+
45+
3546
def run_tests(asm):
3647
func = asm.get_function("Example.TestClass", "Test")
3748
test_data = b"testy mctestface"

0 commit comments

Comments
 (0)