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...@@ -4607,6 +4607,7 @@ fn scanDecl(iter: *ScanDeclIter, decl_sub_index: usize, flags: u4) SemaError!voi
4607 DeclAdapter{ .mod = mod },4607 DeclAdapter{ .mod = mod },
4608 Namespace.DeclContext{ .module = mod },4608 Namespace.DeclContext{ .module = mod },
4609 );4609 );
4610 const comp = mod.comp;
4610 if (!gop.found_existing) {4611 if (!gop.found_existing) {
4611 const new_decl_index = try mod.allocateNewDecl(namespace, decl_node, iter.parent_decl.src_scope);4612 const new_decl_index = try mod.allocateNewDecl(namespace, decl_node, iter.parent_decl.src_scope);
4612 const new_decl = mod.declPtr(new_decl_index);4613 const new_decl = mod.declPtr(new_decl_index);
...@@ -4625,7 +4626,7 @@ fn scanDecl(iter: *ScanDeclIter, decl_sub_index: usize, flags: u4) SemaError!voi...@@ -4625,7 +4626,7 @@ fn scanDecl(iter: *ScanDeclIter, decl_sub_index: usize, flags: u4) SemaError!voi
4625 1 => blk: {4626 1 => blk: {
4626 // test decl with no name. Skip the part where we check against4627 // test decl with no name. Skip the part where we check against
4627 // the test name filter.4628 // 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;
4629 if (decl_pkg != mod.main_pkg) {4630 if (decl_pkg != mod.main_pkg) {
4630 if (!mod.main_pkg_in_std) break :blk false;4631 if (!mod.main_pkg_in_std) break :blk false;
4631 const std_pkg = mod.main_pkg.table.get("std").?;4632 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...@@ -4636,19 +4637,23 @@ fn scanDecl(iter: *ScanDeclIter, decl_sub_index: usize, flags: u4) SemaError!voi
4636 },4637 },
4637 else => blk: {4638 else => blk: {
4638 if (!is_named_test) break :blk false;4639 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;
4640 if (decl_pkg != mod.main_pkg) {4641 if (decl_pkg != mod.main_pkg) {
4641 if (!mod.main_pkg_in_std) break :blk false;4642 if (!mod.main_pkg_in_std) break :blk false;
4642 const std_pkg = mod.main_pkg.table.get("std").?;4643 const std_pkg = mod.main_pkg.table.get("std").?;
4643 if (std_pkg != decl_pkg) break :blk false;4644 if (std_pkg != decl_pkg) break :blk false;
4644 }4645 }
4645 // TODO check the name against --test-filter4646 if (comp.test_filter) |test_filter| {
4647 if (mem.indexOf(u8, decl_name, test_filter) == null) {
4648 break :blk false;
4649 }
4650 }
4646 try mod.test_functions.put(gpa, new_decl_index, {});4651 try mod.test_functions.put(gpa, new_decl_index, {});
4647 break :blk true;4652 break :blk true;
4648 },4653 },
4649 };4654 };
4650 if (want_analysis) {4655 if (want_analysis) {
4651 mod.comp.work_queue.writeItemAssumeCapacity(.{ .analyze_decl = new_decl_index });4656 comp.work_queue.writeItemAssumeCapacity(.{ .analyze_decl = new_decl_index });
4652 }4657 }
4653 new_decl.is_pub = is_pub;4658 new_decl.is_pub = is_pub;
4654 new_decl.is_exported = is_exported;4659 new_decl.is_exported = is_exported;
...@@ -4675,24 +4680,24 @@ fn scanDecl(iter: *ScanDeclIter, decl_sub_index: usize, flags: u4) SemaError!voi...@@ -4675,24 +4680,24 @@ fn scanDecl(iter: *ScanDeclIter, decl_sub_index: usize, flags: u4) SemaError!voi
4675 decl.has_linksection_or_addrspace = has_linksection_or_addrspace;4680 decl.has_linksection_or_addrspace = has_linksection_or_addrspace;
4676 decl.zir_decl_index = @intCast(u32, decl_sub_index);4681 decl.zir_decl_index = @intCast(u32, decl_sub_index);
4677 if (decl.getFunction()) |_| {4682 if (decl.getFunction()) |_| {
4678 switch (mod.comp.bin_file.tag) {4683 switch (comp.bin_file.tag) {
4679 .coff => {4684 .coff => {
4680 // TODO Implement for COFF4685 // TODO Implement for COFF
4681 },4686 },
4682 .elf => if (decl.fn_link.elf.len != 0) {4687 .elf => if (decl.fn_link.elf.len != 0) {
4683 // TODO Look into detecting when this would be unnecessary by storing enough state4688 // TODO Look into detecting when this would be unnecessary by storing enough state
4684 // in `Decl` to notice that the line number did not change.4689 // 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 });
4686 },4691 },
4687 .macho => if (decl.fn_link.macho.len != 0) {4692 .macho => if (decl.fn_link.macho.len != 0) {
4688 // TODO Look into detecting when this would be unnecessary by storing enough state4693 // TODO Look into detecting when this would be unnecessary by storing enough state
4689 // in `Decl` to notice that the line number did not change.4694 // 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 });
4691 },4696 },
4692 .plan9 => {4697 .plan9 => {
4693 // TODO Look into detecting when this would be unnecessary by storing enough state4698 // TODO Look into detecting when this would be unnecessary by storing enough state
4694 // in `Decl` to notice that the line number did not change.4699 // 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 });
4696 },4701 },
4697 .c, .wasm, .spirv, .nvptx => {},4702 .c, .wasm, .spirv, .nvptx => {},
4698 }4703 }