Skip to content

Commit

Permalink
Add integration test
Browse files Browse the repository at this point in the history
Signed-off-by: Sascha Grunert <sgrunert@suse.com>
  • Loading branch information
saschagrunert authored and williammartin committed Oct 8, 2019
1 parent e5dde8c commit d90e0dc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
7 changes: 5 additions & 2 deletions ginkgo/run_command.go
Expand Up @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions integration/coverage_test.go
@@ -1,7 +1,9 @@
package integration_test

import (
"io/ioutil"
"os/exec"
"regexp"

"fmt"

Expand Down Expand Up @@ -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())
Expand Down

0 comments on commit d90e0dc

Please sign in to comment.