Merge pull request #106 from appleboy/coverage
Support testing multiple package in subfolder.
This commit is contained in:
commit
def178ca0e
|
@ -30,7 +30,7 @@ install:
|
||||||
- go get github.com/mattn/goveralls
|
- go get github.com/mattn/goveralls
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- make test
|
- make coverage
|
||||||
- $(go env GOPATH | awk 'BEGIN{FS=":"} {print $1}')/bin/goveralls -coverprofile=coverage.txt
|
- $(go env GOPATH | awk 'BEGIN{FS=":"} {print $1}')/bin/goveralls -coverprofile=coverage.txt
|
||||||
-service=travis-ci -repotoken=$COVERALLS_TOKEN
|
-service=travis-ci -repotoken=$COVERALLS_TOKEN
|
||||||
|
|
||||||
|
|
5
Makefile
5
Makefile
|
@ -25,6 +25,9 @@ endif
|
||||||
build: clean
|
build: clean
|
||||||
sh script/build.sh $(VERSION)
|
sh script/build.sh $(VERSION)
|
||||||
|
|
||||||
|
coverage:
|
||||||
|
sh go.test.sh atomic
|
||||||
|
|
||||||
test: redis_test boltdb_test memory_test config_test
|
test: redis_test boltdb_test memory_test config_test
|
||||||
go test -v -cover -covermode=count -coverprofile=coverage.txt ./gorush/...
|
go test -v -cover -covermode=count -coverprofile=coverage.txt ./gorush/...
|
||||||
|
|
||||||
|
@ -41,7 +44,7 @@ config_test: init
|
||||||
go test -v -cover -covermode=count -coverprofile=coverage.txt ./config/...
|
go test -v -cover -covermode=count -coverprofile=coverage.txt ./config/...
|
||||||
|
|
||||||
html:
|
html:
|
||||||
go tool cover -html=coverage.txt && unlink coverage.txt
|
go tool cover -html=coverage.txt
|
||||||
|
|
||||||
docker_build: clean
|
docker_build: clean
|
||||||
tar -zcvf build.tar.gz gorush.go gorush config storage Makefile glide.lock glide.yaml
|
tar -zcvf build.tar.gz gorush.go gorush config storage Makefile glide.lock glide.yaml
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
output() {
|
||||||
|
printf "\033[32m"
|
||||||
|
echo $1
|
||||||
|
printf "\033[0m"
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
coverage_mode=$1
|
||||||
|
|
||||||
|
test -z $coverage_mode && output "Usage: $0 coverage_mode"
|
||||||
|
|
||||||
|
test -f coverage.txt && rm -rf coverage.txt
|
||||||
|
echo "mode: ${coverage_mode}" > coverage.txt
|
||||||
|
|
||||||
|
for d in ./storage/boltdb/... ./storage/redis/... ./storage/memory/... ./config/... ./gorush/...; do
|
||||||
|
go test -v -cover -coverprofile=profile.out -covermode=${coverage_mode} $d
|
||||||
|
if [ -f profile.out ]; then
|
||||||
|
sed '1d' profile.out >> coverage.txt
|
||||||
|
rm profile.out
|
||||||
|
fi
|
||||||
|
done
|
|
@ -10,6 +10,8 @@ func TestMemoryEngine(t *testing.T) {
|
||||||
|
|
||||||
memory := New()
|
memory := New()
|
||||||
|
|
||||||
|
assert.Nil(t, memory.Init())
|
||||||
|
|
||||||
memory.AddTotalCount(1)
|
memory.AddTotalCount(1)
|
||||||
val = memory.GetTotalCount()
|
val = memory.GetTotalCount()
|
||||||
assert.Equal(t, int64(1), val)
|
assert.Equal(t, int64(1), val)
|
||||||
|
|
Loading…
Reference in New Issue