是否可以将多个包的承保范围发布到Coveralls?

Usm*_*ail 11 go coveralls

我想跟踪使用Coveralls的go项目的测试覆盖率,使用https://github.com/mattn/goveralls进行集成参考的说明

cd $GOPATH/src/github.com/yourusername/yourpackage
$ goveralls your_repos_coveralls_token
Run Code Online (Sandbox Code Playgroud)

但是,这仅发布一个包的结果,并且依次运行包不起作用,因为最终运行会覆盖所有其他运行.有没有人想出如何获得多个包裹的报道?

Usm*_*ail 10

我最终使用这个脚本:

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
Run Code Online (Sandbox Code Playgroud)

它基本上找到路径中的所有目录,并分别为它们打印覆盖率配置文件.然后它将文件连接成一个大的配置文件并将它们运送到工作服.


Cli*_*int 5

采纳Usman的答案,并对其进行更改以支持跳过Godep和其他不相关的文件夹:

echo "mode: set" > acc.out
for Dir in $(go list ./...); 
do
    returnval=`go test -coverprofile=profile.out $Dir`
    echo ${returnval}
    if [[ ${returnval} != *FAIL* ]]
    then
        if [ -f profile.out ]
        then
            cat profile.out | grep -v "mode: set" >> acc.out 
        fi
    else
        exit 1
    fi  

done
if [ -n "$COVERALLS_TOKEN" ]
then
    goveralls -coverprofile=acc.out -repotoken=$COVERALLS_TOKEN -service=travis-pro
fi  

rm -rf ./profile.out
rm -rf ./acc.out
Run Code Online (Sandbox Code Playgroud)

注意,不是查看每个目录,而是使用go list ./...命令,该命令列出了实际上用于构建go软件包的所有目录。

希望对别人有帮助。

**编辑**

如果您正在使用vendorGo v.1.6 + 的文件夹,那么此脚本将滤除依赖项:

echo "mode: set" > acc.out
for Dir in $(go list ./...); 
do
    if [[ ${Dir} != *"/vendor/"* ]]
    then
        returnval=`go test -coverprofile=profile.out $Dir`
        echo ${returnval}
        if [[ ${returnval} != *FAIL* ]]
        then
            if [ -f profile.out ]
            then
                cat profile.out | grep -v "mode: set" >> acc.out 
            fi
        else
            exit 1
        fi
    else
        exit 1
    fi  

done
if [ -n "$COVERALLS_TOKEN" ]
then
    goveralls -coverprofile=acc.out -repotoken=$COVERALLS_TOKEN -service=travis-pro
fi  
Run Code Online (Sandbox Code Playgroud)