Start using the existing test runner
This commit is contained in:
parent
ac95126fce
commit
b28aab2dae
@ -37,6 +37,7 @@ fn runStandalone(allocator: Allocator, args: struct {
|
|||||||
self_hosted: bool,
|
self_hosted: bool,
|
||||||
is_test: bool,
|
is_test: bool,
|
||||||
compiler_path: []const u8,
|
compiler_path: []const u8,
|
||||||
|
repetitions: usize,
|
||||||
}) !void {
|
}) !void {
|
||||||
const test_names = try collectDirectoryDirEntries(allocator, args.directory_path);
|
const test_names = try collectDirectoryDirEntries(allocator, args.directory_path);
|
||||||
|
|
||||||
@ -51,66 +52,68 @@ fn runStandalone(allocator: Allocator, args: struct {
|
|||||||
std.debug.print("\n[{s} START]\n\n", .{args.group_name});
|
std.debug.print("\n[{s} START]\n\n", .{args.group_name});
|
||||||
|
|
||||||
for (test_names) |test_name| {
|
for (test_names) |test_name| {
|
||||||
std.debug.print("{s}... ", .{test_name});
|
std.debug.print("{s} [repetitions={}]\n\n", .{test_name, args.repetitions});
|
||||||
const source_file_path = try std.mem.concat(allocator, u8, &.{ args.directory_path, "/", test_name, "/main.nat" });
|
for (0..args.repetitions) |_| {
|
||||||
const argv: []const []const u8 = &.{ args.compiler_path, if (args.is_test) "test" else "exe", "-main_source_file", source_file_path };
|
const source_file_path = try std.mem.concat(allocator, u8, &.{ args.directory_path, "/", test_name, "/main.nat" });
|
||||||
// if (std.mem.eql(u8, args.compiler_path, "nat/compiler_lightly_optimize_for_speed")) @breakpoint();
|
const argv: []const []const u8 = &.{ args.compiler_path, if (args.is_test) "test" else "exe", "-main_source_file", source_file_path };
|
||||||
const compile_run = try std.ChildProcess.run(.{
|
// if (std.mem.eql(u8, args.compiler_path, "nat/compiler_lightly_optimize_for_speed")) @breakpoint();
|
||||||
.allocator = allocator,
|
const compile_run = try std.ChildProcess.run(.{
|
||||||
// TODO: delete -main_source_file?
|
|
||||||
.argv = argv,
|
|
||||||
.max_output_bytes = std.math.maxInt(u64),
|
|
||||||
});
|
|
||||||
ran_compilation_count += 1;
|
|
||||||
|
|
||||||
const compilation_result: TestError!bool = switch (compile_run.term) {
|
|
||||||
.Exited => |exit_code| if (exit_code == 0) true else error.abnormal_exit_code,
|
|
||||||
.Signal => error.signaled,
|
|
||||||
.Stopped => error.stopped,
|
|
||||||
.Unknown => error.unknown,
|
|
||||||
};
|
|
||||||
|
|
||||||
const compilation_success = compilation_result catch b: {
|
|
||||||
failed_compilation_count += 1;
|
|
||||||
break :b false;
|
|
||||||
};
|
|
||||||
|
|
||||||
std.debug.print("[COMPILATION {s}] ", .{if (compilation_success) "\x1b[32mOK\x1b[0m" else "\x1b[31mFAILED\x1b[0m"});
|
|
||||||
if (compile_run.stdout.len > 0) {
|
|
||||||
std.debug.print("STDOUT:\n\n{s}\n\n", .{compile_run.stdout});
|
|
||||||
}
|
|
||||||
if (compile_run.stderr.len > 0) {
|
|
||||||
std.debug.print("STDERR:\n\n{s}\n\n", .{compile_run.stderr});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (compilation_success and !args.self_hosted) {
|
|
||||||
const test_path = try std.mem.concat(allocator, u8, &.{ "nat/", test_name });
|
|
||||||
const test_run = try std.ChildProcess.run(.{
|
|
||||||
.allocator = allocator,
|
.allocator = allocator,
|
||||||
.argv = &.{test_path},
|
// TODO: delete -main_source_file?
|
||||||
|
.argv = argv,
|
||||||
.max_output_bytes = std.math.maxInt(u64),
|
.max_output_bytes = std.math.maxInt(u64),
|
||||||
});
|
});
|
||||||
ran_test_count += 1;
|
ran_compilation_count += 1;
|
||||||
const test_result: TestError!bool = switch (test_run.term) {
|
|
||||||
|
const compilation_result: TestError!bool = switch (compile_run.term) {
|
||||||
.Exited => |exit_code| if (exit_code == 0) true else error.abnormal_exit_code,
|
.Exited => |exit_code| if (exit_code == 0) true else error.abnormal_exit_code,
|
||||||
.Signal => error.signaled,
|
.Signal => error.signaled,
|
||||||
.Stopped => error.stopped,
|
.Stopped => error.stopped,
|
||||||
.Unknown => error.unknown,
|
.Unknown => error.unknown,
|
||||||
};
|
};
|
||||||
|
|
||||||
const test_success = test_result catch b: {
|
const compilation_success = compilation_result catch b: {
|
||||||
failed_test_count += 1;
|
failed_compilation_count += 1;
|
||||||
break :b false;
|
break :b false;
|
||||||
};
|
};
|
||||||
std.debug.print("[TEST {s}]\n", .{if (test_success) "\x1b[32mOK\x1b[0m" else "\x1b[31mFAILED\x1b[0m"});
|
|
||||||
if (test_run.stdout.len > 0) {
|
std.debug.print("[COMPILATION {s}] ", .{if (compilation_success) "\x1b[32mOK\x1b[0m" else "\x1b[31mFAILED\x1b[0m"});
|
||||||
std.debug.print("STDOUT:\n\n{s}\n\n", .{test_run.stdout});
|
if (compile_run.stdout.len > 0) {
|
||||||
|
std.debug.print("STDOUT:\n\n{s}\n\n", .{compile_run.stdout});
|
||||||
}
|
}
|
||||||
if (test_run.stderr.len > 0) {
|
if (compile_run.stderr.len > 0) {
|
||||||
std.debug.print("STDERR:\n\n{s}\n\n", .{test_run.stderr});
|
std.debug.print("STDERR:\n\n{s}\n\n", .{compile_run.stderr});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (compilation_success and !args.self_hosted) {
|
||||||
|
const test_path = try std.mem.concat(allocator, u8, &.{ "nat/", test_name });
|
||||||
|
const test_run = try std.ChildProcess.run(.{
|
||||||
|
.allocator = allocator,
|
||||||
|
.argv = &.{test_path},
|
||||||
|
.max_output_bytes = std.math.maxInt(u64),
|
||||||
|
});
|
||||||
|
ran_test_count += 1;
|
||||||
|
const test_result: TestError!bool = switch (test_run.term) {
|
||||||
|
.Exited => |exit_code| if (exit_code == 0) true else error.abnormal_exit_code,
|
||||||
|
.Signal => error.signaled,
|
||||||
|
.Stopped => error.stopped,
|
||||||
|
.Unknown => error.unknown,
|
||||||
|
};
|
||||||
|
|
||||||
|
const test_success = test_result catch b: {
|
||||||
|
failed_test_count += 1;
|
||||||
|
break :b false;
|
||||||
|
};
|
||||||
|
std.debug.print("[TEST {s}]\n", .{if (test_success) "\x1b[32mOK\x1b[0m" else "\x1b[31mFAILED\x1b[0m"});
|
||||||
|
if (test_run.stdout.len > 0) {
|
||||||
|
std.debug.print("STDOUT:\n\n{s}\n\n", .{test_run.stdout});
|
||||||
|
}
|
||||||
|
if (test_run.stderr.len > 0) {
|
||||||
|
std.debug.print("STDERR:\n\n{s}\n\n", .{test_run.stderr});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
std.debug.print("\n", .{});
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
std.debug.print("\n", .{});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -583,30 +586,41 @@ pub fn main() !void {
|
|||||||
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
|
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
|
||||||
const allocator = arena.allocator();
|
const allocator = arena.allocator();
|
||||||
|
|
||||||
var errors = run_test_suite(allocator, .{
|
try runStandalone(allocator, .{
|
||||||
.self_hosted = false,
|
.is_test = false,
|
||||||
.compiler_path = bootstrap_relative_path,
|
.compiler_path = bootstrap_relative_path,
|
||||||
|
.self_hosted = false,
|
||||||
|
.group_name = "STANDALONE",
|
||||||
|
.directory_path = "retest/standalone",
|
||||||
|
.repetitions = 100,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!errors) {
|
// var errors = run_test_suite(allocator, .{
|
||||||
inline for (@typeInfo(Optimization).Enum.fields) |opt| {
|
// .self_hosted = false,
|
||||||
const optimization = @field(Optimization, opt.name);
|
// .compiler_path = bootstrap_relative_path,
|
||||||
if (compile_self_hosted(allocator, .{
|
// });
|
||||||
.is_test = false,
|
//
|
||||||
.optimization = optimization,
|
// if (!errors) {
|
||||||
})) |compiler_path| {
|
// inline for (@typeInfo(Optimization).Enum.fields) |opt| {
|
||||||
errors = errors or run_test_suite(allocator, .{
|
// const optimization = @field(Optimization, opt.name);
|
||||||
.self_hosted = true,
|
// if (compile_self_hosted(allocator, .{
|
||||||
.compiler_path = compiler_path,
|
// .is_test = false,
|
||||||
});
|
// .optimization = optimization,
|
||||||
} else |err| {
|
// })) |compiler_path| {
|
||||||
err catch {};
|
// errors = errors or run_test_suite(allocator, .{
|
||||||
errors = true;
|
// .self_hosted = true,
|
||||||
}
|
// .compiler_path = compiler_path,
|
||||||
}
|
// });
|
||||||
}
|
// } else |err| {
|
||||||
|
// err catch {};
|
||||||
if (errors) {
|
// errors = true;
|
||||||
return error.fail;
|
// }
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (errors) {
|
||||||
|
// return error.fail;
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -14,11 +14,7 @@ download_zig master x86_64-linux
|
|||||||
|
|
||||||
# Build and test
|
# Build and test
|
||||||
|
|
||||||
i=$((0))
|
zig build test -Dthird_party_ci=true -Doptimize=Debug
|
||||||
while ((i < 1000)); do
|
zig build test -Dthird_party_ci=true -Doptimize=ReleaseSafe
|
||||||
zig build run -Dthird_party_ci=true -Dprint_stack_trace=true -Doptimize=Debug -- exe -main_source_file retest/standalone/first/main.nat
|
zig build test -Dthird_party_ci=true -Doptimize=ReleaseSmall
|
||||||
zig build run -Dthird_party_ci=true -Dprint_stack_trace=true -Doptimize=ReleaseSafe -- exe -main_source_file retest/standalone/first/main.nat
|
zig build test -Dthird_party_ci=true -Doptimize=ReleaseFast
|
||||||
zig build run -Dthird_party_ci=true -Dprint_stack_trace=true -Doptimize=ReleaseSmall -- exe -main_source_file retest/standalone/first/main.nat
|
|
||||||
zig build run -Dthird_party_ci=true -Dprint_stack_trace=true -Doptimize=ReleaseFast -- exe -main_source_file retest/standalone/first/main.nat
|
|
||||||
i=$((i + 1))
|
|
||||||
done
|
|
||||||
|
@ -10,11 +10,7 @@ source ci/download_zig.sh
|
|||||||
download_zig master aarch64-macos
|
download_zig master aarch64-macos
|
||||||
|
|
||||||
# Build and test
|
# Build and test
|
||||||
i=$((0))
|
zig build test -Dthird_party_ci=true -Doptimize=Debug
|
||||||
while ((i < 1000)); do
|
zig build test -Dthird_party_ci=true -Doptimize=ReleaseSafe
|
||||||
zig build run -Dprint_stack_trace=true -Doptimize=Debug -- exe -main_source_file retest/standalone/first/main.nat
|
zig build test -Dthird_party_ci=true -Doptimize=ReleaseSmall
|
||||||
zig build run -Dprint_stack_trace=true -Doptimize=ReleaseSafe -- exe -main_source_file retest/standalone/first/main.nat
|
zig build test -Dthird_party_ci=true -Doptimize=ReleaseFast
|
||||||
zig build run -Dprint_stack_trace=true -Doptimize=ReleaseSmall -- exe -main_source_file retest/standalone/first/main.nat
|
|
||||||
zig build run -Dprint_stack_trace=true -Doptimize=ReleaseFast -- exe -main_source_file retest/standalone/first/main.nat
|
|
||||||
i=$((i + 1))
|
|
||||||
done
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user