From c569eb719ad0d58e731a870a39f493186b128673 Mon Sep 17 00:00:00 2001 From: Jesse Haka Date: Thu, 23 Nov 2023 08:44:42 +0200 Subject: [PATCH] make coverages automatically as txt formatted --- golang/target/go.go | 12 ++++++++++-- golang/testing.go | 12 +++++++----- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/golang/target/go.go b/golang/target/go.go index a4b69aa..c793faf 100644 --- a/golang/target/go.go +++ b/golang/target/go.go @@ -51,12 +51,20 @@ func (Go) Test(ctx context.Context) { // UnitTest run all unit tests func (Go) UnitTest(ctx context.Context) error { - return golang.UnitTest(ctx, golang.UnitTestCoverDir) + err := golang.UnitTest(ctx, golang.UnitTestCoverDir) + if err != nil { + return err + } + return golang.CreateCoverProfile(ctx, golang.UnitTestCoverProfile, golang.UnitTestCoverDir) } // IntegrationTest run integration tests func (Go) IntegrationTest(ctx context.Context) error { - return golang.IntegrationTest(ctx, BuildTarget, golang.IntegrationTestPkg, golang.IntegrationTestCoverDir, IntegrationTestRunArgs...) + err := golang.IntegrationTest(ctx, BuildTarget, golang.IntegrationTestPkg, golang.IntegrationTestCoverDir, IntegrationTestRunArgs...) + if err != nil { + return err + } + return golang.CreateCoverProfile(ctx, golang.IntegrationTestCoverProfile, golang.IntegrationTestCoverDir) } // CoverProfile convert binary coverage into text format diff --git a/golang/testing.go b/golang/testing.go index 52a7de2..5b7ded1 100644 --- a/golang/testing.go +++ b/golang/testing.go @@ -12,11 +12,13 @@ import ( // Default values used by mageutil/golang/target.Go targets. const ( - IntegrationTestPkg = "./integrationtests" - TestBinDir = "./target/tests/bin/" - UnitTestCoverDir = "./target/tests/cover/unit/" - IntegrationTestCoverDir = "./target/tests/cover/int/" - CombinedCoverProfile = "./target/tests/cover/combined/cover.txt" + IntegrationTestPkg = "./integrationtests" + TestBinDir = "./target/tests/bin/" + UnitTestCoverDir = "./target/tests/cover/unit/" + UnitTestCoverProfile = "./target/tests/cover/unit/cover.txt" + IntegrationTestCoverDir = "./target/tests/cover/int/" + IntegrationTestCoverProfile = "./target/tests/cover/int/cover.txt" + CombinedCoverProfile = "./target/tests/cover/combined/cover.txt" ) // IntegrationTestRunner executes integration tests in 4 phases: