Skip to content

Commit

Permalink
fail when config contains invalid yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
ezekg committed Apr 26, 2016
1 parent 196ff6d commit be71bf2
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
2 changes: 1 addition & 1 deletion hound.go
Expand Up @@ -33,7 +33,7 @@ func (h *Hound) New() bool {

err = h.parseConfig(config)
if err != nil {
return false
panic(err)
}

return true
Expand Down
18 changes: 18 additions & 0 deletions hound_test.go
Expand Up @@ -201,6 +201,24 @@ index 000000..000000 000000
t.Logf("Did pass")
}
}

// Should fail when invalid Yaml is detected
{
badConfig := []byte(`
warn:
- 'string without a closing single quote
fail:
- 'some other string'
skip:
- '/bad.go
`)

if err := hound.parseConfig(badConfig); err != nil {
t.Logf("Did not parse")
} else {
t.Fatalf("Should not parse")
}
}
}

func getDiff(t *testing.T, diffContents string) (string, *diff.Hunk) {
Expand Down
9 changes: 8 additions & 1 deletion main.go
Expand Up @@ -13,14 +13,21 @@ import (
)

var (
version = "0.5.2"
version = "0.5.3"
showVersion = flag.Bool("v", false, "Show version")
noColor = flag.Bool("no-color", false, "Disable color output")
config = flag.String("config", ".githound.yml", "Hound config file")
bin = flag.String("bin", "git", "Executable binary to use for git command")
)

func main() {
defer func() {
if r := recover(); r != nil {
color.Red(fmt.Sprintf("error: %s\n", r))
os.Exit(1)
}
}()

flag.Parse()

if *showVersion {
Expand Down

0 comments on commit be71bf2

Please sign in to comment.