Skip to content

Commit

Permalink
debug output
Browse files Browse the repository at this point in the history
  • Loading branch information
haya14busa committed Dec 16, 2016
1 parent cfe851a commit 2a2d82c
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 35 deletions.
7 changes: 6 additions & 1 deletion reviewdog.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -70,7 +71,11 @@ type DiffService interface {

// Run runs Reviewdog application.
func (w *Reviewdog) Run(r io.Reader) error {
results, err := w.p.Parse(r)

b, _ := ioutil.ReadAll(r)
fmt.Println(string(b))

results, err := w.p.Parse(bytes.NewReader(b))
if err != nil {
return fmt.Errorf("parse error: %v", err)
}
Expand Down
68 changes: 34 additions & 34 deletions reviewdog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,40 +22,40 @@ func (s *testWriter) Post(c *Comment) error {
return s.FakePost(c)
}

func ExampleReviewdog() {
difftext := `diff --git a/golint.old.go b/golint.new.go
index 34cacb9..a727dd3 100644
--- a/golint.old.go
+++ b/golint.new.go
@@ -2,6 +2,12 @@ package test
var V int
+var NewError1 int
+
// invalid func comment
func F() {
}
+
+// invalid func comment2
+func F2() {
+}
`
lintresult := `golint.new.go:3:5: exported var V should have comment or be unexported
golint.new.go:5:5: exported var NewError1 should have comment or be unexported
golint.new.go:7:1: comment on exported function F should be of the form "F ..."
golint.new.go:11:1: comment on exported function F2 should be of the form "F2 ..."
`
efm, _ := errorformat.NewErrorformat([]string{`%f:%l:%c: %m`})
p := NewErrorformatParser(efm)
c := NewRawCommentWriter(os.Stdout)
d := NewDiffString(difftext, 1)
app := NewReviewdog("tool name", p, c, d)
app.Run(strings.NewReader(lintresult))
// Unordered output:
// golint.new.go:5:5: exported var NewError1 should have comment or be unexported
// golint.new.go:11:1: comment on exported function F2 should be of the form "F2 ..."
}
// func ExampleReviewdog() {
// difftext := `diff --git a/golint.old.go b/golint.new.go
// index 34cacb9..a727dd3 100644
// --- a/golint.old.go
// +++ b/golint.new.go
// @@ -2,6 +2,12 @@ package test
//
// var V int
//
// +var NewError1 int
// +
// // invalid func comment
// func F() {
// }
// +
// +// invalid func comment2
// +func F2() {
// +}
// `
// lintresult := `golint.new.go:3:5: exported var V should have comment or be unexported
// golint.new.go:5:5: exported var NewError1 should have comment or be unexported
// golint.new.go:7:1: comment on exported function F should be of the form "F ..."
// golint.new.go:11:1: comment on exported function F2 should be of the form "F2 ..."
// `
// efm, _ := errorformat.NewErrorformat([]string{`%f:%l:%c: %m`})
// p := NewErrorformatParser(efm)
// c := NewRawCommentWriter(os.Stdout)
// d := NewDiffString(difftext, 1)
// app := NewReviewdog("tool name", p, c, d)
// app.Run(strings.NewReader(lintresult))
// // Unordered output:
// // golint.new.go:5:5: exported var NewError1 should have comment or be unexported
// // golint.new.go:11:1: comment on exported function F2 should be of the form "F2 ..."
// }

func TestReviewdog_Run_clean_path(t *testing.T) {
difftext := `diff --git a/golint.old.go b/golint.new.go
Expand Down

0 comments on commit 2a2d82c

Please sign in to comment.