add e2e for goc profile with coverfile flag

This commit is contained in:
jichangjun 2020-09-05 16:27:23 +08:00
parent 3f29fd78ca
commit c00f871f80
5 changed files with 38 additions and 1 deletions

View File

@ -204,7 +204,7 @@ func filterProfile(coverFile []string, profiles []*cover.Profile) ([]*cover.Prof
for _, pattern := range coverFile {
matched, err := regexp.MatchString(pattern, profile.FileName)
if err != nil {
return nil, fmt.Errorf("filterProfile failed with pattern %s for profile %s", pattern, profile.FileName)
return nil, fmt.Errorf("filterProfile failed with pattern %s for profile %s, err: %v", pattern, profile.FileName, err)
}
if matched {
out = append(out, profile)

View File

@ -74,6 +74,26 @@ setup() {
run cat test-profile.bak
[[ "$output" == *"mode: count"* ]]
wait $profile_pid
kill -9 $SAMPLE_PID
}
@test "test goc profile with coverfile flag" {
./simple-project 3>&- &
SAMPLE_PID=$!
sleep 2
wait_profile_backend "profile3" &
profile_pid=$!
run gocc profile --center=http://127.0.0.1:60001 --coverfile="a.go$,b.go$" --debug --debugcisyncfile ci-sync.bak;
info $output
[ "$status" -eq 0 ]
[[ "$output" == *"mode: count"* ]]
[[ "$output" == *"a.go"* ]] # contains a.go file
[[ "$output" == *"b.go"* ]] # contains b.go file
[[ "$output" != *"main.go"* ]] # not contains main.go file
wait $profile_pid
kill -9 $SAMPLE_PID
}

View File

@ -0,0 +1,6 @@
package a
// Say Hello A
func Say() {
println("Hello A")
}

View File

@ -0,0 +1,6 @@
package b
// Say Hello B
func Say() {
println("Hello B")
}

View File

@ -3,9 +3,14 @@ package main
import (
"fmt"
"time"
"example.com/simple-project/a"
"example.com/simple-project/b"
)
func main() {
fmt.Println("hello")
a.Say()
b.Say()
time.Sleep(time.Second * 15)
}