Add pkg field to testing.Internal_Test

This commit is contained in:
gingerBill
2021-03-14 18:15:08 +00:00
parent 2aa588209e
commit 468ad4837b
4 changed files with 40 additions and 8 deletions
+18 -3
View File
@@ -4,6 +4,7 @@ package testing
import "core:io"
import "core:os"
import "core:strings"
import "core:slice"
reset_t :: proc(t: ^T) {
clear(&t.cleanups);
@@ -28,6 +29,15 @@ runner :: proc(internal_tests: []Internal_Test) -> bool {
total_success_count := 0;
total_test_count := len(internal_tests);
slice.sort_by(internal_tests, proc(a, b: Internal_Test) -> bool {
if a.pkg < b.pkg {
return true;
}
return a.name < b.name;
});
prev_pkg := "";
for it in internal_tests {
if it.p == nil {
total_test_count -= 1;
@@ -40,7 +50,12 @@ runner :: proc(internal_tests: []Internal_Test) -> bool {
name := strings.trim_prefix(it.name, "test_");
logf(t, "[Test: %q]", name);
if prev_pkg != it.pkg {
prev_pkg = it.pkg;
logf(t, "[Package: %s]", it.pkg);
}
logf(t, "[Test: %s]", name);
// TODO(bill): Catch panics
{
@@ -48,9 +63,9 @@ runner :: proc(internal_tests: []Internal_Test) -> bool {
}
if t.error_count != 0 {
logf(t, "[%q : FAILURE]", name);
logf(t, "[%s : FAILURE]", name);
} else {
logf(t, "[%q : SUCCESS]", name);
logf(t, "[%s : SUCCESS]", name);
total_success_count += 1;
}
}
+3
View File
@@ -3,9 +3,12 @@ package testing
import "core:fmt"
import "core:io"
// IMPORTANT NOTE: Compiler requires this layout
Test_Signature :: proc(^T);
// IMPORTANT NOTE: Compiler requires this layout
Internal_Test :: struct {
pkg: string,
name: string,
p: Test_Signature,
}