Skip to content

Commit

Permalink
*: enable gofail for make dev. (#5325)
Browse files Browse the repository at this point in the history
* *: update go-check

* *: enable gofail for make dev.
  • Loading branch information
disksing authored and coocood committed Dec 6, 2017
1 parent f3b5975 commit 54f0195
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 17 deletions.
18 changes: 7 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
16 changes: 15 additions & 1 deletion _vendor/src/github.com/pingcap/check/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 {
Expand All @@ -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)
}
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions _vendor/src/github.com/pingcap/check/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion glide.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion glide.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 0 additions & 1 deletion store/tikv/2pc_fail_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion store/tikv/sql_fail_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion store/tikv/store_fail_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 54f0195

Please sign in to comment.