mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
Add -test-name:<string> flag to allow specific tests to be ran
This commit is contained in:
@@ -212,6 +212,8 @@ struct BuildContext {
|
|||||||
|
|
||||||
QueryDataSetSettings query_data_set_settings;
|
QueryDataSetSettings query_data_set_settings;
|
||||||
|
|
||||||
|
StringSet test_names;
|
||||||
|
|
||||||
gbAffinity affinity;
|
gbAffinity affinity;
|
||||||
isize thread_count;
|
isize thread_count;
|
||||||
|
|
||||||
|
|||||||
@@ -4502,6 +4502,38 @@ void check_unchecked_bodies(Checker *c) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void check_test_names(Checker *c) {
|
||||||
|
if (build_context.test_names.entries.count == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
AstPackage *pkg = c->info.init_package;
|
||||||
|
Scope *s = pkg->scope;
|
||||||
|
|
||||||
|
for_array(i, build_context.test_names.entries) {
|
||||||
|
String name = build_context.test_names.entries[i].value;
|
||||||
|
Entity *e = scope_lookup(s, name);
|
||||||
|
if (e == nullptr) {
|
||||||
|
Token tok = {};
|
||||||
|
if (pkg->files.count != 0) {
|
||||||
|
tok = pkg->files[0]->tokens[0];
|
||||||
|
}
|
||||||
|
error(tok, "Unable to find the test '%.*s' in 'package %.*s' ", LIT(name), LIT(pkg->name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (isize i = 0; i < c->info.testing_procedures.count; /**/) {
|
||||||
|
Entity *e = c->info.testing_procedures[i];
|
||||||
|
String name = e->token.string;
|
||||||
|
if (!string_set_exists(&build_context.test_names, name)) {
|
||||||
|
array_ordered_remove(&c->info.testing_procedures, i);
|
||||||
|
} else {
|
||||||
|
i += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void check_parsed_files(Checker *c) {
|
void check_parsed_files(Checker *c) {
|
||||||
#define TIME_SECTION(str) do { if (build_context.show_more_timings) timings_start_section(&global_timings, str_lit(str)); } while (0)
|
#define TIME_SECTION(str) do { if (build_context.show_more_timings) timings_start_section(&global_timings, str_lit(str)); } while (0)
|
||||||
|
|
||||||
@@ -4576,6 +4608,9 @@ void check_parsed_files(Checker *c) {
|
|||||||
TIME_SECTION("generate minimum dependency set");
|
TIME_SECTION("generate minimum dependency set");
|
||||||
generate_minimum_dependency_set(c, c->info.entry_point);
|
generate_minimum_dependency_set(c, c->info.entry_point);
|
||||||
|
|
||||||
|
TIME_SECTION("check test names");
|
||||||
|
check_test_names(c);
|
||||||
|
|
||||||
TIME_SECTION("calculate global init order");
|
TIME_SECTION("calculate global init order");
|
||||||
// Calculate initialization order of global variables
|
// Calculate initialization order of global variables
|
||||||
calculate_global_init_order(c);
|
calculate_global_init_order(c);
|
||||||
|
|||||||
+29
-3
@@ -338,8 +338,8 @@ i32 linker_stage(lbGenerator *gen) {
|
|||||||
gbString lib_str = gb_string_make(heap_allocator(), "-L/");
|
gbString lib_str = gb_string_make(heap_allocator(), "-L/");
|
||||||
defer (gb_string_free(lib_str));
|
defer (gb_string_free(lib_str));
|
||||||
|
|
||||||
for_array(i, gen->module.foreign_library_paths) {
|
for_array(i, gen->default_module.foreign_library_paths) {
|
||||||
String lib = gen->module.foreign_library_paths[i];
|
String lib = gen->default_module.foreign_library_paths[i];
|
||||||
|
|
||||||
// NOTE(zangent): Sometimes, you have to use -framework on MacOS.
|
// NOTE(zangent): Sometimes, you have to use -framework on MacOS.
|
||||||
// This allows you to specify '-f' in a #foreign_system_library,
|
// This allows you to specify '-f' in a #foreign_system_library,
|
||||||
@@ -603,6 +603,8 @@ enum BuildFlagKind {
|
|||||||
BuildFlag_ExtraLinkerFlags,
|
BuildFlag_ExtraLinkerFlags,
|
||||||
BuildFlag_Microarch,
|
BuildFlag_Microarch,
|
||||||
|
|
||||||
|
BuildFlag_TestName,
|
||||||
|
|
||||||
BuildFlag_DisallowDo,
|
BuildFlag_DisallowDo,
|
||||||
BuildFlag_DefaultToNilAllocator,
|
BuildFlag_DefaultToNilAllocator,
|
||||||
BuildFlag_InsertSemicolon,
|
BuildFlag_InsertSemicolon,
|
||||||
@@ -721,6 +723,8 @@ bool parse_build_flags(Array<String> args) {
|
|||||||
add_flag(&build_flags, BuildFlag_ExtraLinkerFlags, str_lit("extra-linker-flags"), BuildFlagParam_String, Command__does_build);
|
add_flag(&build_flags, BuildFlag_ExtraLinkerFlags, str_lit("extra-linker-flags"), BuildFlagParam_String, Command__does_build);
|
||||||
add_flag(&build_flags, BuildFlag_Microarch, str_lit("microarch"), BuildFlagParam_String, Command__does_build);
|
add_flag(&build_flags, BuildFlag_Microarch, str_lit("microarch"), BuildFlagParam_String, Command__does_build);
|
||||||
|
|
||||||
|
add_flag(&build_flags, BuildFlag_TestName, str_lit("test-name"), BuildFlagParam_String, Command_test);
|
||||||
|
|
||||||
add_flag(&build_flags, BuildFlag_DisallowDo, str_lit("disallow-do"), BuildFlagParam_None, Command__does_check);
|
add_flag(&build_flags, BuildFlag_DisallowDo, str_lit("disallow-do"), BuildFlagParam_None, Command__does_check);
|
||||||
add_flag(&build_flags, BuildFlag_DefaultToNilAllocator, str_lit("default-to-nil-allocator"), BuildFlagParam_None, Command__does_check);
|
add_flag(&build_flags, BuildFlag_DefaultToNilAllocator, str_lit("default-to-nil-allocator"), BuildFlagParam_None, Command__does_check);
|
||||||
add_flag(&build_flags, BuildFlag_InsertSemicolon, str_lit("insert-semicolon"), BuildFlagParam_None, Command__does_check);
|
add_flag(&build_flags, BuildFlag_InsertSemicolon, str_lit("insert-semicolon"), BuildFlagParam_None, Command__does_check);
|
||||||
@@ -1219,6 +1223,21 @@ bool parse_build_flags(Array<String> args) {
|
|||||||
string_to_lower(&build_context.microarch);
|
string_to_lower(&build_context.microarch);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case BuildFlag_TestName:
|
||||||
|
GB_ASSERT(value.kind == ExactValue_String);
|
||||||
|
{
|
||||||
|
String name = value.value_string;
|
||||||
|
if (!string_is_valid_identifier(name)) {
|
||||||
|
gb_printf_err("Test name '%.*s' must be a valid identifier\n", LIT(name));
|
||||||
|
bad_flags = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
string_set_add(&build_context.test_names, name);
|
||||||
|
|
||||||
|
// NOTE(bill): Allow for multiple -test-name
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
case BuildFlag_DisallowDo:
|
case BuildFlag_DisallowDo:
|
||||||
build_context.disallow_do = true;
|
build_context.disallow_do = true;
|
||||||
break;
|
break;
|
||||||
@@ -1580,6 +1599,7 @@ void print_show_help(String const arg0, String const &command) {
|
|||||||
bool doc = command == "doc";
|
bool doc = command == "doc";
|
||||||
bool build = command == "build";
|
bool build = command == "build";
|
||||||
bool run_or_build = command == "run" || command == "build" || command == "test";
|
bool run_or_build = command == "run" || command == "build" || command == "test";
|
||||||
|
bool test_only = command == "test";
|
||||||
bool check_only = command == "check";
|
bool check_only = command == "check";
|
||||||
bool check = run_or_build || command == "check";
|
bool check = run_or_build || command == "check";
|
||||||
|
|
||||||
@@ -1734,6 +1754,12 @@ void print_show_help(String const arg0, String const &command) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (test_only) {
|
||||||
|
print_usage_line(1, "-test-name:<string>");
|
||||||
|
print_usage_line(2, "Run specific test only by name");
|
||||||
|
print_usage_line(0, "");
|
||||||
|
}
|
||||||
|
|
||||||
if (run_or_build) {
|
if (run_or_build) {
|
||||||
print_usage_line(1, "-extra-linker-flags:<string>");
|
print_usage_line(1, "-extra-linker-flags:<string>");
|
||||||
print_usage_line(2, "Adds extra linker specific flags in a string");
|
print_usage_line(2, "Adds extra linker specific flags in a string");
|
||||||
@@ -1925,7 +1951,7 @@ int main(int arg_count, char const **arg_ptr) {
|
|||||||
|
|
||||||
map_init(&build_context.defined_values, heap_allocator());
|
map_init(&build_context.defined_values, heap_allocator());
|
||||||
build_context.extra_packages.allocator = heap_allocator();
|
build_context.extra_packages.allocator = heap_allocator();
|
||||||
|
string_set_init(&build_context.test_names, heap_allocator());
|
||||||
|
|
||||||
Array<String> args = setup_args(arg_count, arg_ptr);
|
Array<String> args = setup_args(arg_count, arg_ptr);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user