| ... | @@ -538,6 +538,7 @@ pub const CompileErrorContext = struct { | ... | @@ -538,6 +538,7 @@ pub const CompileErrorContext = struct { |
| 538 | expected_errors: ArrayList([]const u8), | 538 | expected_errors: ArrayList([]const u8), |
| 539 | link_libc: bool, | 539 | link_libc: bool, |
| 540 | is_exe: bool, | 540 | is_exe: bool, |
| | 541 | is_test: bool, |
| 541 | | 542 | |
| 542 | const SourceFile = struct { | 543 | const SourceFile = struct { |
| 543 | filename: []const u8, | 544 | filename: []const u8, |
| ... | @@ -596,7 +597,13 @@ pub const CompileErrorContext = struct { | ... | @@ -596,7 +597,13 @@ pub const CompileErrorContext = struct { |
| 596 | var zig_args = ArrayList([]const u8).init(b.allocator); | 597 | var zig_args = ArrayList([]const u8).init(b.allocator); |
| 597 | zig_args.append(b.zig_exe) catch unreachable; | 598 | zig_args.append(b.zig_exe) catch unreachable; |
| 598 | | 599 | |
| 599 | zig_args.append(if (self.case.is_exe) "build-exe" else "build-obj") catch unreachable; | 600 | if (self.case.is_exe) { |
| | 601 | try zig_args.append("build-exe"); |
| | 602 | } else if (self.case.is_test) { |
| | 603 | try zig_args.append("test"); |
| | 604 | } else { |
| | 605 | try zig_args.append("build-obj"); |
| | 606 | } |
| 600 | zig_args.append(b.pathFromRoot(root_src)) catch unreachable; | 607 | zig_args.append(b.pathFromRoot(root_src)) catch unreachable; |
| 601 | | 608 | |
| 602 | zig_args.append("--name") catch unreachable; | 609 | zig_args.append("--name") catch unreachable; |
| ... | @@ -699,6 +706,7 @@ pub const CompileErrorContext = struct { | ... | @@ -699,6 +706,7 @@ pub const CompileErrorContext = struct { |
| 699 | .expected_errors = ArrayList([]const u8).init(self.b.allocator), | 706 | .expected_errors = ArrayList([]const u8).init(self.b.allocator), |
| 700 | .link_libc = false, | 707 | .link_libc = false, |
| 701 | .is_exe = false, | 708 | .is_exe = false, |
| | 709 | .is_test = false, |
| 702 | }; | 710 | }; |
| 703 | | 711 | |
| 704 | tc.addSourceFile(".tmp_source.zig", source); | 712 | tc.addSourceFile(".tmp_source.zig", source); |
| ... | @@ -726,6 +734,12 @@ pub const CompileErrorContext = struct { | ... | @@ -726,6 +734,12 @@ pub const CompileErrorContext = struct { |
| 726 | self.addCase(tc); | 734 | self.addCase(tc); |
| 727 | } | 735 | } |
| 728 | | 736 | |
| | 737 | pub fn addTest(self: *CompileErrorContext, name: []const u8, source: []const u8, expected_lines: ...) void { |
| | 738 | const tc = self.create(name, source, expected_lines); |
| | 739 | tc.is_test = true; |
| | 740 | self.addCase(tc); |
| | 741 | } |
| | 742 | |
| 729 | pub fn addCase(self: *CompileErrorContext, case: *const TestCase) void { | 743 | pub fn addCase(self: *CompileErrorContext, case: *const TestCase) void { |
| 730 | const b = self.b; | 744 | const b = self.b; |
| 731 | | 745 | |