mirror of
https://github.com/odin-lang/Odin.git
synced 2025-12-30 09:54:45 +00:00
Change from test_* prefix to @(test) attribute for odin test
This commit is contained in:
@@ -48,14 +48,12 @@ runner :: proc(internal_tests: []Internal_Test) -> bool {
|
||||
reset_t(t);
|
||||
defer end_t(t);
|
||||
|
||||
name := strings.trim_prefix(it.name, "test_");
|
||||
|
||||
if prev_pkg != it.pkg {
|
||||
prev_pkg = it.pkg;
|
||||
logf(t, "[Package: %s]", it.pkg);
|
||||
}
|
||||
|
||||
logf(t, "[Test: %s]", name);
|
||||
logf(t, "[Test: %s]", it.name);
|
||||
|
||||
// TODO(bill): Catch panics
|
||||
{
|
||||
@@ -63,9 +61,9 @@ runner :: proc(internal_tests: []Internal_Test) -> bool {
|
||||
}
|
||||
|
||||
if t.error_count != 0 {
|
||||
logf(t, "[%s : FAILURE]", name);
|
||||
logf(t, "[%s : FAILURE]", it.name);
|
||||
} else {
|
||||
logf(t, "[%s : SUCCESS]", name);
|
||||
logf(t, "[%s : SUCCESS]", it.name);
|
||||
total_success_count += 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -687,6 +687,9 @@ void check_proc_decl(CheckerContext *ctx, Entity *e, DeclInfo *d) {
|
||||
check_decl_attributes(ctx, d->attributes, proc_decl_attribute, &ac);
|
||||
}
|
||||
|
||||
if (ac.test) {
|
||||
e->flags |= EntityFlag_Test;
|
||||
}
|
||||
e->Procedure.is_export = ac.is_export;
|
||||
e->deprecated_message = ac.deprecated_message;
|
||||
ac.link_name = handle_link_name(ctx, e->token, ac.link_name, ac.link_prefix);
|
||||
@@ -701,8 +704,8 @@ void check_proc_decl(CheckerContext *ctx, Entity *e, DeclInfo *d) {
|
||||
}
|
||||
}
|
||||
|
||||
bool is_foreign = e->Procedure.is_foreign;
|
||||
bool is_export = e->Procedure.is_export;
|
||||
bool is_foreign = e->Procedure.is_foreign;
|
||||
bool is_export = e->Procedure.is_export;
|
||||
|
||||
if (e->pkg != nullptr && e->token.string == "main") {
|
||||
if (pt->param_count != 0 ||
|
||||
|
||||
@@ -1891,20 +1891,13 @@ void generate_minimum_dependency_set(Checker *c, Entity *start) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String name = e->token.string;
|
||||
String prefix = str_lit("test_");
|
||||
|
||||
if (!string_starts_with(name, prefix)) {
|
||||
if ((e->flags & EntityFlag_Test) == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String name = e->token.string;
|
||||
|
||||
bool is_tester = false;
|
||||
if (name != prefix) {
|
||||
is_tester = true;
|
||||
} else {
|
||||
error(e->token, "Invalid testing procedure name: %.*s", LIT(name));
|
||||
}
|
||||
bool is_tester = true;
|
||||
|
||||
Type *t = base_type(e->type);
|
||||
GB_ASSERT(t->kind == Type_Proc);
|
||||
@@ -2414,7 +2407,13 @@ DECL_ATTRIBUTE_PROC(foreign_block_decl_attribute) {
|
||||
}
|
||||
|
||||
DECL_ATTRIBUTE_PROC(proc_decl_attribute) {
|
||||
if (name == "export") {
|
||||
if (name == "test") {
|
||||
if (value != nullptr) {
|
||||
error(value, "'%.*s' expects no parameter, or a string literal containing \"file\" or \"package\"", LIT(name));
|
||||
}
|
||||
ac->test = true;
|
||||
return true;
|
||||
} else if (name == "export") {
|
||||
ExactValue ev = check_decl_attribute_value(c, value);
|
||||
if (ev.kind == ExactValue_Invalid) {
|
||||
ac->is_export = true;
|
||||
|
||||
@@ -104,6 +104,7 @@ struct AttributeContext {
|
||||
bool require_declaration;
|
||||
bool has_disabled_proc;
|
||||
bool disabled_proc;
|
||||
bool test;
|
||||
String link_name;
|
||||
String link_prefix;
|
||||
isize init_expr_list_count;
|
||||
|
||||
@@ -64,6 +64,8 @@ enum EntityFlag : u32 {
|
||||
|
||||
EntityFlag_Disabled = 1<<24,
|
||||
|
||||
EntityFlag_Test = 1<<25,
|
||||
|
||||
};
|
||||
|
||||
enum EntityState {
|
||||
|
||||
@@ -3932,6 +3932,7 @@ Ast *parse_for_stmt(AstFile *f) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (allow_token(f, Token_do)) {
|
||||
body = convert_stmt_to_body(f, parse_stmt(f));
|
||||
if (build_context.disallow_do) {
|
||||
|
||||
Reference in New Issue
Block a user