From 71a3ad656396f1cb0d0eabb2f2b560a14333a3d5 Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Sat, 27 May 2017 09:18:59 +1000 Subject: [PATCH] Tweak the test output. --- cmd/puffs-test-c/main.go | 2 -- test/c/gif/basic.c | 8 +++----- test/c/testlib/testlib.c | 17 +++++++++++++++-- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/cmd/puffs-test-c/main.go b/cmd/puffs-test-c/main.go index c6778c2d..5ae3764d 100644 --- a/cmd/puffs-test-c/main.go +++ b/cmd/puffs-test-c/main.go @@ -66,7 +66,6 @@ func listDir(dirname string) (filenames []string, err error) { } func do(dirname string, filename string) (failed bool, err error) { - fmt.Printf(" %s:\n", filename) workDir, err := ioutil.TempDir("", "puffs-test-c") if err != nil { return false, err @@ -76,7 +75,6 @@ func do(dirname string, filename string) (failed bool, err error) { for _, cc := range []string{"clang", "gcc"} { in := filepath.Join(dirname, filename) out := filepath.Join(workDir, cc+".out") - fmt.Printf(" %-8s", cc+":") ccCmd := exec.Command(cc, "-std=c99", "-Wall", "-Werror", "-o", out, in) ccCmd.Stdout = os.Stdout diff --git a/test/c/gif/basic.c b/test/c/gif/basic.c index 3cbe8304..bcd2209b 100644 --- a/test/c/gif/basic.c +++ b/test/c/gif/basic.c @@ -5,21 +5,19 @@ To manually run this test: for cc in clang gcc; do - printf "%-8s" "$cc:" $cc -std=c99 -Wall -Werror basic.c && ./a.out rm -f a.out done -It should print: -clang: PASS (N tests run) -gcc: PASS (N tests run) -for some value of N. +Each edition should print "PASS", amongst other information, and exit(0). */ #include "../testlib/testlib.c" #include "../../../gen/c/gif.c" +const char* test_filename = "gif/basic.c"; + void test_default_literal_width() { puffs_gif_lzw_decoder dec; puffs_gif_lzw_decoder_constructor(&dec); diff --git a/test/c/testlib/testlib.c b/test/c/testlib/testlib.c index 8b99eb16..a3630013 100644 --- a/test/c/testlib/testlib.c +++ b/test/c/testlib/testlib.c @@ -13,15 +13,28 @@ typedef void (*test)(); test tests[]; +const char* test_filename; + int main(int argc, char** argv) { +// The order matters here. Clang also defines "__GNUC__". +#if defined(__clang__) + const char* cc = "clang"; +#elif defined(__GNUC__) + const char* cc = "gcc"; +#elif defined(_MSC_VER) + const char* cc = "cl"; +#else + const char* cc = "cc"; +#endif + for (test* t = tests; *t; t++) { (*t)(); if (fail_msg[0]) { - printf("FAIL %s\n", fail_msg); + printf("%-16s%-8sFAIL %s\n", test_filename, cc, fail_msg); return 1; } tests_run++; } - printf("PASS (%d tests run)\n", tests_run); + printf("%-16s%-8sPASS (%d tests run)\n", test_filename, cc, tests_run); return 0; }