Skip to content

Timing issue after using set_mox_global #170

@Sinc63

Description

@Sinc63

I upgraded Mox from 1.1.0 to 1.2.0 and now have an intermittent problem.

I have two test files in a directory, the first of which sets Mox to global mode, and the second of which does not.

I've never had problems with these files before, but since upgrading to 1.2.0 the second file will sometimes now fail multiple tests with an error like:

     ** (ArgumentError) cannot add expectations/stubs to JitsiMeet.Token.JwtMock in the current process (#PID<0.1826.0>) because Mox is in global mode and the global process is #PID<0.1814.0>. Only the process that set Mox to global can set expectations/stubs in global mode

It's not consistent, but I would estimate it occurs on roughly 1/8 test runs. Looking at the code changes I would think this must have to do with NimbleOwnership.allow having a timeout. I didn't look farther than seeing that. I would think that the setting of the global mode should end when the test module exits, (i.e. from an on_exit function), not based on a timeout.

Erlang/OTP 26 [erts-14.2.5] [source] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:1] [jit:ns]

Elixir 1.14.5 (compiled with Erlang/OTP 26)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions