re-enable stage2 tests
This commit is contained in:
parent
6c64f079fa
commit
b9ef36094c
10
build.zig
10
build.zig
@ -54,6 +54,7 @@ pub fn build(b: *Builder) !void {
|
||||
|
||||
var test_stage2 = b.addTest("src-self-hosted/test.zig");
|
||||
test_stage2.setBuildMode(builtin.Mode.Debug);
|
||||
test_stage2.addPackagePath("stage2_tests", "test/stage2/test.zig");
|
||||
|
||||
const fmt_build_zig = b.addFmt([_][]const u8{"build.zig"});
|
||||
|
||||
@ -73,8 +74,7 @@ pub fn build(b: *Builder) !void {
|
||||
const skip_libc = b.option(bool, "skip-libc", "Main test suite skips tests that link libc") orelse false;
|
||||
const skip_self_hosted = b.option(bool, "skip-self-hosted", "Main test suite skips building self hosted compiler") orelse false;
|
||||
if (!skip_self_hosted) {
|
||||
// TODO re-enable this after https://github.com/ziglang/zig/issues/2377
|
||||
//test_step.dependOn(&exe.step);
|
||||
test_step.dependOn(&exe.step);
|
||||
}
|
||||
|
||||
const only_install_lib_files = b.option(bool, "lib-files-only", "Only install library files") orelse false;
|
||||
@ -98,11 +98,7 @@ pub fn build(b: *Builder) !void {
|
||||
|
||||
const test_stage2_step = b.step("test-stage2", "Run the stage2 compiler tests");
|
||||
test_stage2_step.dependOn(&test_stage2.step);
|
||||
|
||||
// TODO see https://github.com/ziglang/zig/issues/1364
|
||||
if (false) {
|
||||
test_step.dependOn(test_stage2_step);
|
||||
}
|
||||
test_step.dependOn(test_stage2_step);
|
||||
|
||||
var chosen_modes: [4]builtin.Mode = undefined;
|
||||
var chosen_mode_index: usize = 0;
|
||||
|
@ -66,11 +66,10 @@ pub fn Group(comptime ReturnType: type) type {
|
||||
node.* = AllocStack.Node{
|
||||
.next = undefined,
|
||||
.data = Node{
|
||||
.handle = frame,
|
||||
.bytes = @sliceToBytes((*[1]@Frame(func))(frame)[0..]),
|
||||
.handle = @asyncCall(frame, {}, func, args),
|
||||
.bytes = std.mem.asBytes(frame),
|
||||
},
|
||||
};
|
||||
frame.* = async func(args);
|
||||
self.alloc_stack.push(node);
|
||||
}
|
||||
|
||||
|
@ -10,13 +10,15 @@ const ZigCompiler = @import("compilation.zig").ZigCompiler;
|
||||
var ctx: TestContext = undefined;
|
||||
|
||||
test "stage2" {
|
||||
// TODO provide a way to run tests in evented I/O mode
|
||||
if (!std.io.is_async) return error.SkipZigTest;
|
||||
|
||||
try ctx.init();
|
||||
defer ctx.deinit();
|
||||
|
||||
try @import("../test/stage2/compile_errors.zig").addCases(&ctx);
|
||||
try @import("../test/stage2/compare_output.zig").addCases(&ctx);
|
||||
try @import("stage2_tests").addCases(&ctx);
|
||||
|
||||
async ctx.run();
|
||||
_ = async ctx.run();
|
||||
}
|
||||
|
||||
const file1 = "1.zig";
|
||||
@ -40,7 +42,7 @@ pub const TestContext = struct {
|
||||
.file_index = std.atomic.Int(usize).init(0),
|
||||
};
|
||||
|
||||
self.zig_compiler = try ZigCompiler.init();
|
||||
self.zig_compiler = try ZigCompiler.init(allocator);
|
||||
errdefer self.zig_compiler.deinit();
|
||||
|
||||
self.group = std.event.Group(anyerror!void).init(allocator);
|
||||
@ -75,7 +77,7 @@ pub const TestContext = struct {
|
||||
) !void {
|
||||
var file_index_buf: [20]u8 = undefined;
|
||||
const file_index = try std.fmt.bufPrint(file_index_buf[0..], "{}", self.file_index.incr());
|
||||
const file1_path = try std.fs.path.join(allocator, [][]const u8{ tmp_dir_name, file_index, file1 });
|
||||
const file1_path = try std.fs.path.join(allocator, [_][]const u8{ tmp_dir_name, file_index, file1 });
|
||||
|
||||
if (std.fs.path.dirname(file1_path)) |dirname| {
|
||||
try std.fs.makePath(allocator, dirname);
|
||||
@ -108,9 +110,9 @@ pub const TestContext = struct {
|
||||
) !void {
|
||||
var file_index_buf: [20]u8 = undefined;
|
||||
const file_index = try std.fmt.bufPrint(file_index_buf[0..], "{}", self.file_index.incr());
|
||||
const file1_path = try std.fs.path.join(allocator, [][]const u8{ tmp_dir_name, file_index, file1 });
|
||||
const file1_path = try std.fs.path.join(allocator, [_][]const u8{ tmp_dir_name, file_index, file1 });
|
||||
|
||||
const output_file = try std.fmt.allocPrint(allocator, "{}-out{}", file1_path, Target(Target.Native).exeFileExt());
|
||||
const output_file = try std.fmt.allocPrint(allocator, "{}-out{}", file1_path, (Target{.Native = {}}).exeFileExt());
|
||||
if (std.fs.path.dirname(file1_path)) |dirname| {
|
||||
try std.fs.makePath(allocator, dirname);
|
||||
}
|
||||
@ -141,7 +143,7 @@ pub const TestContext = struct {
|
||||
comp: *Compilation,
|
||||
exe_file: []const u8,
|
||||
expected_output: []const u8,
|
||||
) !void {
|
||||
) anyerror!void {
|
||||
// TODO this should not be necessary
|
||||
const exe_file_2 = try std.mem.dupe(allocator, u8, exe_file);
|
||||
|
||||
@ -150,7 +152,7 @@ pub const TestContext = struct {
|
||||
|
||||
switch (build_event) {
|
||||
.Ok => {
|
||||
const argv = []const []const u8{exe_file_2};
|
||||
const argv = [_][]const u8{exe_file_2};
|
||||
// TODO use event loop
|
||||
const child = try std.ChildProcess.exec(allocator, argv, null, null, 1024 * 1024);
|
||||
switch (child.term) {
|
||||
@ -186,7 +188,7 @@ pub const TestContext = struct {
|
||||
line: usize,
|
||||
column: usize,
|
||||
text: []const u8,
|
||||
) !void {
|
||||
) anyerror!void {
|
||||
defer comp.destroy();
|
||||
const build_event = comp.events.get();
|
||||
|
||||
|
6
test/stage2/test.zig
Normal file
6
test/stage2/test.zig
Normal file
@ -0,0 +1,6 @@
|
||||
const TestContext = @import("../../src-self-hosted/test.zig").TestContext;
|
||||
|
||||
pub fn addCases(ctx: *TestContext) !void {
|
||||
try @import("compile_errors.zig").addCases(ctx);
|
||||
try @import("compare_output.zig").addCases(ctx);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user