internal/cuetxtar: add field coverage checking
Add field coverage checking to the inline
@test runner: every field in a struct that
contains at least one @test attribute must
be either directly tested or reachable
(transitively) from a tested sibling field.
Coverage propagates via three mechanisms:
- direct identifier references in field
values
- let bindings (let X = fieldA)
- postfix aliases (field~X: ...)
- comprehensions: if a for/if clause
references two fields and one is covered,
the other is covered too
The check recurses into nested struct
literals, so inner fields of test groups
like `testCat: { a: 1 @test(); b: 2 }`
are also checked.
Opt-out via `#no-coverage` in the archive
comment header.
Seven meta-tests in
internal/cuetxtar/testdata/inline/ cover
the failure case, opt-out, fixture files,
propagation, recursion, and comprehension
grouping.
Existing txtar test files in cue/testdata/
have been updated to add @test directives
for previously uncovered inner fields.
Signed-off-by: Marcel van Lohuizen <mpvl@gmail.com>
Change-Id: I484a6312419893e8c34adb5d6b9054ff0cb59b16
Reviewed-on: https://cue.gerrithub.io/c/cue-lang/cue/+/1235980
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>