| 1 |
import subprocess |
| 2 |
import pathlib |
| 3 |
import pytest |
| 4 |
|
| 5 |
TEST_PATH = pathlib.Path(__file__).parents[1].resolve() |
| 6 |
|
| 7 |
xfails = {} |
| 8 |
|
| 9 |
|
| 10 |
def libffi_tests(self, selenium, libffi_test): |
| 11 |
if libffi_test in xfails: |
| 12 |
pytest.xfail(f'known failure with code "{xfails[libffi_test]}"') |
| 13 |
res = selenium.run_js( |
| 14 |
""" |
| 15 |
window.TestModule = await Module(); |
| 16 |
""" |
| 17 |
) |
| 18 |
selenium.run_js( |
| 19 |
f""" |
| 20 |
try {{ |
| 21 |
TestModule._test__{libffi_test}(); |
| 22 |
}} catch(e){{ |
| 23 |
if(e.name !== "ExitStatus"){{ |
| 24 |
throw e; |
| 25 |
}} |
| 26 |
if(e.status !== 0){{ |
| 27 |
throw new Error(`Terminated with nonzero status code ${{e.status}}: ` + e.message); |
| 28 |
}} |
| 29 |
}} |
| 30 |
""" |
| 31 |
) |
| 32 |
|
| 33 |
|
| 34 |
class TestCall: |
| 35 |
TEST_BUILD_DIR = "libffi.call.test" |
| 36 |
test_call = libffi_tests |
| 37 |
|
| 38 |
|
| 39 |
class TestClosures: |
| 40 |
TEST_BUILD_DIR = "libffi.closures.test" |
| 41 |
test_closures = libffi_tests |
| 42 |
|
| 43 |
|
| 44 |
def pytest_generate_tests(metafunc): |
| 45 |
test_build_dir = metafunc.cls.TEST_BUILD_DIR |
| 46 |
test_names = [x.stem for x in (TEST_PATH / test_build_dir).glob("*.o")] |
| 47 |
metafunc.parametrize("libffi_test", test_names) |
| 48 |
|
| 49 |
|
| 50 |
if __name__ == "__main__": |
| 51 |
subprocess.call(["build-tests.sh", "libffi.call"]) |