diff --git a/url_test.go b/url_test.go index a3f02ce..3cdf9f9 100644 --- a/url_test.go +++ b/url_test.go @@ -57,13 +57,17 @@ func printURLTree(t *testing.T, a Node) { notation.Lprintw(t, a) } -func urlParser() func(string) (Node, error) { +func urlParser(trace bool) func(string) (Node, error) { b, err := os.ReadFile("doc/example/url.treerack") if err != nil { panic(err) } p := new(Syntax) + if trace { + p.MaxTraceLength = 180 + } + if err = p.ReadSyntax(bytes.NewBuffer(b)); err != nil { panic(err) } @@ -1524,12 +1528,13 @@ func TestURL(t *testing.T) { } var d time.Duration - p := urlParser() + p := urlParser(test.bench <= 0) for i := 0; i < n && !t.Failed(); i++ { start := time.Now() a, err := p(test.input) d += time.Since(start) if err != nil { + Trace(t.Output(), err) t.Fatal(err) } @@ -1581,7 +1586,7 @@ func TestURLErrors(t *testing.T) { input: "http://foo.bar/foo%xbar", }} { t.Run(test.title, func(t *testing.T) { - p := urlParser() + p := urlParser(false) if a, err := p(test.input); err == nil { printURLTree(t, a) t.Fatal("failed to fail", test.input)