Skip to content

Commit c82acdb

Browse files
committed
clean up test output
After 4df2f3d test names have the word "test" in them so the redundant word is removed from test runner. Also move the prefix/suffix to where it logically belongs in the fully qualified symbol name.
1 parent 1d95fda commit c82acdb

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

src/analyze.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2608,7 +2608,7 @@ static Error resolve_union_zero_bits(CodeGen *g, ZigType *union_type) {
26082608
return ErrorNone;
26092609
}
26102610

2611-
static void get_fully_qualified_decl_name(Buf *buf, Tld *tld) {
2611+
static void get_fully_qualified_decl_name(Buf *buf, Tld *tld, bool is_test) {
26122612
buf_resize(buf, 0);
26132613

26142614
Scope *scope = tld->parent_scope;
@@ -2618,7 +2618,13 @@ static void get_fully_qualified_decl_name(Buf *buf, Tld *tld) {
26182618
ScopeDecls *decls_scope = reinterpret_cast<ScopeDecls *>(scope);
26192619
buf_append_buf(buf, &decls_scope->container_type->name);
26202620
if (buf_len(buf) != 0) buf_append_char(buf, NAMESPACE_SEP_CHAR);
2621-
buf_append_buf(buf, tld->name);
2621+
if (is_test) {
2622+
buf_append_str(buf, "test \"");
2623+
buf_append_buf(buf, tld->name);
2624+
buf_append_char(buf, '"');
2625+
} else {
2626+
buf_append_buf(buf, tld->name);
2627+
}
26222628
}
26232629

26242630
ZigFn *create_fn_raw(CodeGen *g, FnInline inline_value) {
@@ -2729,7 +2735,7 @@ static void resolve_decl_fn(CodeGen *g, TldFn *tld_fn) {
27292735
if (fn_proto->is_export || is_extern) {
27302736
buf_init_from_buf(&fn_table_entry->symbol_name, tld_fn->base.name);
27312737
} else {
2732-
get_fully_qualified_decl_name(&fn_table_entry->symbol_name, &tld_fn->base);
2738+
get_fully_qualified_decl_name(&fn_table_entry->symbol_name, &tld_fn->base, false);
27332739
}
27342740

27352741
if (fn_proto->is_export) {
@@ -2790,10 +2796,7 @@ static void resolve_decl_fn(CodeGen *g, TldFn *tld_fn) {
27902796
} else if (source_node->type == NodeTypeTestDecl) {
27912797
ZigFn *fn_table_entry = create_fn_raw(g, FnInlineAuto);
27922798

2793-
Buf test_fn_name = BUF_INIT;
2794-
get_fully_qualified_decl_name(&test_fn_name, &tld_fn->base);
2795-
buf_resize(&fn_table_entry->symbol_name, 0);
2796-
buf_appendf(&fn_table_entry->symbol_name, "test \"%s\"", buf_ptr(&test_fn_name));
2799+
get_fully_qualified_decl_name(&fn_table_entry->symbol_name, &tld_fn->base, true);
27972800

27982801
tld_fn->fn_entry = fn_table_entry;
27992802

std/special/test_runner.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ pub fn main() !void {
88
var ok_count: usize = 0;
99
var skip_count: usize = 0;
1010
for (test_fn_list) |test_fn, i| {
11-
warn("Test {}/{} {}...", i + 1, test_fn_list.len, test_fn.name);
11+
warn("{}/{} {}...", i + 1, test_fn_list.len, test_fn.name);
1212

1313
if (test_fn.func()) |_| {
1414
ok_count += 1;

0 commit comments

Comments
 (0)