I'm writing a Rust binding and there could be some thread sanitization issues inevitably accessing some global items from .so or registering some global functions that when I run my tests even with --test-threads=1 at least one would fail but if I run each individually by name cargo test myfunction then they all pass.
Is there any way to run tests individually in this case besides adding unwanted test_features = [] or something?
It sounds like the library being wrapped plays around with some global state, so after the first test fails the world is left in an inconsistent state and all later tests blow up as well.
It sounds like instead of restricting tests to one thread, you want to run each test in its own process. It shouldn't be too hard to knock up a python/bash script (or maybe even a Rust program under the tests/ directory) which looks for the my_test bit in #[test]\nfn my_test() and invokes each test with cargo test my_test... It'll take forever to run your test suite that way though...
What about writing your tests without rustc inserting its default test harness? That way you can write a normal Rust program intests/foo.rs to invoke the FFI tests and it'll be executed whenever you run cargo test.
Yes, that's right! in particular, there's a module which works with globally registered functions in .so and it's also possible to globally register functions. Now my unit tests for that module pass or fail underministically and using mutex for each unit test didn't help either.