mirror of
https://github.com/odin-lang/Odin.git
synced 2025-12-31 10:22:08 +00:00
Remove -test-name in favor of test runner option
`-define:ODIN_TEST_NAMES=...` is capable of selecting test by package and name or name only, with the ability to access packages included by `-all-packages`.
This commit is contained in:
@@ -893,7 +893,6 @@ struct BuildContext {
|
||||
u32 cmd_doc_flags;
|
||||
Array<String> extra_packages;
|
||||
|
||||
StringSet test_names;
|
||||
bool test_all_packages;
|
||||
|
||||
gbAffinity affinity;
|
||||
|
||||
@@ -5852,35 +5852,6 @@ gb_internal void remove_neighbouring_duplicate_entires_from_sorted_array(Array<E
|
||||
gb_internal void check_test_procedures(Checker *c) {
|
||||
array_sort(c->info.testing_procedures, init_procedures_cmp);
|
||||
remove_neighbouring_duplicate_entires_from_sorted_array(&c->info.testing_procedures);
|
||||
|
||||
if (build_context.test_names.entries.count == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
AstPackage *pkg = c->info.init_package;
|
||||
Scope *s = pkg->scope;
|
||||
|
||||
for (String const &name : build_context.test_names) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
24
src/main.cpp
24
src/main.cpp
@@ -276,8 +276,6 @@ enum BuildFlagKind {
|
||||
BuildFlag_RelocMode,
|
||||
BuildFlag_DisableRedZone,
|
||||
|
||||
BuildFlag_TestName,
|
||||
|
||||
BuildFlag_DisallowDo,
|
||||
BuildFlag_DefaultToNilAllocator,
|
||||
BuildFlag_DefaultToPanicAllocator,
|
||||
@@ -471,8 +469,6 @@ gb_internal bool parse_build_flags(Array<String> args) {
|
||||
add_flag(&build_flags, BuildFlag_RelocMode, str_lit("reloc-mode"), BuildFlagParam_String, Command__does_build);
|
||||
add_flag(&build_flags, BuildFlag_DisableRedZone, str_lit("disable-red-zone"), BuildFlagParam_None, 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_DefaultToNilAllocator, str_lit("default-to-nil-allocator"), BuildFlagParam_None, Command__does_check);
|
||||
add_flag(&build_flags, BuildFlag_DefaultToPanicAllocator, str_lit("default-to-panic-allocator"),BuildFlagParam_None, Command__does_check);
|
||||
@@ -1119,21 +1115,6 @@ gb_internal bool parse_build_flags(Array<String> args) {
|
||||
case BuildFlag_DisableRedZone:
|
||||
build_context.disable_red_zone = true;
|
||||
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:
|
||||
build_context.disallow_do = true;
|
||||
break;
|
||||
@@ -1962,10 +1943,6 @@ gb_internal void print_show_help(String const arg0, String const &command) {
|
||||
}
|
||||
|
||||
if (test_only) {
|
||||
print_usage_line(1, "-test-name:<string>");
|
||||
print_usage_line(2, "Runs specific test only by name.");
|
||||
print_usage_line(0, "");
|
||||
|
||||
print_usage_line(1, "-all-packages");
|
||||
print_usage_line(2, "Tests all packages imported into the given initial package.");
|
||||
print_usage_line(0, "");
|
||||
@@ -2489,7 +2466,6 @@ int main(int arg_count, char const **arg_ptr) {
|
||||
TIME_SECTION("init args");
|
||||
map_init(&build_context.defined_values);
|
||||
build_context.extra_packages.allocator = heap_allocator();
|
||||
string_set_init(&build_context.test_names);
|
||||
|
||||
Array<String> args = setup_args(arg_count, arg_ptr);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user