Skip to content

Commit

Permalink
Merge pull request #66 from zimmski/megacheck
Browse files Browse the repository at this point in the history
Include Megacheck as a linting tool
  • Loading branch information
zimmski committed Oct 31, 2018
2 parents 2f6f3be + d189337 commit 4e8457f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
1 change: 1 addition & 0 deletions Makefile
Expand Up @@ -47,6 +47,7 @@ install-tools:
# linting
go get -u -v golang.org/x/lint/golint/...
go get -u -v github.com/kisielk/errcheck/...
go get -u -v honnef.co/go/tools/cmd/megacheck

# code coverage
go get -u -v golang.org/x/tools/cmd/cover
Expand Down
14 changes: 4 additions & 10 deletions cmd/go-mutesting/main.go
Expand Up @@ -37,12 +37,6 @@ const (
returnError
)

const (
execPassed = 0
execFailed = 1
execSkipped = 2
)

type options struct {
General struct {
Debug bool `long:"debug" description:"Debug log output"`
Expand Down Expand Up @@ -235,7 +229,7 @@ MUTATOR:
}
}

debug(opts, "Enable mutator %q", name)
verbose(opts, "Enable mutator %q", name)

m, _ := mutator.New(name)
mutators = append(mutators, mutatorItem{
Expand All @@ -248,7 +242,7 @@ MUTATOR:
if err != nil {
panic(err)
}
debug(opts, "Save mutations into %q", tmpDir)
verbose(opts, "Save mutations into %q", tmpDir)

var execs []string
if opts.Exec.Exec != "" {
Expand All @@ -258,7 +252,7 @@ MUTATOR:
stats := &mutationStats{}

for _, file := range files {
debug(opts, "Mutate %q", file)
verbose(opts, "Mutate %q", file)

src, fset, pkg, info, err := mutesting.ParseAndTypeCheckFile(file)
if err != nil {
Expand Down Expand Up @@ -293,7 +287,7 @@ MUTATOR:
}
}
} else {
mutationID = mutate(opts, mutators, mutationBlackList, mutationID, pkg, info, file, fset, src, src, tmpFile, execs, stats)
_ = mutate(opts, mutators, mutationBlackList, mutationID, pkg, info, file, fset, src, src, tmpFile, execs, stats)
}
}

Expand Down
4 changes: 4 additions & 0 deletions scripts/lint.sh
Expand Up @@ -19,4 +19,8 @@ echo "golint:"
OUT=$(golint $PKG/... 2>&1 | grep --invert-match -E "(/example)")
if [ -n "$OUT" ]; then echo "$OUT"; PROBLEM=1; fi

echo "megacheck:"
OUT=$(megacheck $PKG/... 2>&1 | grep --invert-match -E "(example/)")
if [ -n "$OUT" ]; then echo "$OUT"; PROBLEM=1; fi

if [ -n "$PROBLEM" ]; then exit 1; fi
2 changes: 1 addition & 1 deletion test/mutator.go
Expand Up @@ -49,7 +49,7 @@ func Mutator(t *testing.T, m mutator.Mutator, testFile string, count int) {
assert.Nil(t, err)

if !assert.Equal(t, string(changedFile), buf.String(), fmt.Sprintf("For change file %q", changedFilename)) {
err = ioutil.WriteFile(fmt.Sprintf("%s.%d.go.new", testFile, i), []byte(buf.String()), 0644)
err = ioutil.WriteFile(fmt.Sprintf("%s.%d.go.new", testFile, i), buf.Bytes(), 0644)
assert.Nil(t, err)
}

Expand Down

0 comments on commit 4e8457f

Please sign in to comment.