From 1b2d11c201d11c5d05fcacfc637e246cb9fe219e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Mon, 16 Dec 2024 15:07:18 +0000 Subject: [PATCH] internal/cueexperiment: enable embed experiment by default MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As Paul announced in the embed proposal discussion on GitHub [1], we have moved the proposal to a "likely accept" stage and we are enabling the feature by defalut for CUE v0.12. Enable it by default for the first alpha, v0.12.0-alpha.1, for the sake of giving it as much testing as possible before v0.12.0. While here, update the TODOs in the symlink embedding testscript file. We ended up deciding to support symlinks, but the test wasn't updated. [1]: https://cuelang.org/discussion/3264 Signed-off-by: Daniel Martí Change-Id: I499940a2dc799552963783174ed30dc0a312d925 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1205861 Unity-Result: CUE porcuepine TryBot-Result: CUEcueckoo Reviewed-by: Paul Jolly --- cmd/cue/cmd/help.go | 4 ++-- cmd/cue/cmd/testdata/script/embed.txtar | 5 +++-- cmd/cue/cmd/testdata/script/embed_err.txtar | 7 ++----- cmd/cue/cmd/testdata/script/embed_file_err.txtar | 1 - cmd/cue/cmd/testdata/script/embed_mod.txtar | 2 -- cmd/cue/cmd/testdata/script/embed_windows.txtar | 2 -- encoding/jsonschema/internal/externaltest/tests.go | 1 - internal/cueexperiment/exp.go | 2 +- 8 files changed, 8 insertions(+), 16 deletions(-) diff --git a/cmd/cue/cmd/help.go b/cmd/cue/cmd/help.go index 3492b21587f..94d21982f0e 100644 --- a/cmd/cue/cmd/help.go +++ b/cmd/cue/cmd/help.go @@ -254,8 +254,8 @@ and use APIs like yaml.Extract to decode as a list. Note that embedding cue files is not supported at this time. -Note: support for embed is experimental, and is enabled via -CUE_EXPERIMENT=embed. +Note: support for embed is experimental, and can be disabled via +CUE_EXPERIMENT=embed=0. For more details and discussion, see the proposal linked from https://cuelang.org/discussion/3264. diff --git a/cmd/cue/cmd/testdata/script/embed.txtar b/cmd/cue/cmd/testdata/script/embed.txtar index 206bcfb3c2e..f5e747b5a63 100644 --- a/cmd/cue/cmd/testdata/script/embed.txtar +++ b/cmd/cue/cmd/testdata/script/embed.txtar @@ -1,7 +1,8 @@ +# Embedding is enabled by default, but it can still be disabled. +env CUE_EXPERIMENT=embed=0 ! exec cue eval cmp stderr out/noembed - -env CUE_EXPERIMENT=embed +env CUE_EXPERIMENT= exec cue eval cmp stdout out/eval diff --git a/cmd/cue/cmd/testdata/script/embed_err.txtar b/cmd/cue/cmd/testdata/script/embed_err.txtar index a4c6de9601c..2abc1095622 100644 --- a/cmd/cue/cmd/testdata/script/embed_err.txtar +++ b/cmd/cue/cmd/testdata/script/embed_err.txtar @@ -1,12 +1,9 @@ -env CUE_EXPERIMENT=embed - ! exec cue eval ! stdout . cmp stderr out/err -# On systems with symlink support, check that we don't allow embedding symlinks. -# TODO(mvdan): we don't reject valid symlinks yet; see https://cuelang.org/issue/3299. -# TODO: if we support symlinks in the future, add a test case for a symlink pointing to a file +# On systems with symlink support, we follow symlinks when embedding files. +# TODO: add a test case for a symlink pointing to a file # outside of the current module, as that should likely be forbidden. [!symlink] stop cd symlink diff --git a/cmd/cue/cmd/testdata/script/embed_file_err.txtar b/cmd/cue/cmd/testdata/script/embed_file_err.txtar index d2d7ab5cdcc..2fc9e0979cf 100644 --- a/cmd/cue/cmd/testdata/script/embed_file_err.txtar +++ b/cmd/cue/cmd/testdata/script/embed_file_err.txtar @@ -1,7 +1,6 @@ # Test what happens when there is an error an embedded file. # The error should mention the name of the file where the error is. -env CUE_EXPERIMENT=embed ! exec cue vet cmp stderr want-stderr ! exec cue export diff --git a/cmd/cue/cmd/testdata/script/embed_mod.txtar b/cmd/cue/cmd/testdata/script/embed_mod.txtar index ab162a97593..d0e102f1c95 100644 --- a/cmd/cue/cmd/testdata/script/embed_mod.txtar +++ b/cmd/cue/cmd/testdata/script/embed_mod.txtar @@ -1,5 +1,3 @@ -env CUE_EXPERIMENT=embed - exec cue mod tidy exec cue eval ./acme/foo cmp stdout out/eval diff --git a/cmd/cue/cmd/testdata/script/embed_windows.txtar b/cmd/cue/cmd/testdata/script/embed_windows.txtar index df4ba9f2a36..4228729dce3 100644 --- a/cmd/cue/cmd/testdata/script/embed_windows.txtar +++ b/cmd/cue/cmd/testdata/script/embed_windows.txtar @@ -1,5 +1,3 @@ -env CUE_EXPERIMENT=embed - [!windows] cp reuse.json 'star/*.json' [!windows] exec cue export --out cue [!windows] cmp stdout out/export-unix diff --git a/encoding/jsonschema/internal/externaltest/tests.go b/encoding/jsonschema/internal/externaltest/tests.go index 25ad90f39e3..a45a170ae42 100644 --- a/encoding/jsonschema/internal/externaltest/tests.go +++ b/encoding/jsonschema/internal/externaltest/tests.go @@ -88,7 +88,6 @@ func ReadTestDir(dir string) (tests map[string][]*Schema, err error) { } return nil, err } - 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 diff --git a/internal/cueexperiment/exp.go b/internal/cueexperiment/exp.go index 5f85fe958b3..f724522359c 100644 --- a/internal/cueexperiment/exp.go +++ b/internal/cueexperiment/exp.go @@ -20,7 +20,7 @@ var Flags struct { EvalV3 bool // Embed enables file embedding. - Embed bool + Embed bool `envflag:"default:true"` // DecodeInt64 changes [cuelang.org/go/cue.Value.Decode] to choose // `int64` rather than `int` as the default type for CUE integer values