Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: use make testSuite to ensure all testSuites enabled (#11627) #11685

Merged
merged 11 commits into from
Aug 12, 2019
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ build:
# Install the check tools.
check-setup:tools/bin/revive tools/bin/goword tools/bin/gometalinter tools/bin/gosec

check: fmt errcheck lint tidy check-static vet
check: fmt errcheck lint tidy testSuite check-static vet

# These need to be fixed before they can be ran regularly
check-fail: goword check-slow
Expand Down Expand Up @@ -106,6 +106,10 @@ tidy:
@echo "go mod tidy"
./tools/check/check-tidy.sh

testSuite:
@echo "testSuite"
./tools/check/check_testSuite.sh

clean:
$(GO) clean -i ./...
rm -rf *.out
Expand Down
1 change: 1 addition & 0 deletions executor/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ var _ = Suite(&testSuite1{})
var _ = Suite(&testSuite2{})
var _ = Suite(&testSuite3{})
var _ = Suite(&testSuite4{})
var _ = SerialSuites(&testShowStatsSuite{testSuite{}})
var _ = Suite(&testBypassSuite{})
var _ = Suite(&testUpdateSuite{})
var _ = Suite(&testOOMSuite{})
Expand Down
1 change: 1 addition & 0 deletions store/mockstore/mocktikv/mock_tikv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ type testMVCCLevelDB struct {
}

var (
_ = Suite(&testMockTiKVSuite{})
_ = Suite(&testMVCCLevelDB{})
_ = Suite(testMarshal{})
)
Expand Down
4 changes: 2 additions & 2 deletions store/tikv/backoff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type testBackoffSuite struct {
store *tikvStore
}

var _ = Suite(&testLockSuite{})
var _ = Suite(&testBackoffSuite{})

func (s *testBackoffSuite) SetUpTest(c *C) {
s.store = NewTestStore(c).(*tikvStore)
Expand All @@ -37,6 +37,6 @@ func (s *testBackoffSuite) TearDownTest(c *C) {
func (s *testBackoffSuite) TestBackoffWithMax(c *C) {
b := NewBackoffer(context.TODO(), 2000)
err := b.BackoffWithMaxSleep(boTxnLockFast, 30, errors.New("test"))
c.Assert(err, NotNil)
c.Assert(err, IsNil)
c.Assert(b.totalSleep, Equals, 30)
}
17 changes: 17 additions & 0 deletions tools/check/check_testSuite.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

set -euo pipefail

exitCode=0
for testSuite in $(find . -name "*_test.go" -print0 | xargs -0 grep -P "type test(.*)Suite" | awk '{print $2}'); do
# TODO: ugly regex
# TODO: check code comment
if ! find . -name "*_test.go" -print0 | xargs -0 grep -P "_ = (check\.)?(Suite|SerialSuites)\((&?${testSuite}{|new\(${testSuite}\))" > /dev/null
then
if find . -name "*_test.go" -print0 | xargs -0 grep -P "func \((.* )?\*?${testSuite}\) Test" > /dev/null
then
echo "${testSuite} is not enabled" && exitCode=1
fi
fi
done
exit ${exitCode}