Skip to content

Commit

Permalink
encoding/jsonschema: do not let cue/load walk up to the git root
Browse files Browse the repository at this point in the history
When using `GODEBUG=gocachehash=1 go test .`, the number of testInput
lines goes down dramatically after the change, as the test cache logic
no longer needs to stat hundreds of files in parent directories.

    $ grep testInput before.txt | wc -l
    3960
    $ grep testInput after.txt | wc -l
    1291

Signed-off-by: Daniel Martí <[email protected]>
Change-Id: Icf1555286be13c40defd33889f99009bcc001e22
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1201439
TryBot-Result: CUEcueckoo <[email protected]>
Reviewed-by: Roger Peppe <[email protected]>
  • Loading branch information
mvdan committed Sep 18, 2024
1 parent 3ade70e commit cad9ae4
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions encoding/jsonschema/internal/externaltest/tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ func ReadTestDir(dir string) (tests map[string][]*Schema, err error) {
os.Setenv("CUE_EXPERIMENT", "embed")
inst := load.Instances([]string{"."}, &load.Config{
Dir: dir,
// Just like in the cue/load tests, prevent Go tests from walking up to the root
// directory of the git repository, as that almost always causes test cache misses.
ModuleRoot: dir,
})[0]
if err := inst.Err; err != nil {
return nil, err
Expand Down

0 comments on commit cad9ae4

Please sign in to comment.