add e2e for goc profile with coverfile flag
This commit is contained in:
parent
3f29fd78ca
commit
c00f871f80
@ -204,7 +204,7 @@ func filterProfile(coverFile []string, profiles []*cover.Profile) ([]*cover.Prof
|
|||||||
for _, pattern := range coverFile {
|
for _, pattern := range coverFile {
|
||||||
matched, err := regexp.MatchString(pattern, profile.FileName)
|
matched, err := regexp.MatchString(pattern, profile.FileName)
|
||||||
if err != nil {
|
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 {
|
if matched {
|
||||||
out = append(out, profile)
|
out = append(out, profile)
|
||||||
|
@ -77,3 +77,23 @@ setup() {
|
|||||||
wait $profile_pid
|
wait $profile_pid
|
||||||
kill -9 $SAMPLE_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
|
||||||
|
}
|
6
tests/samples/run_for_several_seconds/a/a.go
Normal file
6
tests/samples/run_for_several_seconds/a/a.go
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
package a
|
||||||
|
|
||||||
|
// Say Hello A
|
||||||
|
func Say() {
|
||||||
|
println("Hello A")
|
||||||
|
}
|
6
tests/samples/run_for_several_seconds/b/b.go
Normal file
6
tests/samples/run_for_several_seconds/b/b.go
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
package b
|
||||||
|
|
||||||
|
// Say Hello B
|
||||||
|
func Say() {
|
||||||
|
println("Hello B")
|
||||||
|
}
|
@ -3,9 +3,14 @@ package main
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"example.com/simple-project/a"
|
||||||
|
"example.com/simple-project/b"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
fmt.Println("hello")
|
fmt.Println("hello")
|
||||||
|
a.Say()
|
||||||
|
b.Say()
|
||||||
time.Sleep(time.Second * 15)
|
time.Sleep(time.Second * 15)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user