mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-02 12:48:14 +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);
|
reset_t(t);
|
||||||
defer end_t(t);
|
defer end_t(t);
|
||||||
|
|
||||||
name := strings.trim_prefix(it.name, "test_");
|
|
||||||
|
|
||||||
if prev_pkg != it.pkg {
|
if prev_pkg != it.pkg {
|
||||||
prev_pkg = it.pkg;
|
prev_pkg = it.pkg;
|
||||||
logf(t, "[Package: %s]", it.pkg);
|
logf(t, "[Package: %s]", it.pkg);
|
||||||
}
|
}
|
||||||
|
|
||||||
logf(t, "[Test: %s]", name);
|
logf(t, "[Test: %s]", it.name);
|
||||||
|
|
||||||
// TODO(bill): Catch panics
|
// TODO(bill): Catch panics
|
||||||
{
|
{
|
||||||
@@ -63,9 +61,9 @@ runner :: proc(internal_tests: []Internal_Test) -> bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if t.error_count != 0 {
|
if t.error_count != 0 {
|
||||||
logf(t, "[%s : FAILURE]", name);
|
logf(t, "[%s : FAILURE]", it.name);
|
||||||
} else {
|
} else {
|
||||||
logf(t, "[%s : SUCCESS]", name);
|
logf(t, "[%s : SUCCESS]", it.name);
|
||||||
total_success_count += 1;
|
total_success_count += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-2
@@ -687,6 +687,9 @@ void check_proc_decl(CheckerContext *ctx, Entity *e, DeclInfo *d) {
|
|||||||
check_decl_attributes(ctx, d->attributes, proc_decl_attribute, &ac);
|
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->Procedure.is_export = ac.is_export;
|
||||||
e->deprecated_message = ac.deprecated_message;
|
e->deprecated_message = ac.deprecated_message;
|
||||||
ac.link_name = handle_link_name(ctx, e->token, ac.link_name, ac.link_prefix);
|
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_foreign = e->Procedure.is_foreign;
|
||||||
bool is_export = e->Procedure.is_export;
|
bool is_export = e->Procedure.is_export;
|
||||||
|
|
||||||
if (e->pkg != nullptr && e->token.string == "main") {
|
if (e->pkg != nullptr && e->token.string == "main") {
|
||||||
if (pt->param_count != 0 ||
|
if (pt->param_count != 0 ||
|
||||||
|
|||||||
+10
-11
@@ -1891,20 +1891,13 @@ void generate_minimum_dependency_set(Checker *c, Entity *start) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
String name = e->token.string;
|
if ((e->flags & EntityFlag_Test) == 0) {
|
||||||
String prefix = str_lit("test_");
|
|
||||||
|
|
||||||
if (!string_starts_with(name, prefix)) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String name = e->token.string;
|
||||||
|
|
||||||
bool is_tester = false;
|
bool is_tester = true;
|
||||||
if (name != prefix) {
|
|
||||||
is_tester = true;
|
|
||||||
} else {
|
|
||||||
error(e->token, "Invalid testing procedure name: %.*s", LIT(name));
|
|
||||||
}
|
|
||||||
|
|
||||||
Type *t = base_type(e->type);
|
Type *t = base_type(e->type);
|
||||||
GB_ASSERT(t->kind == Type_Proc);
|
GB_ASSERT(t->kind == Type_Proc);
|
||||||
@@ -2414,7 +2407,13 @@ DECL_ATTRIBUTE_PROC(foreign_block_decl_attribute) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
DECL_ATTRIBUTE_PROC(proc_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);
|
ExactValue ev = check_decl_attribute_value(c, value);
|
||||||
if (ev.kind == ExactValue_Invalid) {
|
if (ev.kind == ExactValue_Invalid) {
|
||||||
ac->is_export = true;
|
ac->is_export = true;
|
||||||
|
|||||||
@@ -104,6 +104,7 @@ struct AttributeContext {
|
|||||||
bool require_declaration;
|
bool require_declaration;
|
||||||
bool has_disabled_proc;
|
bool has_disabled_proc;
|
||||||
bool disabled_proc;
|
bool disabled_proc;
|
||||||
|
bool test;
|
||||||
String link_name;
|
String link_name;
|
||||||
String link_prefix;
|
String link_prefix;
|
||||||
isize init_expr_list_count;
|
isize init_expr_list_count;
|
||||||
|
|||||||
@@ -64,6 +64,8 @@ enum EntityFlag : u32 {
|
|||||||
|
|
||||||
EntityFlag_Disabled = 1<<24,
|
EntityFlag_Disabled = 1<<24,
|
||||||
|
|
||||||
|
EntityFlag_Test = 1<<25,
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum EntityState {
|
enum EntityState {
|
||||||
|
|||||||
@@ -3932,6 +3932,7 @@ Ast *parse_for_stmt(AstFile *f) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (allow_token(f, Token_do)) {
|
if (allow_token(f, Token_do)) {
|
||||||
body = convert_stmt_to_body(f, parse_stmt(f));
|
body = convert_stmt_to_body(f, parse_stmt(f));
|
||||||
if (build_context.disallow_do) {
|
if (build_context.disallow_do) {
|
||||||
|
|||||||
Reference in New Issue
Block a user