this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

cue: teach the fuzzer to cover cue/format, ast.Walk, and astutil.Apply

These need to support all forms of valid syntax, for example.
They cannot fail or panic on input that worked with cue/parser either.

This already catches the fact that cue/ast/astutil missed
adding support for the new cue/ast.TryClause; fix that.
We must fix it at the same time to not break `go test`.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: Id0a08cf1739a00aaba6c5bd052c0f3a89ceff6b3
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1234632
Reviewed-by: Matthew Sackman <matthew@cue.works>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>

+23 -1
+6
cue/ast/astutil/apply.go
··· 496 496 case *ast.FallbackClause: 497 497 apply(v, c, &n.Body) 498 498 499 + case *ast.TryClause: 500 + if n.Ident != nil { 501 + apply(v, c, &n.Ident) 502 + apply(v, c, &n.Expr) 503 + } 504 + 499 505 default: 500 506 panic(fmt.Sprintf("Walk: unexpected node type %T", n)) 501 507 }
+17 -1
cue/fuzz_test.go
··· 17 17 import ( 18 18 "testing" 19 19 20 + "cuelang.org/go/cue/ast" 21 + "cuelang.org/go/cue/ast/astutil" 22 + "cuelang.org/go/cue/format" 20 23 "cuelang.org/go/cue/parser" 21 24 ) 22 25 ··· 62 65 if len(s) > 100 { 63 66 t.Skip() // keep inputs reasonably small for now 64 67 } 65 - _, err := parser.ParseFile("fuzz.cue", s, parser.ParseComments) 68 + f, err := parser.ParseFile("fuzz.cue", s, parser.ParseComments) 66 69 if err != nil { 67 70 t.Skip() // skip inputs which aren't valid syntax 68 71 } 72 + 73 + // Common operations with the syntax tree. 74 + if _, err := format.Node(f); err != nil { 75 + t.Fatalf("cue/format should not fail on parsed input: %v", err) 76 + } 77 + ast.Walk(f, 78 + func(ast.Node) bool { return true }, 79 + func(ast.Node) {}, 80 + ) 81 + astutil.Apply(f, 82 + func(astutil.Cursor) bool { return true }, 83 + func(astutil.Cursor) bool { return true }, 84 + ) 69 85 70 86 // TODO: cover the compiler and evaluator, and various common operations like export 71 87 // ctx := cuecontext.New()