mix test fails randomly
I'm constantly getting failed tests, but not always the same ones and I have no idea why or what I can do about it. The error I get is always something like ** (ArgumentError) cannot add expectations/stubs to Pleroma.CachexMock in the current process (#PID<0.19857.0>) because Mox is in global mode and the global process is #PID<0.19846.0>. Only the process that set Mox to global can set expectations/stubs in global mode
.
@rinpatch suggested I try what happens when I rerun tests with the same seed, but even then a different amount of tests can fail (or not fail at all). An example I had:
mix test
Finished in 195.9 seconds
3391 tests, 1584 failures, 2 excluded, 4 skipped
Randomized with seed 795241
mix test --seed 795241
Finished in 340.9 seconds
3391 tests, 0 failures, 2 excluded, 4 skipped
Randomized with seed 795241
I'm getting this locally and on gitlab. See for example the failed jobs at https://git.pleroma.social/ilja/pleroma/-/pipelines/34140/builds
I had this on the branch for !2964 (closed) but only got it last weekend after merging latest develop with it. I also tried locally on the develop branch and got similar errors there (using the same seed like I gave here).
I have no idea what to do with this, so I hope someone can help because it's the biggest MR I've done so far and I would like to not have it hanging for much longer than necessary.