aboutsummaryrefslogtreecommitdiff
path: root/test/tests.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2019-02-08 19:23:46 -0500
committerAndrew Kelley <andrew@ziglang.org>2019-02-08 19:23:46 -0500
commit46ddd5f5f4db7977010f78129fade7dfa5b9d8d3 (patch)
tree1247e46cfd016c69e23620f9370670fe02caad4b /test/tests.zig
parentc2db077574be841da586fa62d67619c901dd535d (diff)
downloadzig-46ddd5f5f4db7977010f78129fade7dfa5b9d8d3.tar.gz
zig-46ddd5f5f4db7977010f78129fade7dfa5b9d8d3.zip
fix compiler assertion failure when returning value from test
closes #1935
Diffstat (limited to 'test/tests.zig')
-rw-r--r--test/tests.zig16
1 files changed, 15 insertions, 1 deletions
diff --git a/test/tests.zig b/test/tests.zig
index 670c410509..800ddc1ccd 100644
--- a/test/tests.zig
+++ b/test/tests.zig
@@ -538,6 +538,7 @@ pub const CompileErrorContext = struct {
expected_errors: ArrayList([]const u8),
link_libc: bool,
is_exe: bool,
+ is_test: bool,
const SourceFile = struct {
filename: []const u8,
@@ -596,7 +597,13 @@ pub const CompileErrorContext = struct {
var zig_args = ArrayList([]const u8).init(b.allocator);
zig_args.append(b.zig_exe) catch unreachable;
- zig_args.append(if (self.case.is_exe) "build-exe" else "build-obj") catch unreachable;
+ if (self.case.is_exe) {
+ try zig_args.append("build-exe");
+ } else if (self.case.is_test) {
+ try zig_args.append("test");
+ } else {
+ try zig_args.append("build-obj");
+ }
zig_args.append(b.pathFromRoot(root_src)) catch unreachable;
zig_args.append("--name") catch unreachable;
@@ -699,6 +706,7 @@ pub const CompileErrorContext = struct {
.expected_errors = ArrayList([]const u8).init(self.b.allocator),
.link_libc = false,
.is_exe = false,
+ .is_test = false,
};
tc.addSourceFile(".tmp_source.zig", source);
@@ -726,6 +734,12 @@ pub const CompileErrorContext = struct {
self.addCase(tc);
}
+ pub fn addTest(self: *CompileErrorContext, name: []const u8, source: []const u8, expected_lines: ...) void {
+ const tc = self.create(name, source, expected_lines);
+ tc.is_test = true;
+ self.addCase(tc);
+ }
+
pub fn addCase(self: *CompileErrorContext, case: *const TestCase) void {
const b = self.b;