-
Notifications
You must be signed in to change notification settings - Fork 57
Open
Description
When running tests with pytest-xtest, different test runs will try to compile the test code in the same __pycache__
directory. If the tests contain the same C code, this will lead to a situation where two tests are trying to build the same extension simultaneously, which can lead to compilation overwriting the same files, which will not work on windows (and perhaps elsewhere).
For instance, these tests will produce the same cffi source hash so calling ffi.verify
will generate exactly the same object and linker output
def test_rounding_1():
ffi = FFI()
ffi.cdef("double sinf(float x);")
lib = ffi.verify('#include <math.h>', libraries=lib_m)
res = lib.sinf(1.23)
assert res != math.sin(1.23) # not exact, because of double->float
assert abs(res - math.sin(1.23)) < 1E-5
def test_rounding_2():
ffi = FFI()
ffi.cdef("double sin(float x);")
lib = ffi.verify('#include <math.h>', libraries=lib_m)
res = lib.sin(1.23)
assert res != math.sin(1.23) # not exact, because of double->float
assert abs(res - math.sin(1.23)) < 1E-5
One possible mitigation could be to change the __init__
of the FFI
class to add a random `ffi.cdef("/* %d */" % random.randint(0, 32_000))
apteryks
Metadata
Metadata
Assignees
Labels
No labels