From d90e0dcda42f29d3e7ab0bb5d52451df252bf709 Mon Sep 17 00:00:00 2001 From: Sascha Grunert Date: Wed, 19 Dec 2018 11:25:08 +0100 Subject: [PATCH] Add integration test Signed-off-by: Sascha Grunert --- ginkgo/run_command.go | 7 +++++-- integration/coverage_test.go | 10 ++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/ginkgo/run_command.go b/ginkgo/run_command.go index 2e89913f4..1d06e08fd 100644 --- a/ginkgo/run_command.go +++ b/ginkgo/run_command.go @@ -164,8 +164,11 @@ func (r *SpecRunner) combineCoverprofiles(runners []*testrunner.TestRunner) erro fmt.Println("path is " + path) - combined, err := os.OpenFile(filepath.Join(path, r.getCoverprofile()), - os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0666) + combined, err := os.OpenFile( + filepath.Join(path, r.getCoverprofile()), + os.O_WRONLY|os.O_CREATE, + 0666, + ) if err != nil { fmt.Printf("Unable to create combined profile, %v\n", err) diff --git a/integration/coverage_test.go b/integration/coverage_test.go index a1d24bfed..3b4528ce5 100644 --- a/integration/coverage_test.go +++ b/integration/coverage_test.go @@ -1,7 +1,9 @@ package integration_test import ( + "io/ioutil" "os/exec" + "regexp" "fmt" @@ -114,6 +116,14 @@ var _ = Describe("Coverage Specs", func() { Ω("./_fixtures/combined_coverage_fixture/coverprofile-recursive.txt").Should(BeARegularFile()) }) + By("and strips multiple mode specifier", func() { + re := regexp.MustCompile(`mode: atomic`) + bytes, err := ioutil.ReadFile("./_fixtures/combined_coverage_fixture/coverprofile-recursive.txt") + Ω(err).Should(BeNil()) + matches := re.FindAllIndex(bytes, -1) + Ω(len(matches)).Should(Equal(1)) + }) + By("also generating the single package coverage files", func() { Ω("./_fixtures/combined_coverage_fixture/first_package/coverprofile-recursive.txt").Should(BeARegularFile()) Ω("./_fixtures/combined_coverage_fixture/second_package/coverprofile-recursive.txt").Should(BeARegularFile())