From 1d385d434ca9387a55d67f121a423f4834101fbb Mon Sep 17 00:00:00 2001 From: Elliot Chance Date: Tue, 30 May 2017 15:38:49 +0200 Subject: [PATCH] Output TAP test count --- main_test.go | 16 +++++++++++++++- tests/argv.c | 7 +++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/main_test.go b/main_test.go index f1ad88721..7fa8382be 100644 --- a/main_test.go +++ b/main_test.go @@ -4,6 +4,7 @@ package main import ( "bytes" + "fmt" "os" "os/exec" "path/filepath" @@ -11,6 +12,8 @@ import ( "syscall" "testing" + "regexp" + "github.com/elliotchance/c2go/util" ) @@ -99,7 +102,8 @@ func TestIntegrationScripts(t *testing.T) { // Check if both exit codes are zero (or non-zero) if cProgram.isZero != goProgram.isZero { - t.Fatalf("Expected: %t, Got: %t", cProgram.isZero, goProgram.isZero) + t.Fatalf("Exit statuses did not match.\n" + util.ShowDiff(cProgram.stdout.String(), goProgram.stdout.String())) + // t.Fatalf("Expected: %t, Got: %t", cProgram.isZero, goProgram.isZero) } // Check stderr @@ -111,6 +115,16 @@ func TestIntegrationScripts(t *testing.T) { if cProgram.stdout.String() != goProgram.stdout.String() { t.Fatalf(util.ShowDiff(cProgram.stdout.String(), goProgram.stdout.String())) } + + // Extact the number of tests run. + firstLine := strings.Split(goProgram.stdout.String(), "\n")[0] + + matches := regexp.MustCompile(`1..(\d+)`).FindStringSubmatch(firstLine) + if len(matches) == 0 { + t.Fatalf("Test did not output tap: %s", file) + } + + fmt.Println(file + " TAP TESTS: " + matches[1]) }) } } diff --git a/tests/argv.c b/tests/argv.c index d4923105b..42b7fcd6f 100644 --- a/tests/argv.c +++ b/tests/argv.c @@ -5,11 +5,14 @@ int main(int argc, const char **argv) { - plan(4); + plan(3); is_eq(argc, 3); - is_streq(argv[0], "build/go.out"); + // We cannot compare the zeroth argument becuase it will be different for C + // and Go. + // is_streq(argv[0], "build/go.out"); + is_streq(argv[1], "some"); is_streq(argv[2], "args");