Is it possible to post coverage for multiple packages to Coveralls?

前端 未结 6 661
故里飘歌
故里飘歌 2021-02-04 10:02

I want to track test coverage on a go project using Coveralls, the instructions for the integration reference using https://github.com/mattn/goveralls

cd $GOPA         


        
6条回答
  •  时光取名叫无心
    2021-02-04 10:38

    I ended up using this script:

    echo "mode: set" > acc.out
    for Dir in $(find ./* -maxdepth 10 -type d );
    do
            if ls $Dir/*.go &> /dev/null;
            then
                go test -coverprofile=profile.out $Dir
                if [ -f profile.out ]
                then
                    cat profile.out | grep -v "mode: set" >> acc.out
                fi
    fi
    done
    goveralls -coverprofile=acc.out $COVERALLS
    rm -rf ./profile.out
    rm -rf ./acc.out
    

    It basically finds all the directories in the path and prints a coverage profile for them separately. It then concatenates the files into one big profile and ships them off to coveralls.

提交回复
热议问题