diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2018-10-03 14:58:09 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2018-10-16 22:10:56 +0200 |
commit | 35fbfb19a173b01bc881f2bbc5d104136633a7ec (patch) | |
tree | 636d0d51fa262dc808eb3c5cc9cf92ad977a0c6a /hugolib/shortcode_test.go | |
parent | 3a3089121b852332b5744d1f566959c8cf93cef4 (diff) |
commands: Show server error info in browser
The main item in this commit is showing of errors with a file context when running `hugo server`.
This can be turned off: `hugo server --disableBrowserError` (can also be set in `config.toml`).
But to get there, the error handling in Hugo needed a revision. There are some items left TODO for commits soon to follow, most notable errors in content and config files.
Fixes #5284
Fixes #5290
See #5325
See #5324
Diffstat (limited to 'hugolib/shortcode_test.go')
-rw-r--r-- | hugolib/shortcode_test.go | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/hugolib/shortcode_test.go b/hugolib/shortcode_test.go index df7b7103f..3385d31f0 100644 --- a/hugolib/shortcode_test.go +++ b/hugolib/shortcode_test.go @@ -24,8 +24,6 @@ import ( "github.com/spf13/viper" - jww "github.com/spf13/jwalterweatherman" - "github.com/spf13/afero" "github.com/gohugoio/hugo/output" @@ -367,11 +365,11 @@ func TestExtractShortcodes(t *testing.T) { expectErrorMsg string }{ {"text", "Some text.", "map[]", "Some text.", ""}, - {"invalid right delim", "{{< tag }}", "", false, "simple.md:4:.*unrecognized character.*}"}, - {"invalid close", "\n{{< /tag >}}", "", false, "simple.md:5:.*got closing shortcode, but none is open"}, - {"invalid close2", "\n\n{{< tag >}}{{< /anotherTag >}}", "", false, "simple.md:6: closing tag for shortcode 'anotherTag' does not match start tag"}, - {"unterminated quote 1", `{{< figure src="im caption="S" >}}`, "", false, "simple.md:4:.got pos.*"}, - {"unterminated quote 1", `{{< figure src="im" caption="S >}}`, "", false, "simple.md:4:.*unterm.*}"}, + {"invalid right delim", "{{< tag }}", "", false, ":4:.*unrecognized character.*}"}, + {"invalid close", "\n{{< /tag >}}", "", false, ":5:.*got closing shortcode, but none is open"}, + {"invalid close2", "\n\n{{< tag >}}{{< /anotherTag >}}", "", false, ":6: closing tag for shortcode 'anotherTag' does not match start tag"}, + {"unterminated quote 1", `{{< figure src="im caption="S" >}}`, "", false, ":4:.got pos.*"}, + {"unterminated quote 1", `{{< figure src="im" caption="S >}}`, "", false, ":4:.*unterm.*}"}, {"one shortcode, no markup", "{{< tag >}}", "", testScPlaceholderRegexp, ""}, {"one shortcode, markup", "{{% tag %}}", "", testScPlaceholderRegexp, ""}, {"one pos param", "{{% tag param1 %}}", `tag([\"param1\"], true){[]}"]`, testScPlaceholderRegexp, ""}, @@ -384,7 +382,7 @@ func TestExtractShortcodes(t *testing.T) { // issue #934 {"inner self-closing", `Some text. {{< inner />}}. Some more text.`, `inner([], false){[]}`, fmt.Sprintf("Some text. %s. Some more text.", testScPlaceholderRegexp), ""}, - {"close, but not inner", "{{< tag >}}foo{{< /tag >}}", "", false, "Shortcode 'tag' in page 'simple.md' has no .Inner.*"}, + {"close, but not inner", "{{< tag >}}foo{{< /tag >}}", "", false, `shortcode "tag" has no .Inner, yet a closing tag was provided`}, {"nested inner", `Inner->{{< inner >}}Inner Content->{{% inner2 param1 %}}inner2txt{{% /inner2 %}}Inner close->{{< / inner >}}<-done`, `inner([], false){[Inner Content-> inner2([\"param1\"], true){[inner2txt]} Inner close->]}`, fmt.Sprintf("Inner->%s<-done", testScPlaceholderRegexp), ""}, @@ -434,7 +432,7 @@ func TestExtractShortcodes(t *testing.T) { } else { r, _ := regexp.Compile(this.expectErrorMsg) if !r.MatchString(err.Error()) { - t.Fatalf("[%d] %s: ExtractShortcodes didn't return an expected error message, got %s but expected %s", + t.Fatalf("[%d] %s: ExtractShortcodes didn't return an expected error message, got\n%s but expected\n%s", i, this.name, err.Error(), this.expectErrorMsg) } } @@ -777,7 +775,7 @@ NotFound: {{< thisDoesNotExist >}} "thisDoesNotExist", ) - require.Equal(t, uint64(1), s.Log.LogCountForLevel(jww.LevelError)) + require.Equal(t, uint64(1), s.Log.ErrorCounter.Count()) } |