Skip to content

Commit

Permalink
cmd/cue: repurpose modinit test for language.version
Browse files Browse the repository at this point in the history
Since we added fallbackVersion in https://cuelang.org/cl/1177860,
the norm is for `cue mod init` to add a language.version field,
and it should only be skipped in the rare case where a version exists
but it is somehow invalid, such as being inserted via ldflags.

All other modinit tests already check that we insert a version
by using $CUE_VERSION_OVERRIDE like this test used to.
Make this test useful by testing the now-rare edge case of no version.

Also make setting CUE_EXPERIMENT=modules explicit rather than
via the _registry directory, which is less obvious and more verbose.

Signed-off-by: Daniel Martí <[email protected]>
Change-Id: Ieb92e397b472323bf0d00df17fa3093cf259450c
Dispatch-Trailer: {"type":"trybot","CL":1182873,"patchset":1,"ref":"refs/changes/73/1182873/1","targetBranch":"master"}
  • Loading branch information
mvdan authored and cueckoo committed Mar 14, 2024
1 parent d5ecd6c commit 954a765
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
18 changes: 0 additions & 18 deletions cmd/cue/cmd/testdata/script/modinit_with_version.txtar

This file was deleted.

14 changes: 14 additions & 0 deletions cmd/cue/cmd/testdata/script/modinit_without_version.txtar
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Check that cue mod init skips the language version
# when it lacks any version information at all.
# A zero pseudo-version is one such case, as there are no semver numbers.
env CUE_EXPERIMENT=modules
env CUE_VERSION_OVERRIDE=v0.0.0-00010101000000-000000000000
exec cue mod init foo.example
cmp cue.mod/module.cue want-module

# cue mod tidy should be a no-op after cue mod init
exec cue mod tidy
cmp cue.mod/module.cue want-module

-- want-module --
module: "foo.example@v0"

0 comments on commit 954a765

Please sign in to comment.