Skip to content

Commit

Permalink
cmd/cue: add test for mod edit strictness
Browse files Browse the repository at this point in the history
This CL adds a check for `cue mod edit` when
run on a module.cue file that is not acceptable to
strict checking, in preparation for a change
to make it work even with non-strict files.

It also changes the `cue mod tidy` check to ensure that
it adds major versions to dependency modules when
they are not present and that the major version is
not added when not already present. These are both
things that should probably have been tested here before
but were not.

Signed-off-by: Roger Peppe <rogpeppe@gmail.com>
Change-Id: Ib1229a27c962315a51a66c87608d1022cde3b5e8
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1196179
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1196233
Reviewed-by: Paul Jolly <paul@myitcv.io>
  • Loading branch information
rogpeppe authored and myitcv committed Jun 12, 2024
1 parent fc6d421 commit 7ceb629
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
12 changes: 12 additions & 0 deletions cmd/cue/cmd/testdata/script/modedit_nonstrict.txtar
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This test checks that cue mod edit works OK even when the
# module file doesn't conform to the strict parsing.
# TODO fix this to pass.
! exec cue mod edit --source self
cmpenv stderr want-stderr

-- cue.mod/module.cue --
module: "main.org"
deps: "foo.com": v: "v1.2.3"
language: version: "v0.9.0-alpha.0"
-- want-stderr --
invalid module.cue file $WORK${/}cue.mod${/}module.cue: no major version in "foo.com"
6 changes: 3 additions & 3 deletions cmd/cue/cmd/testdata/script/modtidy_initial.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ cmp stdout cue-cache-dir.files
# Unused dependencies should not have their entire source downloaded or extracted.
! stdout 'unused\.com.*\.zip$'
-- want-module --
module: "main.org@v0"
module: "main.org"
language: {
version: "v0.8.0"
}
Expand Down Expand Up @@ -47,10 +47,10 @@ deps: {
"example.com@v0": "v0.0.1"
}
-- cue.mod/module.cue --
module: "main.org@v0"
module: "main.org"
language: version: "v0.8.0"

deps: "example.com@v0": v: "v0.0.1"
deps: "example.com": v: "v0.0.1"
deps: "unused.com@v0": v: "v0.2.4"

-- main.cue --
Expand Down

0 comments on commit 7ceb629

Please sign in to comment.