Skip to content

integrate incremental compilation with zig test #4414

@momumi

Description

@momumi

I have a bunch of tests in separate files, and in my main.zig file I include all the tests like this:

test "main test" {
    _ = @import("tests/test_1.zig");
    // ...
    _ = @import("tests/test_N.zig");
}

If I update one of these files and run zig test main.zig, then zig seems to recompile all my tests files even though only one of them changed.

My tests run nearly instantly, but they are rather slow to compile:

$ time zig build test

real    8.34s
user    7.73s
sys     0.60s

Running the tests again after they have been compiled:

$ time zig build test

real    0.07s
user    0.05s
sys     0.01s

Removing all the tests from main.zig except for the one that changed:

$ time zig build test

real    1.08s
user    0.95s
sys     0.12s

What I expect to happen, is zig test would only rebuild the tests that have changed. Of course if I modify code that tests depend upon, then those tests should also be rebuilt. There's not a lot documentation for tests, so I could also have set this up in the completely wrong way.

--test-filter

One work around seems to be to use --test-filter, however this fails because if the filter expression doesn't match against main test, then none of the tests will be include or compiled.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementSolving this issue will likely involve adding new logic or components to the codebase.frontendTokenization, parsing, AstGen, Sema, and Liveness.incremental compilationProblem occurs only when reusing compiler state.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions