diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2022-03-31 15:06:44 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-03-31 15:10:31 -0700 |
| commit | 243afdcdf57d74a184784551aebe58062e5afc03 (patch) | |
| tree | 7e637a4c50b8abf6beb1354c346fc08055c5f0e7 /test/compile_errors | |
| parent | df1ba38a88a255286af4d939d427f8a4ee667485 (diff) | |
| download | zig-243afdcdf57d74a184784551aebe58062e5afc03.tar.gz zig-243afdcdf57d74a184784551aebe58062e5afc03.zip | |
test harness improvements
* `-Dskip-compile-errors` is removed; `-Dskip-stage1` is added.
* Use `std.testing.allocator` instead of a new instance of GPA.
- Fix the memory leaks this revealed.
* Show the file name when it is not parsed correctly such as when the
manifest is missing.
- Better error messages when test files are not parsed correctly.
* Ignore unknown files such as swap files.
* Move logic from declarative file to the test harness implementation.
* Move stage1 tests to stage2 tests where appropriate.
Diffstat (limited to 'test/compile_errors')
| -rw-r--r-- | test/compile_errors/stage1/obj/std.fmt_error_for_unused_arguments.zig (renamed from test/compile_errors/stage1/exe/std.fmt_error_for_unused_arguments.zig) | 2 | ||||
| -rw-r--r-- | test/compile_errors/stage1/obj/unused_variable_error_on_errdefer.zig (renamed from test/compile_errors/stage1/test/unused_variable_error_on_errdefer.zig) | 0 | ||||
| -rw-r--r-- | test/compile_errors/stage1/test/duplicate-unused_labels.zig | 30 | ||||
| -rw-r--r-- | test/compile_errors/stage2/constant_inside_comptime_function_has_compile_error.zig (renamed from test/compile_errors/stage1/obj/constant_inside_comptime_function_has_compile_error.zig) | 7 | ||||
| -rw-r--r-- | test/compile_errors/stage2/duplicate-unused_labels.zig | 30 |
5 files changed, 35 insertions, 34 deletions
diff --git a/test/compile_errors/stage1/exe/std.fmt_error_for_unused_arguments.zig b/test/compile_errors/stage1/obj/std.fmt_error_for_unused_arguments.zig index 7da78d5b03..68299c2177 100644 --- a/test/compile_errors/stage1/exe/std.fmt_error_for_unused_arguments.zig +++ b/test/compile_errors/stage1/obj/std.fmt_error_for_unused_arguments.zig @@ -1,4 +1,4 @@ -pub fn main() !void { +export fn entry() void { @import("std").debug.print("{d} {d} {d} {d} {d}", .{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}); } diff --git a/test/compile_errors/stage1/test/unused_variable_error_on_errdefer.zig b/test/compile_errors/stage1/obj/unused_variable_error_on_errdefer.zig index eb92776938..eb92776938 100644 --- a/test/compile_errors/stage1/test/unused_variable_error_on_errdefer.zig +++ b/test/compile_errors/stage1/obj/unused_variable_error_on_errdefer.zig diff --git a/test/compile_errors/stage1/test/duplicate-unused_labels.zig b/test/compile_errors/stage1/test/duplicate-unused_labels.zig deleted file mode 100644 index 285741afc4..0000000000 --- a/test/compile_errors/stage1/test/duplicate-unused_labels.zig +++ /dev/null @@ -1,30 +0,0 @@ -comptime { - blk: { blk: while (false) {} } -} -comptime { - blk: while (false) { blk: for (@as([0]void, undefined)) |_| {} } -} -comptime { - blk: for (@as([0]void, undefined)) |_| { blk: {} } -} -comptime { - blk: {} -} -comptime { - blk: while(false) {} -} -comptime { - blk: for(@as([0]void, undefined)) |_| {} -} - -// duplicate/unused labels -// -// tmp.zig:2:12: error: redefinition of label 'blk' -// tmp.zig:2:5: note: previous definition here -// tmp.zig:5:26: error: redefinition of label 'blk' -// tmp.zig:5:5: note: previous definition here -// tmp.zig:8:46: error: redefinition of label 'blk' -// tmp.zig:8:5: note: previous definition here -// tmp.zig:11:5: error: unused block label -// tmp.zig:14:5: error: unused while loop label -// tmp.zig:17:5: error: unused for loop label diff --git a/test/compile_errors/stage1/obj/constant_inside_comptime_function_has_compile_error.zig b/test/compile_errors/stage2/constant_inside_comptime_function_has_compile_error.zig index 8eabcfdeaa..969b73713f 100644 --- a/test/compile_errors/stage1/obj/constant_inside_comptime_function_has_compile_error.zig +++ b/test/compile_errors/stage2/constant_inside_comptime_function_has_compile_error.zig @@ -2,6 +2,7 @@ const ContextAllocator = MemoryPool(usize); pub fn MemoryPool(comptime T: type) type { const free_list_t = @compileError("aoeu",); + _ = T; return struct { free_list: free_list_t, @@ -10,10 +11,10 @@ pub fn MemoryPool(comptime T: type) type { export fn entry() void { var allocator: ContextAllocator = undefined; + _ = allocator; } // constant inside comptime function has compile error // -// tmp.zig:4:5: error: unreachable code -// tmp.zig:4:25: note: control flow is diverted here -// tmp.zig:12:9: error: unused local variable +// :4:5: error: unreachable code +// :4:25: note: control flow is diverted here diff --git a/test/compile_errors/stage2/duplicate-unused_labels.zig b/test/compile_errors/stage2/duplicate-unused_labels.zig new file mode 100644 index 0000000000..82afe4e854 --- /dev/null +++ b/test/compile_errors/stage2/duplicate-unused_labels.zig @@ -0,0 +1,30 @@ +comptime { + blk: { blk: while (false) {} } +} +comptime { + blk: while (false) { blk: for (@as([0]void, undefined)) |_| {} } +} +comptime { + blk: for (@as([0]void, undefined)) |_| { blk: {} } +} +comptime { + blk: {} +} +comptime { + blk: while(false) {} +} +comptime { + blk: for(@as([0]void, undefined)) |_| {} +} + +// duplicate/unused labels +// +// :2:12: error: redefinition of label 'blk' +// :2:5: note: previous definition here +// :5:26: error: redefinition of label 'blk' +// :5:5: note: previous definition here +// :8:46: error: redefinition of label 'blk' +// :8:5: note: previous definition here +// :11:5: error: unused block label +// :14:5: error: unused while loop label +// :17:5: error: unused for loop label |
