authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-06-27 14:31:54-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-06-27 14:31:54-07:00
log3b19869853282546fe290a63fc447ae88e713031
tree12b2a34164fa4e7b8246778f9b463dbb365d91f9
parenta76775b50a65fd0ea0fd17d6ef3c42058df13997

Sema: honor the --test-filter flag


1 files changed, 13 insertions(+), 8 deletions(-)

src/Module.zig+13-8
......@@ -4607,6 +4607,7 @@ fn scanDecl(iter: *ScanDeclIter, decl_sub_index: usize, flags: u4) SemaError!voi
46074607 DeclAdapter{ .mod = mod },
46084608 Namespace.DeclContext{ .module = mod },
46094609 );
4610 const comp = mod.comp;
46104611 if (!gop.found_existing) {
46114612 const new_decl_index = try mod.allocateNewDecl(namespace, decl_node, iter.parent_decl.src_scope);
46124613 const new_decl = mod.declPtr(new_decl_index);
......@@ -4625,7 +4626,7 @@ fn scanDecl(iter: *ScanDeclIter, decl_sub_index: usize, flags: u4) SemaError!voi
46254626 1 => blk: {
46264627 // test decl with no name. Skip the part where we check against
46274628 // the test name filter.
4628 if (!mod.comp.bin_file.options.is_test) break :blk false;
4629 if (!comp.bin_file.options.is_test) break :blk false;
46294630 if (decl_pkg != mod.main_pkg) {
46304631 if (!mod.main_pkg_in_std) break :blk false;
46314632 const std_pkg = mod.main_pkg.table.get("std").?;
......@@ -4636,19 +4637,23 @@ fn scanDecl(iter: *ScanDeclIter, decl_sub_index: usize, flags: u4) SemaError!voi
46364637 },
46374638 else => blk: {
46384639 if (!is_named_test) break :blk false;
4639 if (!mod.comp.bin_file.options.is_test) break :blk false;
4640 if (!comp.bin_file.options.is_test) break :blk false;
46404641 if (decl_pkg != mod.main_pkg) {
46414642 if (!mod.main_pkg_in_std) break :blk false;
46424643 const std_pkg = mod.main_pkg.table.get("std").?;
46434644 if (std_pkg != decl_pkg) break :blk false;
46444645 }
4645 // TODO check the name against --test-filter
4646 if (comp.test_filter) |test_filter| {
4647 if (mem.indexOf(u8, decl_name, test_filter) == null) {
4648 break :blk false;
4649 }
4650 }
46464651 try mod.test_functions.put(gpa, new_decl_index, {});
46474652 break :blk true;
46484653 },
46494654 };
46504655 if (want_analysis) {
4651 mod.comp.work_queue.writeItemAssumeCapacity(.{ .analyze_decl = new_decl_index });
4656 comp.work_queue.writeItemAssumeCapacity(.{ .analyze_decl = new_decl_index });
46524657 }
46534658 new_decl.is_pub = is_pub;
46544659 new_decl.is_exported = is_exported;
......@@ -4675,24 +4680,24 @@ fn scanDecl(iter: *ScanDeclIter, decl_sub_index: usize, flags: u4) SemaError!voi
46754680 decl.has_linksection_or_addrspace = has_linksection_or_addrspace;
46764681 decl.zir_decl_index = @intCast(u32, decl_sub_index);
46774682 if (decl.getFunction()) |_| {
4678 switch (mod.comp.bin_file.tag) {
4683 switch (comp.bin_file.tag) {
46794684 .coff => {
46804685 // TODO Implement for COFF
46814686 },
46824687 .elf => if (decl.fn_link.elf.len != 0) {
46834688 // TODO Look into detecting when this would be unnecessary by storing enough state
46844689 // in `Decl` to notice that the line number did not change.
4685 mod.comp.work_queue.writeItemAssumeCapacity(.{ .update_line_number = decl_index });
4690 comp.work_queue.writeItemAssumeCapacity(.{ .update_line_number = decl_index });
46864691 },
46874692 .macho => if (decl.fn_link.macho.len != 0) {
46884693 // TODO Look into detecting when this would be unnecessary by storing enough state
46894694 // in `Decl` to notice that the line number did not change.
4690 mod.comp.work_queue.writeItemAssumeCapacity(.{ .update_line_number = decl_index });
4695 comp.work_queue.writeItemAssumeCapacity(.{ .update_line_number = decl_index });
46914696 },
46924697 .plan9 => {
46934698 // TODO Look into detecting when this would be unnecessary by storing enough state
46944699 // in `Decl` to notice that the line number did not change.
4695 mod.comp.work_queue.writeItemAssumeCapacity(.{ .update_line_number = decl_index });
4700 comp.work_queue.writeItemAssumeCapacity(.{ .update_line_number = decl_index });
46964701 },
46974702 .c, .wasm, .spirv, .nvptx => {},
46984703 }