Skip to content

Commit

Permalink
build: use make testSuite to ensure all testSuites enabled (#11627)
Browse files Browse the repository at this point in the history
  • Loading branch information
SunRunAway authored and sre-bot committed Aug 8, 2019
1 parent f74b9e9 commit 554594b
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 3 deletions.
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 @@ -93,6 +93,7 @@ var _ = Suite(&testSuite1{})
var _ = Suite(&testSuite2{})
var _ = Suite(&testSuite3{})
var _ = Suite(&testSuite4{})
var _ = SerialSuites(&testShowStatsSuite{testSuite{&baseTestSuite{}}})
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}

0 comments on commit 554594b

Please sign in to comment.