是否可以向Coveralls发布多个软件包的覆盖范围? [英] Is it possible to post coverage for multiple packages to Coveralls?

查看:109
本文介绍了是否可以向Coveralls发布多个软件包的覆盖范围?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Coveralls跟踪项目的测试覆盖率,使用
https://github.com/mattn/goveralls

  cd $ GOPATH / src / github.com / yourusername / yourpackage 
$ goveralls your_repos_coveralls_token

但是,这只会发布一个包的结果并运行对于软件包而言,由于最终运行会覆盖所有其他运行,因此不起作用。有没有人想出了如何获得多个软件包的覆盖率?

我最终使用 script

  echomode:set>对于$中的Dir,请输入
(find ./* -maxdepth 10 -type d);

如果ls $ Dir / *。go&>的/ dev / null的;
然后
去测试-coverprofile = profile.out $ Dir
if [-f profile.out]
然后
cat profile.out | grep -vmode:set>> acc.out
fi
fi
done
goveralls -coverprofile = acc.out $ COVERALLS
rm -rf ./profile.out
rm -rf ./acc.out

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

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?

解决方案

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.

这篇关于是否可以向Coveralls发布多个软件包的覆盖范围?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆