Commit c8d0fb0b21

Jakub Konka <kubkon@jakubkonka.com>
2022-04-28 12:11:49
test: migrate stage2 independent compile errors to test manifest parser
1 parent 3c19f69
src/test.zig
@@ -42,12 +42,12 @@ test {
     defer compile_errors_dir.close();
 
     {
-        var stage2_dir = try compile_errors_dir.openDir("stage2", .{ .iterate = true });
-        defer stage2_dir.close();
+        var dir = try compile_errors_dir.openDir("stage2", .{ .iterate = true });
+        defer dir.close();
 
         // TODO make this incremental once the bug is solved that it triggers
         // See: https://github.com/ziglang/zig/issues/11344
-        ctx.addErrorCasesFromDir("stage2", stage2_dir, .stage2, .Obj, false, .independent);
+        ctx.addTestCasesFromDir(dir, .independent);
     }
 
     if (!skip_stage1) {
test/compile_errors/stage2/constant_inside_comptime_function_has_compile_error.zig
@@ -14,7 +14,7 @@ export fn entry() void {
     _ = allocator;
 }
 
-// constant inside comptime function has compile error
+// error
 //
 // :4:5: error: unreachable code
 // :4:25: note: control flow is diverted here
test/compile_errors/stage2/duplicate-unused_labels.zig
@@ -17,7 +17,7 @@ comptime {
     blk: for(@as([0]void, undefined)) |_| {}
 }
 
-// duplicate/unused labels
+// error
 //
 // :2:12: error: redefinition of label 'blk'
 // :2:5: note: previous definition here
test/compile_errors/stage2/embed_outside_package.zig
@@ -2,6 +2,6 @@ export fn a() usize {
     return @embedFile("/root/foo").len;
 }
 
-// embed outside package
+// error
 //
 //:2:23: error: embed of file outside package path: '/root/foo'
test/compile_errors/stage2/import_outside_package.zig
@@ -2,6 +2,6 @@ export fn a() usize {
     return @import("../../above.zig").len;
 }
 
-// import outside package
+// error
 //
 // :2:20: error: import of file outside package path: '../../above.zig'
test/compile_errors/stage2/out_of_bounds_index.zig
@@ -20,7 +20,7 @@ comptime {
     _ = slice;
 }
 
-// out of bounds indexing
+// error
 //
 // :4:26: error: end index 6 out of bounds for slice of length 4 +1 (sentinel)
 // :9:22: error: end index 6 out of bounds for array of length 4 +1 (sentinel)
test/compile_errors/stage2/slice_of_null_pointer.zig
@@ -5,6 +5,6 @@ comptime {
     _ = y;
 }
 
-// slice of null C pointer
+// error
 //
 // :4:14: error: slice of null pointer
test/compile_errors/stage2/struct_duplicate_field_name.zig
@@ -8,7 +8,7 @@ export fn entry() void {
     _ = s;
 }
 
-// duplicate struct field name
+// error
 //
 // :3:5: error: duplicate struct field: 'foo'
 // :2:5: note: other field here
test/compile_errors/stage2/union_access_of_inactive_field.zig
@@ -3,12 +3,12 @@ const U = union {
     b: u64,
 };
 comptime {
-    var u: U = .{.a = {}};
+    var u: U = .{ .a = {} };
     const v = u.b;
     _ = v;
 }
 
-// access of inactive union field
+// error
 //
 // :7:16: error: access of union field 'b' while field 'a' is active
 // :1:11: note: union declared here
test/compile_errors/stage2/union_duplicate_enum_field.zig
@@ -1,4 +1,4 @@
-const E = enum {a, b};
+const E = enum { a, b };
 const U = union(E) {
     a: u32,
     a: u32,
@@ -9,7 +9,7 @@ export fn foo() void {
     _ = u;
 }
 
-// union with enum and duplicate fields
+// error
 //
 // :4:5: error: duplicate union field: 'a'
 // :3:5: note: other field here
test/compile_errors/stage2/union_duplicate_field_definition.zig
@@ -8,7 +8,7 @@ export fn entry() void {
     _ = u;
 }
 
-// duplicate union field name
+// error
 //
 // :3:5: error: duplicate union field: 'foo'
 // :2:5: note: other field here
test/compile_errors/stage2/union_enum_field_missing.zig
@@ -13,7 +13,7 @@ export fn entry() usize {
     return @sizeOf(U);
 }
 
-// enum field missing in union
+// error
 //
 // :7:1: error: enum field(s) missing in union
 // :4:5: note: field 'c' missing, declared here
test/compile_errors/stage2/union_extra_field.zig
@@ -13,7 +13,7 @@ export fn entry() usize {
     return @sizeOf(U);
 }
 
-// union extra field
+// error
 //
 // :6:1: error: enum 'tmp.E' has no field named 'd'
 // :1:11: note: enum declared here
test/compile_errors/stage2/union_runtime_coercion_from_enum.zig
@@ -14,7 +14,7 @@ export fn doTheTest() u64 {
     return u.b;
 }
 
-// runtime coercion from enum to union
+// error
 //
 // :13:19: error: runtime coercion from enum 'tmp.E' to union 'tmp.U' which has non-void fields
 // :6:5: note: field 'a' has type 'u32'