gocoveralls

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


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 $GOPATH/src/github.com/yourusername/yourpackage
$ goveralls your_repos_coveralls_token

However, this only posts the results for one package and running for packages in turn does not work as the final run overwrites all other runs. Has anyone figured out how to get coverage for multiple packages?


Solution

  • 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.