diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index f4449be2..81ace1a3 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -44,7 +44,7 @@ jobs: - name: Coverage run: | - # go get -u github.com/wadey/gocovmerge + go get -u github.com/wadey/gocovmerge # go get -u github.com/Konstantin8105/cs # go get -u golang.org/x/sys/unix TRAVIS=true ./scripts/test.sh diff --git a/scripts/test.sh b/scripts/test.sh index c7aa7f82..010a9406 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -1,51 +1,59 @@ #!/bin/bash -go install github.com/ory/go-acc@latest - -touch ./coverage.tmp -echo 'mode: atomic' > coverage.txt -go list ./... | grep -v /cmd | grep -v /vendor | xargs -n1 -I{} sh -c 'go test -covermode=atomic -coverprofile=coverage.tmp -coverpkg $(go list ./... | grep -v /vendor | tr "\n" ",") {} && tail -n +2 coverage.tmp >> coverage.txt || exit 255' && rm coverage.tmp - - -# set -e -# -# echo "" > coverage.txt -# -# mkdir -p ./testdata/ -# -# # Package list -# export PKGS=$(go list ./... | grep -v c4go/testdata | grep -v c4go/examples | grep -v c4go/tests | grep -v /vendor/ | tr '\n' ' ') -# -# # Make comma-separated. -# export PKGS_DELIM=$(echo "$PKGS" | tr ' ' ',') -# -# echo "PKGS : $PKGS" -# echo "PKGS_DELIM : $PKGS_DELIM" -# -# go test \ -# -cover \ -# -timeout=30m \ -# -coverpkg=$PKGS_DELIM \ -# -coverprofile=./testdata/pkg.coverprofile $PKGS -# -# # Merge coverage profiles. -# COVERAGE_FILES=`ls -1 ./testdata/*.coverprofile 2>/dev/null | wc -l` -# if [ $COVERAGE_FILES != 0 ]; then -# # check program `gocovmerge` is exist -# if which gocovmerge >/dev/null 2>&1; then -# export FILES=$(ls testdata/*.coverprofile | tr '\n' ' ') -# echo "Combine next coverprofiles : $FILES" -# gocovmerge $FILES > coverage.txt -# fi -# fi - -# echo "" > coverage.out -# for d in $(go list ./... | grep -v vendor); do -# go test -v -race -coverprofile=profile.out -covermode=atomic $d -# if [ -f profile.out ]; then -# cat profile.out >> coverage.out -# rm profile.out -# fi -# done - -# echo "End of coverage" +# go install github.com/ory/go-acc@latest +# +# touch ./coverage.tmp +# echo 'mode: atomic' > coverage.txt +# go list ./... | grep -v /cmd | grep -v /vendor | xargs -n1 -I{} sh -c 'go test -covermode=atomic -coverprofile=coverage.tmp -coverpkg $(go list ./... | grep -v /vendor | tr "\n" ",") {} && tail -n +2 coverage.tmp >> coverage.txt || exit 255' && rm coverage.tmp + + +set -e + +echo "" > coverage.txt + +mkdir -p ./testdata/ + +# github.com/Konstantin8105/c4go +# github.com/Konstantin8105/c4go/ast +# github.com/Konstantin8105/c4go/examples // ignore +# github.com/Konstantin8105/c4go/noarch +# github.com/Konstantin8105/c4go/preprocessor +# github.com/Konstantin8105/c4go/program +# github.com/Konstantin8105/c4go/scripts +# github.com/Konstantin8105/c4go/testdata // ignore +# github.com/Konstantin8105/c4go/tests // ignore +# github.com/Konstantin8105/c4go/transpiler +# github.com/Konstantin8105/c4go/types +# github.com/Konstantin8105/c4go/util +# github.com/Konstantin8105/c4go/version + +# Package list +# export PKGS="github.com/Konstantin8105/c4go github.com/Konstantin8105/c4go/ast github.com/Konstantin8105/c4go/noarch github.com/Konstantin8105/c4go/preprocessor github.com/Konstantin8105/c4go/program github.com/Konstantin8105/c4go/scripts github.com/Konstantin8105/c4go/transpiler github.com/Konstantin8105/c4go/types github.com/Konstantin8105/c4go/util github.com/Konstantin8105/c4go/version" +export PKGS="github.com/Konstantin8105/c4go github.com/Konstantin8105/c4go/ast github.com/Konstantin8105/c4go/version" +# $(go list ./... | grep -v c4go/testdata | grep -v c4go/examples | grep -v c4go/tests | grep -v /vendor/ | tr '\n' ' ') + +# Make comma-separated. +export PKGS_DELIM=$(echo "$PKGS" | tr ' ' ',') + +echo "PKGS : $PKGS" +echo "PKGS_DELIM : $PKGS_DELIM" + +go test \ + -cover \ + -covermode=atomic \ + -timeout=30m \ + -coverpkg=$PKGS_DELIM \ + -coverprofile=./testdata/pkg.coverprofile $PKGS + +# Merge coverage profiles. +COVERAGE_FILES=`ls -1 ./testdata/*.coverprofile 2>/dev/null | wc -l` +if [ $COVERAGE_FILES != 0 ]; then + # check program `gocovmerge` is exist + if which gocovmerge >/dev/null 2>&1; then + export FILES=$(ls testdata/*.coverprofile | tr '\n' ' ') + echo "Combine next coverprofiles : $FILES" + gocovmerge $FILES > coverage.txt + fi +fi + +echo "End of coverage"