From 54f019570c294a0cbe6b5900547852b625d0663a Mon Sep 17 00:00:00 2001 From: disksing Date: Wed, 6 Dec 2017 19:51:57 +0800 Subject: [PATCH] *: enable gofail for make dev. (#5325) * *: update go-check * *: enable gofail for make dev. --- Makefile | 18 +++++++----------- _vendor/src/github.com/pingcap/check/check.go | 16 +++++++++++++++- _vendor/src/github.com/pingcap/check/run.go | 2 ++ glide.lock | 2 +- glide.yaml | 2 +- store/tikv/2pc_fail_test.go | 1 - store/tikv/sql_fail_test.go | 1 - store/tikv/store_fail_test.go | 1 - 8 files changed, 26 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index 5d01336581a58..5ccf0727964c9 100644 --- a/Makefile +++ b/Makefile @@ -114,27 +114,23 @@ ifeq ("$(TRAVIS_COVERAGE)", "1") $(GOVERALLS) -service=travis-ci -coverprofile=overalls.coverprofile else @echo "Running in native mode." + go get github.com/coreos/gofail + @$(GOFAIL_ENABLE) @export log_level=error; \ - $(GOTEST) -cover $(PACKAGES) + $(GOTEST) -cover $(PACKAGES) || { $(GOFAIL_DISABLE); exit 1; } + @$(GOFAIL_DISABLE) endif race: parserlib @export log_level=debug; \ - $(GOTEST) -race $(PACKAGES) + $(GOTEST) -check.exclude="TestFail" -race $(PACKAGES) leak: parserlib @export log_level=debug; \ - $(GOTEST) -tags leak $(PACKAGES) - -gofail: parserlib - go get github.com/coreos/gofail - @$(GOFAIL_ENABLE) - @export log_level=debug; \ - $(GOTEST) -tags gofail $(PACKAGES) || { $(GOFAIL_DISABLE); exit 1; } - @$(GOFAIL_DISABLE) + $(GOTEST) -check.exclude="TestFail" -tags leak $(PACKAGES) tikv_integration_test: parserlib - $(GOTEST) ./store/tikv/. -with-tikv=true + $(GOTEST) -check.exclude="TestFail" ./store/tikv/. -with-tikv=true RACE_FLAG = ifeq ("$(WITH_RACE)", "1") diff --git a/_vendor/src/github.com/pingcap/check/check.go b/_vendor/src/github.com/pingcap/check/check.go index c9485e70447de..fc535bc38fa0e 100644 --- a/_vendor/src/github.com/pingcap/check/check.go +++ b/_vendor/src/github.com/pingcap/check/check.go @@ -534,6 +534,7 @@ type RunConf struct { BenchmarkTime time.Duration // Defaults to 1 second BenchmarkMem bool KeepWorkDir bool + Exclude string } // Create a new suiteRunner able to run all methods in the given suite. @@ -578,6 +579,17 @@ func newSuiteRunner(suite interface{}, runConf *RunConf) *suiteRunner { } } + var excludeRegexp *regexp.Regexp + if conf.Exclude != "" { + if regexp, err := regexp.Compile(conf.Exclude); err != nil { + msg := "Bad exclude expression: " + err.Error() + runner.tracker.result.RunError = errors.New(msg) + return runner + } else { + excludeRegexp = regexp + } + } + for i := 0; i != suiteNumMethods; i++ { method := newMethod(suiteValue, i) switch method.Info.Name { @@ -598,7 +610,9 @@ func newSuiteRunner(suite interface{}, runConf *RunConf) *suiteRunner { continue } if filterRegexp == nil || method.matches(filterRegexp) { - runner.tests = append(runner.tests, method) + if excludeRegexp == nil || !method.matches(excludeRegexp) { + runner.tests = append(runner.tests, method) + } } } } diff --git a/_vendor/src/github.com/pingcap/check/run.go b/_vendor/src/github.com/pingcap/check/run.go index bf0d65ac9e54e..afa631f470484 100644 --- a/_vendor/src/github.com/pingcap/check/run.go +++ b/_vendor/src/github.com/pingcap/check/run.go @@ -42,6 +42,7 @@ var ( newBenchMem = flag.Bool("check.bmem", false, "Report memory benchmarks") newListFlag = flag.Bool("check.list", false, "List the names of all tests that will be run") newWorkFlag = flag.Bool("check.work", false, "Display and do not remove the test working directory") + newExcludeFlag = flag.String("check.exclude", "", "Regular expression to exclude tests to run") ) var CustomVerboseFlag bool @@ -62,6 +63,7 @@ func TestingT(testingT *testing.T) { BenchmarkTime: benchTime, BenchmarkMem: *newBenchMem, KeepWorkDir: *oldWorkFlag || *newWorkFlag, + Exclude: *newExcludeFlag, } if *oldListFlag || *newListFlag { w := bufio.NewWriter(os.Stdout) diff --git a/glide.lock b/glide.lock index dcf035af7fef7..ed0a17cd8cbb2 100644 --- a/glide.lock +++ b/glide.lock @@ -117,7 +117,7 @@ imports: - name: github.com/peterh/liner version: 3f3a91ddf7d2784892a58e27ddf48d70e3304bb7 - name: github.com/pingcap/check - version: 9b266636177e249ec28b0aeffe8e86bc272bb481 + version: 1c287c953996ab3a0bf535dba9d53d809d3dc0b6 - name: github.com/pingcap/goleveldb version: 8d44bfdf1030639ae7130922c95df12d6d4da3b6 subpackages: diff --git a/glide.yaml b/glide.yaml index 76494585bf6f6..07a7be81374ec 100644 --- a/glide.yaml +++ b/glide.yaml @@ -46,7 +46,7 @@ import: - package: github.com/peterh/liner version: 3f3a91ddf7d2784892a58e27ddf48d70e3304bb7 - package: github.com/pingcap/check - version: 9b266636177e249ec28b0aeffe8e86bc272bb481 + version: 1c287c953996ab3a0bf535dba9d53d809d3dc0b6 - package: github.com/pingcap/goleveldb version: 8d44bfdf1030639ae7130922c95df12d6d4da3b6 subpackages: diff --git a/store/tikv/2pc_fail_test.go b/store/tikv/2pc_fail_test.go index 10c57b57b2e35..c1e6e1d2a33ac 100644 --- a/store/tikv/2pc_fail_test.go +++ b/store/tikv/2pc_fail_test.go @@ -10,7 +10,6 @@ // distributed under the License is distributed on an "AS IS" BASIS, // See the License for the specific language governing permissions and // limitations under the License. -// +build gofail package tikv diff --git a/store/tikv/sql_fail_test.go b/store/tikv/sql_fail_test.go index a3d7695bc9cf0..90cc11391485c 100644 --- a/store/tikv/sql_fail_test.go +++ b/store/tikv/sql_fail_test.go @@ -10,7 +10,6 @@ // distributed under the License is distributed on an "AS IS" BASIS, // See the License for the specific language governing permissions and // limitations under the License. -// +build gofail package tikv_test diff --git a/store/tikv/store_fail_test.go b/store/tikv/store_fail_test.go index 3ba9de102dd7a..ce90bf6c31a13 100644 --- a/store/tikv/store_fail_test.go +++ b/store/tikv/store_fail_test.go @@ -10,7 +10,6 @@ // distributed under the License is distributed on an "AS IS" BASIS, // See the License for the specific language governing permissions and // limitations under the License. -// +build gofail package tikv