Skip to content

Commit

Permalink
internal/cueexperiment: enable embed experiment by default
Browse files Browse the repository at this point in the history
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í <mvdan@mvdan.cc>
Change-Id: I499940a2dc799552963783174ed30dc0a312d925
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1205861
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Reviewed-by: Paul Jolly <paul@myitcv.io>
  • Loading branch information
mvdan committed Dec 18, 2024
1 parent 4f8b741 commit 1b2d11c
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 16 deletions.
4 changes: 2 additions & 2 deletions cmd/cue/cmd/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 3 additions & 2 deletions cmd/cue/cmd/testdata/script/embed.txtar
Original file line number Diff line number Diff line change
@@ -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
Expand Down
7 changes: 2 additions & 5 deletions cmd/cue/cmd/testdata/script/embed_err.txtar
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 0 additions & 1 deletion cmd/cue/cmd/testdata/script/embed_file_err.txtar
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 0 additions & 2 deletions cmd/cue/cmd/testdata/script/embed_mod.txtar
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
env CUE_EXPERIMENT=embed

exec cue mod tidy
exec cue eval ./acme/foo
cmp stdout out/eval
Expand Down
2 changes: 0 additions & 2 deletions cmd/cue/cmd/testdata/script/embed_windows.txtar
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 0 additions & 1 deletion encoding/jsonschema/internal/externaltest/tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion internal/cueexperiment/exp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1b2d11c

Please sign in to comment.