stage2: use stage1 test runner for stage2

This commit is contained in:
Veikka Tuominen 2022-02-27 11:48:42 +02:00
parent 593d23c0d7
commit 950d840be6
5 changed files with 50 additions and 32 deletions

View File

@ -269,7 +269,12 @@ fn refreshWithHeldLock(self: *Progress) void {
}
if (eti > 0) {
if (need_ellipse) self.bufWrite(&end, " ", .{});
self.bufWrite(&end, "[{d}/{d}] ", .{ current_item, eti });
if (builtin.zig_backend == .stage2_llvm) {
self.bufWrite(&end, "[{d}/ ", .{current_item});
self.bufWrite(&end, "{d}] ", .{eti});
} else {
self.bufWrite(&end, "[{d}/{d}] ", .{ current_item, eti });
}
need_ellipse = false;
} else if (completed_items != 0) {
if (need_ellipse) self.bufWrite(&end, " ", .{});
@ -284,9 +289,10 @@ fn refreshWithHeldLock(self: *Progress) void {
}
}
_ = file.write(self.output_buffer[0..end]) catch {
_ = file.write(self.output_buffer[0..end]) catch blk: {
// Stop trying to write to this file once it errors.
self.terminal = null;
break :blk 0; // TODO stage2 requires this
};
if (self.timer) |*timer| {
self.prev_refresh_timestamp = timer.read();

View File

@ -871,7 +871,7 @@ var vdso_clock_gettime = @ptrCast(?*const anyopaque, init_vdso_clock_gettime);
const vdso_clock_gettime_ty = fn (i32, *timespec) callconv(.C) usize;
pub fn clock_gettime(clk_id: i32, tp: *timespec) usize {
if (@hasDecl(VDSO, "CGT_SYM")) {
if (@hasDecl(VDSO, "CGT_SYM") and builtin.zig_backend == .stage1) {
const ptr = @atomicLoad(?*const anyopaque, &vdso_clock_gettime, .Unordered);
if (ptr) |fn_ptr| {
const f = @ptrCast(vdso_clock_gettime_ty, fn_ptr);

View File

@ -23,10 +23,12 @@ fn processArgs() void {
}
pub fn main() void {
if (builtin.zig_backend != .stage1) {
if (builtin.zig_backend != .stage1 and
builtin.zig_backend != .stage2_llvm)
{
return main2() catch @panic("test failure");
}
processArgs();
if (builtin.zig_backend == .stage1) processArgs();
const test_fn_list = builtin.test_functions;
var ok_count: usize = 0;
var skip_count: usize = 0;
@ -44,9 +46,9 @@ pub fn main() void {
var leaks: usize = 0;
for (test_fn_list) |test_fn, i| {
std.testing.allocator_instance = .{};
if (builtin.zig_backend != .stage2_llvm) std.testing.allocator_instance = .{};
defer {
if (std.testing.allocator_instance.deinit()) {
if (builtin.zig_backend != .stage2_llvm and std.testing.allocator_instance.deinit()) {
leaks += 1;
}
}
@ -56,9 +58,17 @@ pub fn main() void {
test_node.activate();
progress.refresh();
if (!have_tty) {
std.debug.print("{d}/{d} {s}... ", .{ i + 1, test_fn_list.len, test_fn.name });
if (builtin.zig_backend == .stage2_llvm) {
std.debug.print("{d}/", .{i + 1});
std.debug.print("{d} ", .{test_fn_list.len});
std.debug.print("{s}... ", .{test_fn.name});
} else {
std.debug.print("{d}/{d} {s}... ", .{ i + 1, test_fn_list.len, test_fn.name });
}
}
const result = if (test_fn.async_frame_size) |size| switch (io_mode) {
const result = if (builtin.zig_backend == .stage2_llvm)
test_fn.func()
else if (test_fn.async_frame_size) |size| switch (io_mode) {
.evented => blk: {
if (async_frame_buffer.len < size) {
std.heap.page_allocator.free(async_frame_buffer);
@ -90,9 +100,9 @@ pub fn main() void {
fail_count += 1;
progress.log("FAIL ({s})\n", .{@errorName(err)});
if (!have_tty) std.debug.print("FAIL ({s})\n", .{@errorName(err)});
if (@errorReturnTrace()) |trace| {
if (builtin.zig_backend != .stage2_llvm) if (@errorReturnTrace()) |trace| {
std.debug.dumpStackTrace(trace.*);
}
};
test_node.end();
},
}
@ -101,7 +111,13 @@ pub fn main() void {
if (ok_count == test_fn_list.len) {
std.debug.print("All {d} tests passed.\n", .{ok_count});
} else {
std.debug.print("{d} passed; {d} skipped; {d} failed.\n", .{ ok_count, skip_count, fail_count });
if (builtin.zig_backend == .stage2_llvm) {
std.debug.print("{d} passed; ", .{ok_count});
std.debug.print("{d} skipped; ", .{skip_count});
std.debug.print("{d} failed.\n", .{fail_count});
} else {
std.debug.print("{d} passed; {d} skipped; {d} failed.\n", .{ ok_count, skip_count, fail_count });
}
}
if (log_err_count != 0) {
std.debug.print("{d} errors were logged.\n", .{log_err_count});
@ -141,20 +157,7 @@ pub fn main2() anyerror!void {
}
};
}
if (builtin.zig_backend == .stage2_llvm) {
const stderr = std.io.getStdErr().writer();
const ok_count = builtin.test_functions.len - skipped - failed;
if (ok_count == builtin.test_functions.len) {
try stderr.print("All {d} tests passed.\n", .{ok_count});
} else {
try stderr.print("{d} passed; ", .{ok_count});
try stderr.print("{d} skipped; ", .{skipped});
try stderr.print("{d} failed.\n", .{failed});
}
if (failed != 0) {
std.process.exit(1);
}
} else if (builtin.zig_backend == .stage2_wasm or
if (builtin.zig_backend == .stage2_wasm or
builtin.zig_backend == .stage2_x86_64)
{
const passed = builtin.test_functions.len - skipped - failed;

View File

@ -3762,7 +3762,7 @@ fn semaDecl(mod: *Module, decl: *Decl) !bool {
// Note this resolves the type of the Decl, not the value; if this Decl
// is a struct, for example, this resolves `type` (which needs no resolution),
// not the struct itself.
try sema.resolveTypeLayout(&block_scope, src, decl_tv.ty);
try sema.resolveTypeFully(&block_scope, src, decl_tv.ty);
const decl_arena_state = try decl_arena_allocator.create(std.heap.ArenaAllocator.State);

View File

@ -11947,19 +11947,27 @@ fn zirReify(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I
var buffer: Value.ToTypeBuffer = undefined;
const child_ty = child_val.toType(&buffer);
const ptr_size = size_val.toEnum(std.builtin.TypeInfo.Pointer.Size);
var actual_sentinel: ?Value = null;
if (!sentinel_val.isNull()) {
return sema.fail(block, src, "TODO: implement zirReify for pointer with non-null sentinel", .{});
if (ptr_size == .One or ptr_size == .C) {
return sema.fail(block, src, "sentinels are only allowed on slices and unknown-length pointers", .{});
}
const sentinel_ptr_val = sentinel_val.castTag(.opt_payload).?.data;
const ptr_ty = try Type.ptr(sema.arena, .{ .@"addrspace" = .generic, .pointee_type = child_ty });
actual_sentinel = (try sema.pointerDeref(block, src, sentinel_ptr_val, ptr_ty)).?;
}
const ty = try Type.ptr(sema.arena, .{
.size = size_val.toEnum(std.builtin.TypeInfo.Pointer.Size),
.size = ptr_size,
.mutable = !is_const_val.toBool(),
.@"volatile" = is_volatile_val.toBool(),
.@"align" = @intCast(u8, alignment_val.toUnsignedInt()), // TODO: Validate this value.
.@"addrspace" = address_space_val.toEnum(std.builtin.AddressSpace),
.pointee_type = try child_ty.copy(sema.arena),
.@"allowzero" = is_allowzero_val.toBool(),
.sentinel = null,
.sentinel = actual_sentinel,
});
return sema.addType(ty);
},
@ -12069,6 +12077,7 @@ fn zirIntToPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
const type_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
const type_res = try sema.resolveType(block, src, extra.lhs);
try sema.checkPtrType(block, type_src, type_res);
_ = try sema.resolveTypeLayout(block, src, type_res.childType());
const ptr_align = type_res.ptrAlignment(sema.mod.getTarget());
if (try sema.resolveDefinedValue(block, operand_src, operand_coerced)) |val| {
@ -17586,7 +17595,7 @@ fn resolvePeerTypes(
return chosen_ty;
}
pub fn resolveTypeLayout(
fn resolveTypeLayout(
sema: *Sema,
block: *Block,
src: LazySrcLoc,
@ -17659,7 +17668,7 @@ fn resolveUnionLayout(
union_obj.status = .have_layout;
}
fn resolveTypeFully(
pub fn resolveTypeFully(
sema: *Sema,
block: *Block,
src: LazySrcLoc,