Skip to content

Commit

Permalink
Zcu: allow test declarations to be failed
Browse files Browse the repository at this point in the history
The introduction of the `extended(astgen_error())` instruction allows a
`test` declaration to be unresolved, i.e. the declaration doesn't even
contain a `func`. I could modify AstGen to not do this, but it makes
more sense to just handle this case when collecting test functions.

Note that tests under incremental compilation are currently broken if
you ever remove all references to a test; this is tracked as a subtask
of ziglang#21165.
  • Loading branch information
mlugg committed Dec 6, 2024
1 parent 8f84968 commit 9f086f8
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/Zcu/PerThread.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2511,6 +2511,19 @@ pub fn populateTestFunctions(

for (test_fn_vals, zcu.test_functions.keys()) |*test_fn_val, test_nav_index| {
const test_nav = ip.getNav(test_nav_index);

{
// The test declaration might have failed; if that's the case, just return, as we'll
// be emitting a compile error anyway.
const cau = test_nav.analysis_owner.unwrap().?;
const anal_unit: AnalUnit = .wrap(.{ .cau = cau });
if (zcu.failed_analysis.contains(anal_unit) or
zcu.transitive_failed_analysis.contains(anal_unit))
{
return;
}
}

const test_nav_name = test_nav.fqn;
const test_nav_name_len = test_nav_name.length(ip);
const test_name_anon_decl: InternPool.Key.Ptr.BaseAddr.Uav = n: {
Expand Down

0 comments on commit 9f086f8

Please sign in to comment.