Unable to run test that uses import outside current directory?

I searched my code base and there is one place where I actually use .. to navigate in a deeper folder structure one level up to refer to a bunch of types that are common to a bunch of different files. I guess there are places where the analogy fails.

I think the problem might be that the zig test command doesn’t seem to have support for being used for projects with more complex imports, I think you need to use a custom build step to define your test run similar to this (but for testing instead of docs) Zig Autodoc : exclude anonymous imports? - #2 by dimdin
Basically I think the zig test command is only for simple cases, for more complex ones define a build step that does the testing.

I don’t quite know how the zig test command determines the root of the module, you also could try calling it from a parent directory, but I am not sure if that works.
Have you tried cd src and the zig test dep/dep.zig so that theoretically the command may have the same root directory?

I just know that I had cases where I gave up trying to use zig test and then just used testing via a build system run step.

1 Like