#How does one run all tests in all files ?

1 messages · Page 1 of 1 (latest)

snow pier
#

Suppose I have a number of subdirectories, a number of files with various functions.

How can I run ALL of the tests for all of the functions? I have played with a number of ways ... but my attempts add too many hand-curated dependencies. What's the magic way?

opaque haven
#

you have to reference them from a central test, for example I put something like this in main.zig and then run zig test main.zig

test {
    _ = @import("./x.zig");
    _ = @import("./y.zig");
    _ = @import("./z/a.zig");
    _ = @import("./z/b.zig");
}

there is no simpler way that i know of

#

i should say, you have to reference each file containing tests

latent niche
#

You can adjust the example from zig init-exe by adding all files for which zig build test will be run.

snow pier
next patrol
opaque haven
#

yes, but doesn't that only work well in that situation (std.zig) because that file already imports all those other modules?

#

i guess the same thing would work if you happen to already have a file that imports most of the modules in the app

next patrol
snow pier
hearty turret
opaque haven
hearty turret
#

'cause you have a test whose only purpose is to reference other tests

#

if you do that enough in enough files, you end up with a few dozen non-test tests

opaque haven
#

i do it in exactly one file

hearty turret
#

sure, that's fine ig

#

I'm just sayin

#

I personally prefer the number of tests to reflect the exact number of actual number of tests

snow pier
#

part of my original question had been motivated by the fact that I presently use a loop (and a nested build function), to be able to build serveral executables with 1 invocation of "zig build". But, trying to extend this to build multiple tests ... failed and failed.

So, I was happy to see that a number of "smooth" solutions exist. Moreoever, this quest lead me to read "Mitchell Hasimoto" in depth article on the Zig Build System Internals. I learned much about build from this and recommend it to others. ... sigh ... that is my long-winded "Thank you" to the group here.