From adfacd1713d945d26142466a2a4f1f44899f66f9 Mon Sep 17 00:00:00 2001 From: jichangjun Date: Fri, 18 Dec 2020 11:07:04 +0800 Subject: [PATCH] feature: add e2e tests --- pkg/cover/server.go | 2 +- tests/profile.bats | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/pkg/cover/server.go b/pkg/cover/server.go index 98403a3..72e946b 100644 --- a/pkg/cover/server.go +++ b/pkg/cover/server.go @@ -243,7 +243,7 @@ func filterProfile(coverFile []string, profiles []*cover.Profile) ([]*cover.Prof return out, nil } -// skipProfile skips profiles of the packages matching the coverFile pattern +// skipProfile skips profiles of the packages matching the skipFile pattern func skipProfile(skipFile []string, profiles []*cover.Profile) ([]*cover.Profile, error) { var out = make([]*cover.Profile, 0) for _, profile := range profiles { diff --git a/tests/profile.bats b/tests/profile.bats index 6a64bf2..92c8f26 100755 --- a/tests/profile.bats +++ b/tests/profile.bats @@ -98,6 +98,26 @@ setup() { kill -9 $SAMPLE_PID } +@test "test goc profile with coverfile and skipfile flags" { + ./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$" --skipfile="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"* ]] # not contains b.go file + [[ "$output" != *"main.go"* ]] # not contains main.go file + + wait $profile_pid + kill -9 $SAMPLE_PID +} + @test "test goc profile with service flag" { ./simple-project 3>&- & SAMPLE_PID=$!