@@ -19,6 +19,7 @@ PROGS = cadence
19
19
TEST_ARG ?= -race -v -timeout 5m
20
20
BUILD := ./build
21
21
TOOLS_CMD_ROOT =./cmd/tools
22
+ INTEG_TEST_ROOT =./host
22
23
23
24
export PATH := $(GOPATH ) /bin:$(PATH )
24
25
@@ -50,6 +51,21 @@ TOOLS_SRC += $(TOOLS_CMD_ROOT)
50
51
# all directories with *_test.go files in them
51
52
TEST_DIRS := $(sort $(dir $(filter % _test.go,$(ALL_SRC ) ) ) )
52
53
54
+ # dirs that contain integration tests, these need to be treated
55
+ # differently to get correct code coverage
56
+ INTEG_TEST_DIRS := $(filter $(INTEG_TEST_ROOT ) % ,$(TEST_DIRS ) )
57
+ # all tests other than integration test fall into the pkg_test category
58
+ PKG_TEST_DIRS := $(filter-out $(INTEG_TEST_ROOT ) % ,$(TEST_DIRS ) )
59
+
60
+
61
+ # Need the following option to have integration tests
62
+ # count towards coverage. godoc below:
63
+ # -coverpkg pkg1,pkg2,pkg3
64
+ # Apply coverage analysis in each test to the given list of packages.
65
+ # The default is for each test to analyze only the package being tested.
66
+ # Packages are specified as import paths.
67
+ GOCOVERPKG_ARG := -coverpkg="$(PROJECT_ROOT ) /common/...,$(PROJECT_ROOT ) /service/...,$(PROJECT_ROOT ) /client/...,$(PROJECT_ROOT ) /tools/..."
68
+
53
69
vendor/glide.updated : glide.lock glide.yaml
54
70
glide install
55
71
touch vendor/glide.updated
@@ -77,22 +93,30 @@ test: bins
77
93
done ;
78
94
79
95
cover_profile : clean bins_nothrift
80
- @echo Testing packages:
81
- @for dir in $(TEST_DIRS ) ; do \
96
+ @mkdir -p $(BUILD )
97
+ @echo " mode: atomic" > $(BUILD ) /cover.out
98
+
99
+ @echo Running integration tests:
100
+ @time for dir in $(INTEG_TEST_DIRS); do \
101
+ mkdir -p $(BUILD)/"$$dir"; \
102
+ go test "$$dir" $(TEST_ARG) $(GOCOVERPKG_ARG) -coverprofile=$(BUILD)/"$$dir"/coverage.out || exit 1; \
103
+ cat $(BUILD)/"$$dir"/coverage.out | grep -v "mode: atomic" >> $(BUILD)/cover.out; \
104
+ done
105
+
106
+ @echo Running package tests:
107
+ @for dir in $(PKG_TEST_DIRS); do \
82
108
mkdir -p $(BUILD)/"$$dir"; \
83
109
go test "$$dir" $(TEST_ARG) -coverprofile=$(BUILD)/"$$dir"/coverage.out || exit 1; \
110
+ cat $(BUILD)/"$$dir"/coverage.out | grep -v "mode: atomic" >> $(BUILD)/cover.out; \
84
111
done;
85
112
86
113
cover : cover_profile
87
- @for dir in $(TEST_DIRS ) ; do \
88
- go tool cover -html=$(BUILD ) /" $$ dir" /coverage.out; \
89
- done
114
+ go tool cover -html=$(BUILD ) /cover.out;
90
115
91
116
cover_ci : cover_profile
92
- @for dir in $(TEST_DIRS ) ; do \
93
- goveralls -coverprofile=$(BUILD ) /" $$ dir" /coverage.out -service=travis-ci || echo -e " \x1b[31mCoveralls failed\x1b[m" ; \
94
- done
117
+ goveralls -coverprofile=$(BUILD ) /cover.out -service=travis-ci || echo -e " \x1b[31mCoveralls failed\x1b[m" ; \
95
118
96
119
clean :
97
- rm -rf cadence
98
- rm -rf cadence-cassandra-tool
120
+ rm -f cadence
121
+ rm -f cadence-cassandra-tool
122
+ rm -Rf $(BUILD )
0 commit comments