-
Notifications
You must be signed in to change notification settings - Fork 294
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/cue: implement --language-version flag for cue mod edit and init
This allows the language version to be chosen at `cue mod init` time and also to be changed later. Fixes #3247. Fixes #2920. Signed-off-by: Roger Peppe <[email protected]> Change-Id: Iaa7324d164242ecc8ff6ce793e16dfaf88a532b4 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1196822 TryBot-Result: CUEcueckoo <[email protected]> Unity-Result: CUE porcuepine <[email protected]> Reviewed-by: Paul Jolly <[email protected]>
- Loading branch information
Showing
8 changed files
with
166 additions
and
44 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
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
43 changes: 43 additions & 0 deletions
43
cmd/cue/cmd/testdata/script/modinit_with_explicit_version.txtar
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Check we can initialize the module with an explicit version. | ||
|
||
# Set current version. | ||
exec cue mod init --language-version current foo.example | ||
cmpenv cue.mod/module.cue want-module-1 | ||
rm cue.mod | ||
|
||
# Set specific version. | ||
exec cue mod init --language-version v0.9.2 foo.example | ||
cmp cue.mod/module.cue want-module-2 | ||
rm cue.mod | ||
|
||
# Set version earlier than earliest module schema version. | ||
! exec cue mod init --language-version v0.4.3 foo.example | ||
cmp stderr want-stderr-3 | ||
rm cue.mod | ||
|
||
# Set version too new. | ||
! exec cue mod init --language-version v2.3.4 foo.example | ||
cmp stderr want-stderr-4 | ||
rm cue.mod | ||
|
||
# Set version that's incompatible with the source field. | ||
! exec cue mod init --language-version v0.8.0 --source self foo.example | ||
cmp stderr want-stderr-5 | ||
rm cue.mod | ||
|
||
-- want-module-1 -- | ||
module: "foo.example" | ||
language: { | ||
version: "$CUE_LANGUAGE_VERSION" | ||
} | ||
-- want-module-2 -- | ||
module: "foo.example" | ||
language: { | ||
version: "v0.9.2" | ||
} | ||
-- want-stderr-3 -- | ||
language version "v0.4.3" is too early for module.cue schema (earliest allowed is v0.8.0-alpha.0) | ||
-- want-stderr-4 -- | ||
language version "v2.3.4" may not be after current language version v0.10.0 | ||
-- want-stderr-5 -- | ||
cannot parse result: invalid module.cue file: source field is not allowed at this language version; need at least 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