stage1 实现ir2vm 修复nob test命令的构建问题

This commit is contained in:
zzy committed 2026-09-12 18:51:10 +08:00
1 parent 87d9b7ea34
commit a64a96f9a4
11 files changed
+1565 -195

No files matched your search

+14 -12
View File
@@ -31,8 +31,9 @@ static const char *splc0_srcs[] = {
"stage1/spl_intrin.c",
"stage1/spl_ir.c",
"stage1/spl_ast2ir.c",
// "stage1/spl_ir2vm.c",
// "stage0/spl_mcode.c",
"stage1/spl_layout.c",
"stage1/spl_ir2vm.c",
"stage0/spl_mcode.c",
};
/* clang-format on */
@@ -182,7 +183,7 @@ static void parse_expect(const char *name, Nob_Cmd_Result *expect) {
if (rest.count == 0)
continue;
if (nob_sv_starts_with(rest, nob_sv_from_cstr("Expect"))) {
if (!nob_sv_starts_with(rest, nob_sv_from_cstr("Expect"))) {
break;
}
rest = nob_sv_from_parts(rest.data + 6, rest.count - 6);
@@ -198,6 +199,7 @@ static void parse_expect(const char *name, Nob_Cmd_Result *expect) {
for (size_t i = 0; i < value.count && isdigit(value.data[i]); ++i) {
val = val * 10 + (value.data[i] - '0');
}
// printf("expected code %d\n", val);
expect->exit_code = val;
} else if (nob_sv_eq(key, nob_sv_from_cstr("stdout"))) {
}
@@ -229,14 +231,14 @@ static bool test_once(const char *fname, void *user_data) {
cmd.count = 0;
nob_cmd_append(&cmd, nob_temp_sprintf(BUILD_FOLDER "%s", cli_path));
nob_cmd_append(&cmd, target_sir);
nob_cmd_run(&cmd);
// nob_cmd_run(&cmd);
Nob_Cmd_Result result = {0};
Nob_String_Builder cmd_str = {0};
nob_cmd_render(cmd, &cmd_str);
nob_sb_append_null(&cmd_str);
nob_cmd_capture_popen(cmd_str.items, &result);
Nob_String_View sv = nob_sb_to_sv(cmd_str);
nob_cmd_capture_popen(nob_temp_sv_to_cstr(sv), &result);
// Expect retcode = number
Nob_Cmd_Result expect = {0};
@@ -268,6 +270,10 @@ typedef bool (*test_fn_t)(const char *fname, void *user_data);
static bool run_test(Nob_Files *files, test_fn_t test_once, void *user_data) {
const char *test_folder = "./tests/stage1/";
if (!prepare_build()) {
return 1;
}
Nob_File_Paths paths = {0};
nob_read_entire_dir(test_folder, &paths);
for (int i = 0; i < files->count; i += 1) {
@@ -284,10 +290,6 @@ static bool run_test(Nob_Files *files, test_fn_t test_once, void *user_data) {
}
}
if (!prepare_build()) {
return 1;
}
return true;
}
@@ -320,7 +322,7 @@ int main(int argc, char **argv) {
#ifdef _WIN32
SetConsoleOutputCP(CP_UTF8);
#endif
NOB_GO_REBUILD_URSELF_PLUS(argc, argv, "nob.h");
NOB_GO_REBUILD_URSELF_PLUS(argc, argv, "nob.h", "nob_popen.h");
set_log_handler(nob_cancer_log_handler);
const char *program_name = nob_shift(argv, argc);