diff --git a/src/test.zig b/src/test.zig index 2f3389d7ff..8ede838a5e 100644 --- a/src/test.zig +++ b/src/test.zig @@ -1012,18 +1012,18 @@ pub const TestContext = struct { ) !void { var cases = std.ArrayList(usize).init(ctx.arena); - var it = dir.iterate(); + var it = try dir.walk(ctx.arena); var filenames = std.ArrayList([]const u8).init(ctx.arena); while (try it.next()) |entry| { if (entry.kind != .File) continue; // Ignore stuff such as .swp files - switch (Compilation.classifyFileExt(entry.name)) { + switch (Compilation.classifyFileExt(entry.basename)) { .unknown => continue, else => {}, } - try filenames.append(try ctx.arena.dupe(u8, entry.name)); + try filenames.append(try ctx.arena.dupe(u8, entry.path)); } // Sort filenames, so that incremental tests are contiguous and in-order diff --git a/test/behavior.zig b/test/behavior.zig index 828a56a81f..4d8b3587bc 100644 --- a/test/behavior.zig +++ b/test/behavior.zig @@ -69,8 +69,10 @@ test { _ = @import("behavior/bugs/7003.zig"); _ = @import("behavior/bugs/7027.zig"); _ = @import("behavior/bugs/7047.zig"); + _ = @import("behavior/bugs/7187.zig"); _ = @import("behavior/bugs/7250.zig"); _ = @import("behavior/bugs/9584.zig"); + _ = @import("behavior/bugs/10138.zig"); _ = @import("behavior/bugs/10147.zig"); _ = @import("behavior/bugs/10970.zig"); _ = @import("behavior/bugs/11046.zig"); diff --git a/test/incremental/issue_10138_callee_preserved_regs_working_x86_64_linux.zig b/test/behavior/bugs/10138.zig similarity index 54% rename from test/incremental/issue_10138_callee_preserved_regs_working_x86_64_linux.zig rename to test/behavior/bugs/10138.zig index 4c045496da..88dc5acde7 100644 --- a/test/incremental/issue_10138_callee_preserved_regs_working_x86_64_linux.zig +++ b/test/behavior/bugs/10138.zig @@ -1,4 +1,11 @@ -pub fn main() void { +const std = @import("std"); +const builtin = @import("builtin"); + +test "registers get overwritten when ignoring return" { + if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; + if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; + if (builtin.cpu.arch != .x86_64 or builtin.os.tag != .linux) return error.SkipZigTest; + const fd = open(); _ = write(fd, "a", 1); _ = close(fd); @@ -25,7 +32,3 @@ fn close(fd: usize) usize { unreachable; return 0; } - -// run -// target=x86_64-linux -// diff --git a/test/behavior/bugs/7187.zig b/test/behavior/bugs/7187.zig new file mode 100644 index 0000000000..86f5aa6706 --- /dev/null +++ b/test/behavior/bugs/7187.zig @@ -0,0 +1,18 @@ +const std = @import("std"); +const builtin = @import("builtin"); +const expect = std.testing.expect; + +test "miscompilation with bool return type" { + if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; + if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; + + var x: usize = 1; + var y: bool = getFalse(); + _ = y; + + try expect(x == 1); +} + +fn getFalse() bool { + return false; +} diff --git a/test/incremental/access_slice_element_by_index_slice_elem_val.zig b/test/incremental/access_slice_element_by_index_slice_elem_val.zig deleted file mode 100644 index a0bdae0826..0000000000 --- a/test/incremental/access_slice_element_by_index_slice_elem_val.zig +++ /dev/null @@ -1,17 +0,0 @@ -var array = [_]usize{ 0, 42, 123, 34 }; -var slice: []const usize = &array; - -pub fn main() void { - assert(slice[0] == 0); - assert(slice[1] == 42); - assert(slice[2] == 123); - assert(slice[3] == 34); -} - -fn assert(ok: bool) void { - if (!ok) unreachable; -} - -// run -// target=x86_64-linux,x86_64-macos -// diff --git a/test/incremental/issue_7187_miscompilation_with_bool_return_type.zig b/test/incremental/issue_7187_miscompilation_with_bool_return_type.zig deleted file mode 100644 index 3aed8685bf..0000000000 --- a/test/incremental/issue_7187_miscompilation_with_bool_return_type.zig +++ /dev/null @@ -1,18 +0,0 @@ -pub fn main() void { - var x: usize = 1; - var y: bool = getFalse(); - _ = y; - - assert(x == 1); -} - -fn getFalse() bool { - return false; -} - -fn assert(ok: bool) void { - if (!ok) unreachable; -} - -// run -// diff --git a/test/incremental/load_store_via_pointer_deref.0.zig b/test/incremental/load_store_via_pointer_deref.0.zig deleted file mode 100644 index 96aedf3196..0000000000 --- a/test/incremental/load_store_via_pointer_deref.0.zig +++ /dev/null @@ -1,16 +0,0 @@ -pub fn main() void { - var x: u32 = undefined; - set(&x); - assert(x == 123); -} - -fn set(x: *u32) void { - x.* = 123; -} - -fn assert(ok: bool) void { - if (!ok) unreachable; -} - -// run -// diff --git a/test/incremental/load_store_via_pointer_deref.1.zig b/test/incremental/load_store_via_pointer_deref.1.zig deleted file mode 100644 index e311092744..0000000000 --- a/test/incremental/load_store_via_pointer_deref.1.zig +++ /dev/null @@ -1,16 +0,0 @@ -pub fn main() void { - var x: u16 = undefined; - set(&x); - assert(x == 123); -} - -fn set(x: *u16) void { - x.* = 123; -} - -fn assert(ok: bool) void { - if (!ok) unreachable; -} - -// run -// diff --git a/test/incremental/load_store_via_pointer_deref.2.zig b/test/incremental/load_store_via_pointer_deref.2.zig deleted file mode 100644 index 3b1484faa1..0000000000 --- a/test/incremental/load_store_via_pointer_deref.2.zig +++ /dev/null @@ -1,16 +0,0 @@ -pub fn main() void { - var x: u8 = undefined; - set(&x); - assert(x == 123); -} - -fn set(x: *u8) void { - x.* = 123; -} - -fn assert(ok: bool) void { - if (!ok) unreachable; -} - -// run -// diff --git a/test/incremental/saving_vars_of_different_abi_size_to_stack.0.zig b/test/incremental/saving_vars_of_different_abi_size_to_stack.0.zig deleted file mode 100644 index 6134622a0e..0000000000 --- a/test/incremental/saving_vars_of_different_abi_size_to_stack.0.zig +++ /dev/null @@ -1,16 +0,0 @@ -pub fn main() void { - assert(callMe(2) == 24); -} - -fn callMe(a: u8) u8 { - var b: u8 = a + 10; - const c = 2 * b; - return c; -} - -pub fn assert(ok: bool) void { - if (!ok) unreachable; // assertion failure -} - -// run -// diff --git a/test/incremental/saving_vars_of_different_abi_size_to_stack.1.zig b/test/incremental/saving_vars_of_different_abi_size_to_stack.1.zig deleted file mode 100644 index 4d87d7b9c5..0000000000 --- a/test/incremental/saving_vars_of_different_abi_size_to_stack.1.zig +++ /dev/null @@ -1,16 +0,0 @@ -pub fn main() void { - assert(callMe(2) == 24); -} - -fn callMe(a: u16) u16 { - var b: u16 = a + 10; - const c = 2 * b; - return c; -} - -pub fn assert(ok: bool) void { - if (!ok) unreachable; // assertion failure -} - -// run -// diff --git a/test/incremental/saving_vars_of_different_abi_size_to_stack.2.zig b/test/incremental/saving_vars_of_different_abi_size_to_stack.2.zig deleted file mode 100644 index b665227962..0000000000 --- a/test/incremental/saving_vars_of_different_abi_size_to_stack.2.zig +++ /dev/null @@ -1,16 +0,0 @@ -pub fn main() void { - assert(callMe(2) == 24); -} - -fn callMe(a: u32) u32 { - var b: u32 = a + 10; - const c = 2 * b; - return c; -} - -pub fn assert(ok: bool) void { - if (!ok) unreachable; // assertion failure -} - -// run -// diff --git a/test/incremental/subtracting_numbers_at_runtime.zig b/test/incremental/subtracting_numbers_at_runtime.zig deleted file mode 100644 index 5ea81a34b8..0000000000 --- a/test/incremental/subtracting_numbers_at_runtime.zig +++ /dev/null @@ -1,10 +0,0 @@ -pub fn main() void { - sub(7, 4); -} - -fn sub(a: u32, b: u32) void { - if (a - b != 3) unreachable; -} - -// run -// diff --git a/test/incremental/unwrap_error_union_simple_errors.0.zig b/test/incremental/unwrap_error_union_simple_errors.0.zig deleted file mode 100644 index a1e2da9340..0000000000 --- a/test/incremental/unwrap_error_union_simple_errors.0.zig +++ /dev/null @@ -1,10 +0,0 @@ -pub fn main() void { - maybeErr() catch unreachable; -} - -fn maybeErr() !void { - return; -} - -// run -// diff --git a/test/incremental/unwrap_error_union_simple_errors.1.zig b/test/incremental/unwrap_error_union_simple_errors.1.zig deleted file mode 100644 index 830ee629bc..0000000000 --- a/test/incremental/unwrap_error_union_simple_errors.1.zig +++ /dev/null @@ -1,11 +0,0 @@ -pub fn main() void { - maybeErr() catch return; - unreachable; -} - -fn maybeErr() !void { - return error.NoWay; -} - -// run -// diff --git a/test/incremental/hello_world_with_updates_x86_64_linux.0.zig b/test/incremental/x86_64-linux/hello_world_with_updates.0.zig similarity index 100% rename from test/incremental/hello_world_with_updates_x86_64_linux.0.zig rename to test/incremental/x86_64-linux/hello_world_with_updates.0.zig diff --git a/test/incremental/hello_world_with_updates_x86_64_linux.1.zig b/test/incremental/x86_64-linux/hello_world_with_updates.1.zig similarity index 100% rename from test/incremental/hello_world_with_updates_x86_64_linux.1.zig rename to test/incremental/x86_64-linux/hello_world_with_updates.1.zig diff --git a/test/incremental/hello_world_with_updates_x86_64_linux.2.zig b/test/incremental/x86_64-linux/hello_world_with_updates.2.zig similarity index 100% rename from test/incremental/hello_world_with_updates_x86_64_linux.2.zig rename to test/incremental/x86_64-linux/hello_world_with_updates.2.zig diff --git a/test/incremental/hello_world_with_updates_x86_64_linux.3.zig b/test/incremental/x86_64-linux/hello_world_with_updates.3.zig similarity index 100% rename from test/incremental/hello_world_with_updates_x86_64_linux.3.zig rename to test/incremental/x86_64-linux/hello_world_with_updates.3.zig diff --git a/test/incremental/hello_world_with_updates_x86_64_linux.4.zig b/test/incremental/x86_64-linux/hello_world_with_updates.4.zig similarity index 100% rename from test/incremental/hello_world_with_updates_x86_64_linux.4.zig rename to test/incremental/x86_64-linux/hello_world_with_updates.4.zig diff --git a/test/incremental/hello_world_with_updates_x86_64_linux.5.zig b/test/incremental/x86_64-linux/hello_world_with_updates.5.zig similarity index 100% rename from test/incremental/hello_world_with_updates_x86_64_linux.5.zig rename to test/incremental/x86_64-linux/hello_world_with_updates.5.zig diff --git a/test/incremental/inline_assembly_x86_64_linux.0.zig b/test/incremental/x86_64-linux/inline_assembly.0.zig similarity index 100% rename from test/incremental/inline_assembly_x86_64_linux.0.zig rename to test/incremental/x86_64-linux/inline_assembly.0.zig diff --git a/test/incremental/inline_assembly_x86_64_linux.1.zig b/test/incremental/x86_64-linux/inline_assembly.1.zig similarity index 100% rename from test/incremental/inline_assembly_x86_64_linux.1.zig rename to test/incremental/x86_64-linux/inline_assembly.1.zig diff --git a/test/incremental/inline_assembly_x86_64_linux.2.zig b/test/incremental/x86_64-linux/inline_assembly.2.zig similarity index 100% rename from test/incremental/inline_assembly_x86_64_linux.2.zig rename to test/incremental/x86_64-linux/inline_assembly.2.zig diff --git a/test/incremental/inline_assembly_x86_64_linux.3.zig b/test/incremental/x86_64-linux/inline_assembly.3.zig similarity index 100% rename from test/incremental/inline_assembly_x86_64_linux.3.zig rename to test/incremental/x86_64-linux/inline_assembly.3.zig diff --git a/test/incremental/only_1_function_and_it_gets_updated_x86_64_linux.0.zig b/test/incremental/x86_64-linux/only_1_function_and_it_gets_updated.0.zig similarity index 100% rename from test/incremental/only_1_function_and_it_gets_updated_x86_64_linux.0.zig rename to test/incremental/x86_64-linux/only_1_function_and_it_gets_updated.0.zig diff --git a/test/incremental/only_1_function_and_it_gets_updated_x86_64_linux.1.zig b/test/incremental/x86_64-linux/only_1_function_and_it_gets_updated.1.zig similarity index 100% rename from test/incremental/only_1_function_and_it_gets_updated_x86_64_linux.1.zig rename to test/incremental/x86_64-linux/only_1_function_and_it_gets_updated.1.zig diff --git a/test/incremental/hello_world_with_updates_x86_64_macos.0.zig b/test/incremental/x86_64-macos/hello_world_with_updates.0.zig similarity index 100% rename from test/incremental/hello_world_with_updates_x86_64_macos.0.zig rename to test/incremental/x86_64-macos/hello_world_with_updates.0.zig diff --git a/test/incremental/hello_world_with_updates_x86_64_macos.1.zig b/test/incremental/x86_64-macos/hello_world_with_updates.1.zig similarity index 100% rename from test/incremental/hello_world_with_updates_x86_64_macos.1.zig rename to test/incremental/x86_64-macos/hello_world_with_updates.1.zig diff --git a/test/incremental/hello_world_with_updates_x86_64_macos.2.zig b/test/incremental/x86_64-macos/hello_world_with_updates.2.zig similarity index 100% rename from test/incremental/hello_world_with_updates_x86_64_macos.2.zig rename to test/incremental/x86_64-macos/hello_world_with_updates.2.zig diff --git a/test/incremental/hello_world_with_updates_x86_64_macos.3.zig b/test/incremental/x86_64-macos/hello_world_with_updates.3.zig similarity index 100% rename from test/incremental/hello_world_with_updates_x86_64_macos.3.zig rename to test/incremental/x86_64-macos/hello_world_with_updates.3.zig diff --git a/test/incremental/hello_world_with_updates_x86_64_macos.4.zig b/test/incremental/x86_64-macos/hello_world_with_updates.4.zig similarity index 100% rename from test/incremental/hello_world_with_updates_x86_64_macos.4.zig rename to test/incremental/x86_64-macos/hello_world_with_updates.4.zig diff --git a/test/incremental/hello_world_with_updates_x86_64_macos.5.zig b/test/incremental/x86_64-macos/hello_world_with_updates.5.zig similarity index 100% rename from test/incremental/hello_world_with_updates_x86_64_macos.5.zig rename to test/incremental/x86_64-macos/hello_world_with_updates.5.zig diff --git a/test/incremental/hello_world_with_updates_x86_64_macos.6.zig b/test/incremental/x86_64-macos/hello_world_with_updates.6.zig similarity index 100% rename from test/incremental/hello_world_with_updates_x86_64_macos.6.zig rename to test/incremental/x86_64-macos/hello_world_with_updates.6.zig