Add .NET Framework test, run on macos, allow failure for Mono

This commit is contained in:
Benedikt Reinartz 2020-11-22 00:55:55 +01:00
Родитель c09ca66314
Коммит 179229c1eb
5 изменённых файлов: 21 добавлений и 8 удалений

2
.github/workflows/ci.yml поставляемый
Просмотреть файл

@ -10,7 +10,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest] # macos-latest
os: [ubuntu-latest, windows-latest, macos-latest]
python: ['3.9', '3.8', '3.7', '3.6', pypy3]
steps:

Просмотреть файл

@ -50,7 +50,7 @@ class Runtime:
return self.get_assembly(path)
def get_mono(domain=None):
def get_mono(domain=None, config_file=None, path=None, gc=None):
from .mono import Mono
impl = Mono(domain=domain)

Просмотреть файл

@ -36,7 +36,9 @@ def load_hostfxr(dotnet_root):
def load_mono(path=None, gc=None):
# Preload C++ standard library, Mono needs that and doesn't properly link against it
ffi.dlopen("stdc++", ffi.RTLD_GLOBAL)
if sys.platform.startswith("linux"):
ffi.dlopen("stdc++", ffi.RTLD_GLOBAL)
if path is None:
from ctypes.util import find_library

Просмотреть файл

@ -11,9 +11,9 @@ _ROOT_DOMAIN = None
class Mono:
def __init__(self, domain=None, config_file=None):
def __init__(self, domain=None, config_file=None, path=None, gc=None):
self._assemblies = {}
initialize(config_file=config_file)
initialize(config_file=config_file, path=path, gc=gc)
if domain is None:
self._domain = _ROOT_DOMAIN
@ -84,7 +84,7 @@ def initialize(config_file, path=None, gc=None):
global _MONO, _ROOT_DOMAIN
if _MONO is None:
_MONO = load_mono(path=path, gc=gc)
if config_file is None:
config_file = ffi.NULL
else:

Просмотреть файл

@ -1,8 +1,8 @@
import pytest
from subprocess import check_call
import os
from cffi import FFI
NULL = FFI().NULL
import sys
@pytest.fixture(scope="session")
def example_dll(tmpdir_factory):
@ -14,6 +14,7 @@ def example_dll(tmpdir_factory):
return out
@pytest.mark.xfail
def test_mono(example_dll):
from clr_loader import get_mono
@ -32,6 +33,16 @@ def test_coreclr(example_dll):
run_tests(asm)
@pytest.mark.skipif(sys.platform != 'win32', reason=".NET Framework only exists on Windows")
def test_netfx(example_dll):
from clr_loader import get_netfx
netfx = get_netfx()
asm = netfx.get_assembly(os.path.join(example_dll, "example.dll"))
run_tests(asm)
def run_tests(asm):
func = asm.get_function("Example.TestClass", "Test")
test_data = b"testy mctestface"