diff --git a/Makefile b/Makefile index 2af63a547d3b9..0186a59b5cab3 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -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 diff --git a/executor/executor_test.go b/executor/executor_test.go index 3294260b7d447..8de5009b0b900 100644 --- a/executor/executor_test.go +++ b/executor/executor_test.go @@ -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{}) diff --git a/store/mockstore/mocktikv/mock_tikv_test.go b/store/mockstore/mocktikv/mock_tikv_test.go index b5072107d812a..b76a5a11ed3d9 100644 --- a/store/mockstore/mocktikv/mock_tikv_test.go +++ b/store/mockstore/mocktikv/mock_tikv_test.go @@ -39,6 +39,7 @@ type testMVCCLevelDB struct { } var ( + _ = Suite(&testMockTiKVSuite{}) _ = Suite(&testMVCCLevelDB{}) _ = Suite(testMarshal{}) ) diff --git a/store/tikv/backoff_test.go b/store/tikv/backoff_test.go index 13aa5ef4c8fd2..ddf7d1fcf86f6 100644 --- a/store/tikv/backoff_test.go +++ b/store/tikv/backoff_test.go @@ -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) @@ -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) } diff --git a/tools/check/check_testSuite.sh b/tools/check/check_testSuite.sh new file mode 100755 index 0000000000000..dd743df3830bf --- /dev/null +++ b/tools/check/check_testSuite.sh @@ -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}