Skip to content

Commit 810f8ae

Browse files
authored
*: remove pingcap/check dependency (pingcap#34734)
close pingcap#28328
1 parent a3193a8 commit 810f8ae

File tree

160 files changed

+1000
-1926
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

160 files changed

+1000
-1926
lines changed

Makefile

+6-11
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ ut: tools/bin/ut tools/bin/xprog failpoint-enable
125125
gotest: failpoint-enable
126126
@echo "Running in native mode."
127127
@export log_level=info; export TZ='Asia/Shanghai'; \
128-
$(GOTEST) -ldflags '$(TEST_LDFLAGS)' $(EXTRA_TEST_ARGS) -timeout 20m -cover $(PACKAGES_TIDB_TESTS) -coverprofile=coverage.txt -check.p true > gotest.log || { $(FAILPOINT_DISABLE); cat 'gotest.log'; exit 1; }
128+
$(GOTEST) -ldflags '$(TEST_LDFLAGS)' $(EXTRA_TEST_ARGS) -timeout 20m -cover $(PACKAGES_TIDB_TESTS) -coverprofile=coverage.txt > gotest.log || { $(FAILPOINT_DISABLE); cat 'gotest.log'; exit 1; }
129129
@$(FAILPOINT_DISABLE)
130130

131131
gotest_in_verify_ci: tools/bin/xprog tools/bin/ut failpoint-enable
@@ -151,11 +151,6 @@ race: failpoint-enable
151151
@$(FAILPOINT_DISABLE)
152152
@$(CLEAN_UT_BINARY)
153153

154-
leak: failpoint-enable
155-
@export log_level=debug; \
156-
$(GOTEST) -tags leak $(PACKAGES) || { $(FAILPOINT_DISABLE); exit 1; }
157-
@$(FAILPOINT_DISABLE)
158-
159154
server:
160155
ifeq ($(TARGET), "")
161156
CGO_ENABLED=1 $(GOBUILD) $(RACE_FLAG) -ldflags '$(LDFLAGS) $(CHECK_FLAG)' -o bin/tidb-server tidb-server/main.go
@@ -273,7 +268,7 @@ ifeq ("$(pkg)", "")
273268
else
274269
@echo "Running unit test for github.com/pingcap/tidb/$(pkg)"
275270
@export log_level=fatal; export TZ='Asia/Shanghai'; \
276-
$(GOTEST) -ldflags '$(TEST_LDFLAGS)' -cover github.com/pingcap/tidb/$(pkg) -check.p true -check.timeout 4s || { $(FAILPOINT_DISABLE); exit 1; }
271+
$(GOTEST) -ldflags '$(TEST_LDFLAGS)' -cover github.com/pingcap/tidb/$(pkg) || { $(FAILPOINT_DISABLE); exit 1; }
277272
endif
278273
@$(FAILPOINT_DISABLE)
279274

@@ -336,15 +331,15 @@ br_unit_test: export ARGS=$$($(BR_PACKAGES))
336331
br_unit_test:
337332
@make failpoint-enable
338333
@export TZ='Asia/Shanghai';
339-
$(GOTEST) $(RACE_FLAG) -ldflags '$(LDFLAGS)' -tags leak $(ARGS) -coverprofile=coverage.txt || ( make failpoint-disable && exit 1 )
334+
$(GOTEST) $(RACE_FLAG) -ldflags '$(LDFLAGS)' $(ARGS) -coverprofile=coverage.txt || ( make failpoint-disable && exit 1 )
340335
@make failpoint-disable
341336
br_unit_test_in_verify_ci: export ARGS=$$($(BR_PACKAGES))
342337
br_unit_test_in_verify_ci: tools/bin/gotestsum
343338
@make failpoint-enable
344339
@export TZ='Asia/Shanghai';
345340
@mkdir -p $(TEST_COVERAGE_DIR)
346341
CGO_ENABLED=1 tools/bin/gotestsum --junitfile "$(TEST_COVERAGE_DIR)/br-junit-report.xml" -- $(RACE_FLAG) -ldflags '$(LDFLAGS)' \
347-
-tags leak $(ARGS) -coverprofile="$(TEST_COVERAGE_DIR)/br_cov.unit_test.out" || ( make failpoint-disable && exit 1 )
342+
$(ARGS) -coverprofile="$(TEST_COVERAGE_DIR)/br_cov.unit_test.out" || ( make failpoint-disable && exit 1 )
348343
@make failpoint-disable
349344

350345
br_integration_test: br_bins build_br build_for_br_integration_test
@@ -401,12 +396,12 @@ build_dumpling:
401396

402397
dumpling_unit_test: export DUMPLING_ARGS=$$($(DUMPLING_PACKAGES))
403398
dumpling_unit_test: failpoint-enable
404-
$(DUMPLING_GOTEST) $(RACE_FLAG) -coverprofile=coverage.txt -covermode=atomic -tags leak $(DUMPLING_ARGS) || ( make failpoint-disable && exit 1 )
399+
$(DUMPLING_GOTEST) $(RACE_FLAG) -coverprofile=coverage.txt -covermode=atomic $(DUMPLING_ARGS) || ( make failpoint-disable && exit 1 )
405400
@make failpoint-disable
406401
dumpling_unit_test_in_verify_ci: export DUMPLING_ARGS=$$($(DUMPLING_PACKAGES))
407402
dumpling_unit_test_in_verify_ci: failpoint-enable tools/bin/gotestsum
408403
@mkdir -p $(TEST_COVERAGE_DIR)
409-
CGO_ENABLED=1 tools/bin/gotestsum --junitfile "$(TEST_COVERAGE_DIR)/dumpling-junit-report.xml" -- -tags leak $(DUMPLING_ARGS) \
404+
CGO_ENABLED=1 tools/bin/gotestsum --junitfile "$(TEST_COVERAGE_DIR)/dumpling-junit-report.xml" -- $(DUMPLING_ARGS) \
410405
$(RACE_FLAG) -coverprofile="$(TEST_COVERAGE_DIR)/dumpling_cov.unit_test.out" || ( make failpoint-disable && exit 1 )
411406
@make failpoint-disable
412407

bindinfo/main_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ package bindinfo_test
1717
import (
1818
"testing"
1919

20-
"github.com/pingcap/tidb/util/testbridge"
20+
"github.com/pingcap/tidb/testkit/testsetup"
2121
"go.uber.org/goleak"
2222
)
2323

2424
func TestMain(m *testing.M) {
25-
testbridge.SetupForCommonTest()
25+
testsetup.SetupForCommonTest()
2626
opts := []goleak.Option{
2727
goleak.IgnoreTopFunction("github.com/golang/glog.(*loggingT).flushDaemon"),
2828
goleak.IgnoreTopFunction("go.etcd.io/etcd/client/pkg/v3/logutil.(*MergeLogger).outputLoop"),

br/pkg/backup/main_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ package backup
1717
import (
1818
"testing"
1919

20-
"github.com/pingcap/tidb/util/testbridge"
20+
"github.com/pingcap/tidb/testkit/testsetup"
2121
"go.uber.org/goleak"
2222
)
2323

2424
func TestMain(m *testing.M) {
25-
testbridge.SetupForCommonTest()
25+
testsetup.SetupForCommonTest()
2626
opts := []goleak.Option{
2727
goleak.IgnoreTopFunction("github.com/golang/glog.(*loggingT).flushDaemon"),
2828
goleak.IgnoreTopFunction("github.com/klauspost/compress/zstd.(*blockDec).startDecoder"),

br/pkg/checksum/main_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ package checksum
1717
import (
1818
"testing"
1919

20-
"github.com/pingcap/tidb/util/testbridge"
20+
"github.com/pingcap/tidb/testkit/testsetup"
2121
"go.uber.org/goleak"
2222
)
2323

@@ -28,6 +28,6 @@ func TestMain(m *testing.M) {
2828
goleak.IgnoreTopFunction("go.etcd.io/etcd/client/pkg/v3/logutil.(*MergeLogger).outputLoop"),
2929
goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start"),
3030
}
31-
testbridge.SetupForCommonTest()
31+
testsetup.SetupForCommonTest()
3232
goleak.VerifyTestMain(m, opts...)
3333
}

br/pkg/conn/main_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ package conn
1717
import (
1818
"testing"
1919

20-
"github.com/pingcap/tidb/util/testbridge"
20+
"github.com/pingcap/tidb/testkit/testsetup"
2121
"go.uber.org/goleak"
2222
)
2323

@@ -27,6 +27,6 @@ func TestMain(m *testing.M) {
2727
goleak.IgnoreTopFunction("go.etcd.io/etcd/client/pkg/v3/logutil.(*MergeLogger).outputLoop"),
2828
goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start"),
2929
}
30-
testbridge.SetupForCommonTest()
30+
testsetup.SetupForCommonTest()
3131
goleak.VerifyTestMain(m, opts...)
3232
}

br/pkg/lightning/checkpoints/main_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ package checkpoints_test
1717
import (
1818
"testing"
1919

20-
"github.com/pingcap/tidb/util/testbridge"
20+
"github.com/pingcap/tidb/testkit/testsetup"
2121
"go.uber.org/goleak"
2222
)
2323

2424
func TestMain(m *testing.M) {
25-
testbridge.SetupForCommonTest()
25+
testsetup.SetupForCommonTest()
2626
opts := []goleak.Option{
2727
goleak.IgnoreTopFunction("github.com/golang/glog.(*loggingT).flushDaemon"),
2828
goleak.IgnoreTopFunction("github.com/klauspost/compress/zstd.(*blockDec).startDecoder"),

br/pkg/lightning/common/main_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ package common_test
1717
import (
1818
"testing"
1919

20-
"github.com/pingcap/tidb/util/testbridge"
20+
"github.com/pingcap/tidb/testkit/testsetup"
2121
"go.uber.org/goleak"
2222
)
2323

2424
func TestMain(m *testing.M) {
25-
testbridge.SetupForCommonTest()
25+
testsetup.SetupForCommonTest()
2626
opts := []goleak.Option{
2727
goleak.IgnoreTopFunction("github.com/golang/glog.(*loggingT).flushDaemon"),
2828
goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start"),

br/pkg/lightning/mydump/main_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ package mydump
1717
import (
1818
"testing"
1919

20-
"github.com/pingcap/tidb/util/testbridge"
20+
"github.com/pingcap/tidb/testkit/testsetup"
2121
"go.uber.org/goleak"
2222
)
2323

2424
func TestMain(m *testing.M) {
25-
testbridge.SetupForCommonTest()
25+
testsetup.SetupForCommonTest()
2626
opts := []goleak.Option{
2727
goleak.IgnoreTopFunction("github.com/golang/glog.(*loggingT).flushDaemon"),
2828
goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start"),

br/pkg/metautil/main_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ package metautil
1717
import (
1818
"testing"
1919

20-
"github.com/pingcap/tidb/util/testbridge"
20+
"github.com/pingcap/tidb/testkit/testsetup"
2121
"go.uber.org/goleak"
2222
)
2323

@@ -26,6 +26,6 @@ func TestMain(m *testing.M) {
2626
goleak.IgnoreTopFunction("github.com/golang/glog.(*loggingT).flushDaemon"),
2727
goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start"),
2828
}
29-
testbridge.SetupForCommonTest()
29+
testsetup.SetupForCommonTest()
3030
goleak.VerifyTestMain(m, opts...)
3131
}

br/pkg/pdutil/main_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ package pdutil
1717
import (
1818
"testing"
1919

20-
"github.com/pingcap/tidb/util/testbridge"
20+
"github.com/pingcap/tidb/testkit/testsetup"
2121
"go.uber.org/goleak"
2222
)
2323

2424
func TestMain(m *testing.M) {
25-
testbridge.SetupForCommonTest()
25+
testsetup.SetupForCommonTest()
2626
opts := []goleak.Option{
2727
goleak.IgnoreTopFunction("github.com/golang/glog.(*loggingT).flushDaemon"),
2828
goleak.IgnoreTopFunction("go.etcd.io/etcd/client/pkg/v3/logutil.(*MergeLogger).outputLoop"),

br/pkg/restore/main_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ import (
2020
"testing"
2121

2222
"github.com/pingcap/tidb/br/pkg/mock"
23-
"github.com/pingcap/tidb/util/testbridge"
23+
"github.com/pingcap/tidb/testkit/testsetup"
2424
"go.uber.org/goleak"
2525
)
2626

2727
func TestMain(m *testing.M) {
28-
testbridge.SetupForCommonTest()
28+
testsetup.SetupForCommonTest()
2929
opts := []goleak.Option{
3030
goleak.IgnoreTopFunction("github.com/golang/glog.(*loggingT).flushDaemon"),
3131
goleak.IgnoreTopFunction("github.com/klauspost/compress/zstd.(*blockDec).startDecoder"),

br/pkg/rtree/main_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ package rtree_test
1717
import (
1818
"testing"
1919

20-
"github.com/pingcap/tidb/util/testbridge"
20+
"github.com/pingcap/tidb/testkit/testsetup"
2121
"go.uber.org/goleak"
2222
)
2323

2424
func TestMain(m *testing.M) {
25-
testbridge.SetupForCommonTest()
25+
testsetup.SetupForCommonTest()
2626
opts := []goleak.Option{
2727
goleak.IgnoreTopFunction("github.com/golang/glog.(*loggingT).flushDaemon"),
2828
goleak.IgnoreTopFunction("go.etcd.io/etcd/client/pkg/v3/logutil.(*MergeLogger).outputLoop"),

br/pkg/stream/decode_kv_test.go

+10-19
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,13 @@
33
package stream_test
44

55
import (
6-
"bytes"
76
"testing"
87

9-
. "github.com/pingcap/check"
108
"github.com/pingcap/tidb/br/pkg/stream"
9+
"github.com/stretchr/testify/require"
1110
)
1211

13-
type testDecodeKVSuite struct{}
14-
15-
func TestT(t *testing.T) {
16-
TestingT(t)
17-
}
18-
19-
var _ = Suite(&testDecodeKVSuite{})
20-
21-
func (s *testDecodeKVSuite) TestDecodeKVEntry(c *C) {
12+
func TestDecodeKVEntry(t *testing.T) {
2213
var (
2314
pairs = map[string]string{
2415
"db": "tidb",
@@ -37,17 +28,17 @@ func (s *testDecodeKVSuite) TestDecodeKVEntry(c *C) {
3728
for ei.Valid() {
3829
ei.Next()
3930
err := ei.GetError()
40-
c.Assert(err, IsNil)
31+
require.NoError(t, err)
4132

4233
key := ei.Key()
4334
value := ei.Value()
4435
v, exist := pairs[string(key)]
45-
c.Assert(exist, IsTrue)
46-
c.Assert(string(value), Equals, v)
36+
require.True(t, exist)
37+
require.Equal(t, v, string(value))
4738
}
4839
}
4940

50-
func (s *testDecodeKVSuite) TestDecodeKVEntryError(c *C) {
41+
func TestDecodeKVEntryError(t *testing.T) {
5142
var (
5243
k = []byte("db")
5344
v = []byte("tidb")
@@ -59,10 +50,10 @@ func (s *testDecodeKVSuite) TestDecodeKVEntryError(c *C) {
5950

6051
ei := stream.NewEventIterator(buff)
6152
ei.Next()
62-
c.Assert(bytes.Equal(k, ei.Key()), IsTrue)
63-
c.Assert(bytes.Equal(v, ei.Value()), IsTrue)
64-
c.Assert(ei.Valid(), IsTrue)
53+
require.Equal(t, k, ei.Key())
54+
require.Equal(t, v, ei.Value())
55+
require.True(t, ei.Valid())
6556

6657
ei.Next()
67-
c.Assert(ei.GetError(), NotNil)
58+
require.Error(t, ei.GetError())
6859
}

0 commit comments

Comments
 (0)