From 098dee66121671204a501123ae53bb6415832bec Mon Sep 17 00:00:00 2001 From: tiancaiamao Date: Thu, 19 May 2022 14:08:38 +0800 Subject: [PATCH] tools/check: 'ut' now remove support for the old test cases (#34800) close pingcap/tidb#30822 --- tools/check/ut.go | 52 +++++++---------------------------------------- 1 file changed, 7 insertions(+), 45 deletions(-) diff --git a/tools/check/ut.go b/tools/check/ut.go index a037bcf04bb94..52ac0e2d46db9 100644 --- a/tools/check/ut.go +++ b/tools/check/ut.go @@ -85,7 +85,6 @@ const modulePath = "github.com/pingcap/tidb" type task struct { pkg string test string - old bool } func (t *task) String() string { @@ -626,17 +625,9 @@ func listTestCases(pkg string, tasks []task) ([]task, error) { return nil, withTrace(err) } for _, c := range newCases { - tasks = append(tasks, task{pkg, c, false}) + tasks = append(tasks, task{pkg, c}) } - oldCases, err := listOldTestCases(pkg) - if err != nil { - fmt.Println("list old test case error", pkg, err) - return nil, withTrace(err) - } - for _, c := range oldCases { - tasks = append(tasks, task{pkg, c, true}) - } return tasks, nil } @@ -692,7 +683,7 @@ type numa struct { func (n *numa) worker(wg *sync.WaitGroup, ch chan task) { defer wg.Done() for t := range ch { - res := n.runTestCase(t.pkg, t.test, t.old) + res := n.runTestCase(t.pkg, t.test) if res.Failure != nil { fmt.Println("[FAIL] ", t.pkg, t.test) fmt.Fprintf(os.Stderr, "err=%s\n%s", res.err.Error(), res.Failure.Contents) @@ -708,7 +699,7 @@ type testResult struct { err error } -func (n *numa) runTestCase(pkg string, fn string, old bool) testResult { +func (n *numa) runTestCase(pkg string, fn string) testResult { res := testResult{ JUnitTestCase: JUnitTestCase{ Classname: path.Join(modulePath, pkg), @@ -720,7 +711,7 @@ func (n *numa) runTestCase(pkg string, fn string, old bool) testResult { var err error var start time.Time for i := 0; i < 3; i++ { - cmd := n.testCommand(pkg, fn, old) + cmd := n.testCommand(pkg, fn) cmd.Dir = path.Join(workDir, pkg) // Combine the test case output, so the run result for failed cases can be displayed. cmd.Stdout = &buf @@ -805,7 +796,7 @@ func failureCases(input []JUnitTestCase) int { return sum } -func (n *numa) testCommand(pkg string, fn string, old bool) *exec.Cmd { +func (n *numa) testCommand(pkg string, fn string) *exec.Cmd { args := make([]string, 0, 10) exe := "./" + testFileName(pkg) if coverprofile != "" { @@ -818,13 +809,8 @@ func (n *numa) testCommand(pkg string, fn string, old bool) *exec.Cmd { // Don't set timeout for race because it takes a longer when race is enabled. args = append(args, []string{"-test.timeout", "2m"}...) } - if old { - // session.test -test.run '^TestT$' -check.f testTxnStateSerialSuite.TestTxnInfoWithPSProtoco - args = append(args, "-test.run", "^TestT$", "-check.f", fn) - } else { - // session.test -test.run TestClusteredPrefixColum - args = append(args, "-test.run", fn) - } + // session.test -test.run TestClusteredPrefixColum + args = append(args, "-test.run", fn) return exec.Command(exe, args...) } @@ -918,30 +904,6 @@ func listNewTestCases(pkg string) ([]string, error) { }), nil } -func listOldTestCases(pkg string) (res []string, err error) { - exe := "./" + testFileName(pkg) - - // Maybe the restructure is finish on this package. - cmd := exec.Command(exe, "-h") - cmd.Dir = path.Join(workDir, pkg) - buf, err := cmd.CombinedOutput() - if err != nil { - err = withTrace(err) - return - } - if !bytes.Contains(buf, []byte("check.list")) { - // there is no old test case in pkg - return - } - - // session.test -test.run TestT -check.list Test - cmd = exec.Command(exe, "-test.run", "^TestT$", "-check.list", "Test") - cmd.Dir = path.Join(workDir, pkg) - res, err = cmdToLines(cmd) - res = filter(res, func(s string) bool { return strings.Contains(s, "Test") }) - return res, withTrace(err) -} - func cmdToLines(cmd *exec.Cmd) ([]string, error) { res, err := cmd.Output() if err != nil {