-
Notifications
You must be signed in to change notification settings - Fork 278
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/cue: more resilient mod init version
Before now, if there wasn't an available version, `cue mod init` would create a module file with no language version. However as the language version field is now mandatory, this isn't a good approach. Instead, we sanity check that the version is at least the minimum supported version and use the fallback version otherwise. Technically we could compare with the fallback version instead, because the actual version should always be at least that, but tests often use a fixed version that's not kept up to date, so this approach seems a bit better. Signed-off-by: Roger Peppe <rogpeppe@gmail.com> Change-Id: I732c94467285a2c5d502b67c4ba0616e6bb1a53b Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1193331 TryBot-Result: CUEcueckoo <cueckoo@cuelang.org> Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
- Loading branch information
Showing
5 changed files
with
83 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,19 @@ | ||
# Check that cue mod init fails when it lacks any version | ||
# information at all. | ||
# Check that cue mod init uses the latest schema | ||
# 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 stderr want-stderr | ||
exec cue mod init foo.example | ||
cmp cue.mod/module.cue want-module | ||
|
||
-- want-stderr -- | ||
cannot round-trip module file: no language version declared in module.cue | ||
|
||
# cue mod tidy should be a no-op after cue mod init | ||
env CUE_CACHE_DIR=$WORK/.tmp/cache | ||
exec cue mod tidy | ||
cmp cue.mod/module.cue want-module | ||
|
||
-- want-module -- | ||
module: "foo.example@v0" | ||
language: { | ||
version: "v0.9.0-alpha.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters