From cad9ae400e34a1199882e4cf5f545a97b8feab12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Wed, 18 Sep 2024 15:07:05 +0100 Subject: [PATCH] encoding/jsonschema: do not let cue/load walk up to the git root MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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í Change-Id: Icf1555286be13c40defd33889f99009bcc001e22 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1201439 TryBot-Result: CUEcueckoo Reviewed-by: Roger Peppe --- encoding/jsonschema/internal/externaltest/tests.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/encoding/jsonschema/internal/externaltest/tests.go b/encoding/jsonschema/internal/externaltest/tests.go index cfd3975a7b0..a8088539bec 100644 --- a/encoding/jsonschema/internal/externaltest/tests.go +++ b/encoding/jsonschema/internal/externaltest/tests.go @@ -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