Rewrite test runner
This commit is contained in:
parent
1ea16f923b
commit
a722eabf6e
87
src/main.zig
87
src/main.zig
@ -100,48 +100,6 @@ fn compile_file(arena: *Arena, compile: Compile) converter.Options {
|
|||||||
|
|
||||||
const base_cache_dir = "bb-cache";
|
const base_cache_dir = "bb-cache";
|
||||||
|
|
||||||
const TestRun = struct {
|
|
||||||
build_mode: BuildMode,
|
|
||||||
has_debug_info: bool,
|
|
||||||
stop_at_failure: bool,
|
|
||||||
};
|
|
||||||
|
|
||||||
// This function is abstracted out so that dumb inline for loops don't inline the code 10x
|
|
||||||
fn run_tests(arena: *Arena, environment: [*:null]const ?[*:0]const u8, names: []const []const u8, test_run: TestRun) void {
|
|
||||||
for (names) |name| {
|
|
||||||
const build_mode = test_run.build_mode;
|
|
||||||
const has_debug_info = test_run.has_debug_info;
|
|
||||||
const stop_at_failure = test_run.has_debug_info;
|
|
||||||
|
|
||||||
const position = arena.position;
|
|
||||||
defer arena.restore(position);
|
|
||||||
|
|
||||||
const relative_file_path = arena.join_string(&.{ "tests/", name, ".bbb" });
|
|
||||||
const compile_result = compile_file(arena, .{
|
|
||||||
.relative_file_path = relative_file_path,
|
|
||||||
.build_mode = build_mode,
|
|
||||||
.has_debug_info = has_debug_info,
|
|
||||||
.silent = true,
|
|
||||||
});
|
|
||||||
|
|
||||||
const result = lib.os.run_child_process(arena, &.{compile_result.executable}, environment, .{
|
|
||||||
.stdout = .pipe,
|
|
||||||
.stderr = .pipe,
|
|
||||||
.null_file_descriptor = null,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!result.is_successful()) {
|
|
||||||
lib.print_string("Failed to run test ");
|
|
||||||
lib.print_string(name);
|
|
||||||
lib.print_string(" with build mode ");
|
|
||||||
lib.print_string(@tagName(build_mode));
|
|
||||||
if (stop_at_failure) {
|
|
||||||
lib.libc.exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn entry_point(arguments: []const [*:0]const u8, environment: [*:null]const ?[*:0]const u8) void {
|
pub fn entry_point(arguments: []const [*:0]const u8, environment: [*:null]const ?[*:0]const u8) void {
|
||||||
lib.GlobalState.initialize();
|
lib.GlobalState.initialize();
|
||||||
const arena = lib.global.arena;
|
const arena = lib.global.arena;
|
||||||
@ -186,16 +144,45 @@ pub fn entry_point(arguments: []const [*:0]const u8, environment: [*:null]const
|
|||||||
"minimal_stack",
|
"minimal_stack",
|
||||||
"minimal_stack_arithmetic",
|
"minimal_stack_arithmetic",
|
||||||
"pointer",
|
"pointer",
|
||||||
|
"extend",
|
||||||
};
|
};
|
||||||
|
|
||||||
inline for (@typeInfo(converter.BuildMode).@"enum".fields) |f| {
|
var build_modes: [@typeInfo(BuildMode).@"enum".fields.len]BuildMode = undefined;
|
||||||
const build_mode = @field(converter.BuildMode, f.name);
|
inline for (@typeInfo(BuildMode).@"enum".fields, 0..) |field, field_index| {
|
||||||
for ([2]bool{ true, false }) |has_debug_info| {
|
const build_mode = @field(BuildMode, field.name);
|
||||||
run_tests(arena, environment, names, .{
|
build_modes[field_index] = build_mode;
|
||||||
.build_mode = build_mode,
|
}
|
||||||
.has_debug_info = has_debug_info,
|
|
||||||
.stop_at_failure = stop_at_failure,
|
for (names) |name| {
|
||||||
});
|
for (build_modes) |build_mode| {
|
||||||
|
for ([2]bool{ true, false }) |has_debug_info| {
|
||||||
|
const position = arena.position;
|
||||||
|
defer arena.restore(position);
|
||||||
|
|
||||||
|
const relative_file_path = arena.join_string(&.{ "tests/", name, ".bbb" });
|
||||||
|
const compile_result = compile_file(arena, .{
|
||||||
|
.relative_file_path = relative_file_path,
|
||||||
|
.build_mode = build_mode,
|
||||||
|
.has_debug_info = has_debug_info,
|
||||||
|
.silent = true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = lib.os.run_child_process(arena, &.{compile_result.executable}, environment, .{
|
||||||
|
.stdout = .inherit,
|
||||||
|
.stderr = .inherit,
|
||||||
|
.null_file_descriptor = null,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!result.is_successful()) {
|
||||||
|
lib.print_string("Failed to run test ");
|
||||||
|
lib.print_string(name);
|
||||||
|
lib.print_string(" with build mode ");
|
||||||
|
lib.print_string(@tagName(build_mode));
|
||||||
|
if (stop_at_failure) {
|
||||||
|
lib.libc.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user