Skip to content

Commit 76db0cb

Browse files
author
iasergunin
committed
1. Fixed codecoverage
1 parent 7dda220 commit 76db0cb

File tree

8 files changed

+64
-12
lines changed

8 files changed

+64
-12
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,4 @@ vendor/
2828

2929
# Code coverage
3030
coverage.*
31+
coverage/

Makefile

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
GO_TEST=cd ./sh && sh ./go.test.sh
2-
GO_TEST_WITH_REAL_DB=$(GO_TEST) --tags=with_real_db
3-
41
DIR=$(PWD)
5-
COVERAGE_FILE=`echo $(DIR)/coverage.out`
2+
3+
GO_TEST=cd ./sh && bash ./go.test.sh
4+
GO_TEST_COVERAGE=cd ./sh && bash ./go.test.coverage.sh
5+
6+
GO_TEST_WITH_REAL_DB=--tags=with_real_db
67

78
test:
89
$(GO_TEST)
910

1011
test.with_real_db:
11-
$(GO_TEST_WITH_REAL_DB)
12+
$(GO_TEST) $(GO_TEST_WITH_REAL_DB)
1213

13-
# TODO see in https://gist.github.com/skarllot/13ebe8220822bc19494c8b076aabe9fc
1414
test.coverage:
15-
$(GO_TEST) -covermode=atomic -coverprofile=$(COVERAGE_FILE)
15+
$(GO_TEST_COVERAGE)
1616

1717
test.coverage.with_real_db:
18-
$(GO_TEST_WITH_REAL_DB) -covermode=atomic -coverprofile=$(COVERAGE_FILE)
18+
$(GO_TEST_COVERAGE) $(GO_TEST_WITH_REAL_DB)
1919

2020
fmt:
2121
go fmt ./...

internal/cover/nested/cover.build.sh

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
cd ./module1/cmd
2+
3+
mkdir -p codecov
4+
5+
go build -cover -o run.exe .
6+
GOCOVERDIR=./codecov ./run.exe
7+
8+
# go test ./... -covermode=atomic -coverprofile=coverage.out
9+
10+
cd ../../module2/cmd
11+
12+
mkdir -p codecov
13+
14+
go build -cover -o run.exe .
15+
GOCOVERDIR=./codecov ./run.exe
16+
17+
# go test ./... -covermode=atomic -coverprofile=coverage.out
18+
19+
cd ../../
20+
21+
go tool covdata textfmt -i=module1/cmd/codecov,module2/cmd/codecov -o ./output.out

sh/go.mod.tidy.sh

100644100755
+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/bin/bash
2+
13
cd ../
24

35
ROOT=$(pwd)

sh/go.mod.vendor.sh

100644100755
+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/bin/bash
2+
13
cd ../
24

35
ROOT=$(pwd)

sh/go.test.coverage.sh

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
DIR=$(pwd)
4+
ROOT="$(pwd)/.."
5+
6+
COVERAGE_TEST="-cover -covermode=atomic -test.gocoverdir=$ROOT/coverage"
7+
8+
drivers=("$($DIR/utils/drivers.sh)")
9+
10+
mkdir -p $ROOT/coverage
11+
12+
./go.test.sh $COVERAGE_TEST "$@"
13+
14+
drivers_i="${drivers// //coverage,}"
15+
go tool covdata textfmt -i="$ROOT/coverage" -o "$ROOT/coverage.out"

sh/go.test.sh

100644100755
+10-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
#!/bin/bash
2+
3+
DIR=$(pwd)
4+
5+
drivers=("$($DIR/utils/drivers.sh)")
6+
17
cd ../
28

39
ROOT=$(pwd)
@@ -9,16 +15,16 @@ golist() {
915
gotest() {
1016
cd $driver
1117

12-
go test $(golist) -race "$@"
18+
go test $(golist) "$@"
1319

1420
cd $ROOT
1521
}
1622

17-
go test $(golist) -race "$@"
23+
go test $(golist) $@ &
1824

19-
for driver in ./drivers/*; do
25+
for driver in $drivers; do
2026
if [ -d "$driver" ]; then
21-
gotest "$@" &
27+
gotest $@ &
2228
fi
2329
done
2430

sh/utils/drivers.sh

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
cd ../
4+
5+
echo drivers/*

0 commit comments

Comments
 (0)