this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

cmd/cue: add a forwards compatibility test case for bugfix releases

When loading a CUE module which uses a higher language.version than
the current language version supported by cmd/cue, it does not matter
whether the version is higher due to a higher bugfix number
or a higher minor or even major number.

We treat the language.version version as a hard version minimum,
even though the language spec should not change in bugfix releases,
for the sake of consistent and intuitive behavior.
language.version also affects the module.cue file schema to use,
and that can indeed change in bugfix releases from time to time.

We already had a test case for a CUE module with a higher minor number
in its language.version; add one with a higher bugfix number as well.

While here, move "cd" testscript commands to be next to the top-level
comment which describes each test case set up via txtar.

For #3197.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: Ied3603b95662656fa45063421f730e7788646b8e
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1196300
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Reviewed-by: Paul Jolly <paul@myitcv.io>
Reviewed-by: Roger Peppe <rogpeppe@gmail.com>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>

+60 -3
+5
cmd/cue/cmd/script_test.go
··· 47 47 "cuelang.org/go/cue/parser" 48 48 "cuelang.org/go/internal/cuetest" 49 49 "cuelang.org/go/internal/cueversion" 50 + "cuelang.org/go/internal/mod/semver" 50 51 "cuelang.org/go/internal/registrytest" 51 52 ) 52 53 ··· 257 258 e.Vars = append(e.Vars, 258 259 "GOPROXY="+srv.URL, 259 260 "GONOSUMDB=*", // GOPROXY is a private proxy 261 + 262 + // The current language version which would be added by `cue mod init`, e.g. v0.10.0. 260 263 "CUE_LANGUAGE_VERSION="+cueversion.LanguageVersion(), 264 + // A later language version which only increases the bugfix release, e.g. v0.10.99. 265 + "CUE_LANGUAGE_VERSION_BUGFIX="+semver.MajorMinor(cueversion.LanguageVersion())+".99", 261 266 ) 262 267 entries, err := os.ReadDir(e.WorkDir) 263 268 if err != nil {
+2 -2
cmd/cue/cmd/testdata/script/module_compatibility_backwards.txtar
··· 17 17 18 18 # A module that was created before the modules experiment, 19 19 # without a major version suffix nor a language version. 20 + cd ${WORK}/premodules 20 21 21 22 # Downstream consumption via cue.mod/*/ works. 22 23 # Downstream consumption via a registry is not possible as its module path lacks a major version suffix. 23 - cd ${WORK}/premodules 24 24 exec cue export 25 25 stdout '"downstream": "hello from premodules.example"' 26 26 ··· 56 56 57 57 58 58 # A module that was created with a language.version of v0.8.0. 59 + cd ${WORK}/v0.8.0-downstream-deps 59 60 60 61 # Downstream consumption via a registry works. 61 62 # Note that we need to point CUE_REGISTRY back to the contents inside _registry/ below. 62 63 env CUE_REGISTRY=${ORIG_CUE_REGISTRY} 63 - cd ${WORK}/v0.8.0-downstream-deps 64 64 exec cue export 65 65 stdout '"downstream": "hello from v0.8.0.example"' 66 66 env CUE_REGISTRY=$MEMREGISTRY+insecure
+53 -1
cmd/cue/cmd/testdata/script/module_compatibility_forwards.txtar
··· 9 9 # cover scenarios where just one of them is too new, 10 10 # as we should allow downstream consumption when only the module schema version is too new. 11 11 12 - # A module that was created with a language.version of v0.99.0 in the far future. 12 + # A module that was created with a language.version of ${CUE_LANGUAGE_VERSION_BUGFIX}, 13 + # which is like the current ${CUE_LANGUAGE_VERSION} but with a higher bugfix release. 14 + # For example, if ${CUE_LANGUAGE_VERSION} is v0.10.0 or v0.10.5, ${CUE_LANGUAGE_VERSION_BUGFIX} is v0.10.99. 15 + # Even though the language spec should not change in bugfix releases, 16 + # we still treat the language version as a hard minimum following semver. 17 + cd ${WORK}/bugfix-newer 18 + env-fill cue.mod/pkg/bugfix-newer.example/cue.mod/module.cue 13 19 14 20 # TODO(mvdan): downstream consumption via cue.mod/*/ works when it should not, 15 21 # because we do not yet use language.version as a minimum for parsing or evaluating CUE. 22 + exec cue export 23 + stdout '"downstream": "hello from bugfix-newer.example"' 24 + 25 + # TODO(mvdan): test downstream consumption via a registry; note that _registry/ complains 26 + # because it is unable to parse the module.cue file with a schema that is too new. 27 + 28 + # Continue inside the module's own directory as if we had cloned it directly. 29 + cd ${WORK} 30 + mv bugfix-newer/cue.mod/pkg/bugfix-newer.example bugfix-newer-downstream-direct 31 + cd bugfix-newer-downstream-direct 32 + 33 + # Downstream consumption via `cue export` does not work as we don't support the language spec version. 34 + ! exec cue export 35 + cmp stderr ${WORK}/bugfix-newer-toonew.stderr 36 + 37 + # Upstream development and publishing is forbidden as we don't have or understand the schema. 38 + ! exec cue mod tidy --check 39 + cmp stderr ${WORK}/bugfix-newer-toonew.stderr 40 + ! exec cue mod publish v0.0.2 41 + cmp stderr ${WORK}/bugfix-newer-toonew.stderr 42 + 43 + 44 + # A module that was created with a language.version of v0.99.0 in the far future. 16 45 cd ${WORK}/v0.99.0 46 + 47 + # TODO(mvdan): downstream consumption via cue.mod/*/ works when it should not, 48 + # because we do not yet use language.version as a minimum for parsing or evaluating CUE. 17 49 exec cue export 18 50 stdout '"downstream": "hello from v0.99.0.example"' 19 51 ··· 34 66 cmp stderr ${WORK}/v0.99.0-toonew.stderr 35 67 ! exec cue mod publish v0.0.2 36 68 cmp stderr ${WORK}/v0.99.0-toonew.stderr 69 + 70 + -- bugfix-newer-toonew.stderr -- 71 + language version "v0.10.99" declared in module.cue is too new for current language version "v0.10.0" 72 + -- bugfix-newer/cue.mod/module.cue -- 73 + module: "downstream.example" 74 + language: version: "v0.9.0" 75 + -- bugfix-newer/downstream.cue -- 76 + package downstream 77 + import "bugfix-newer.example:root" 78 + downstream: root 79 + -- bugfix-newer/cue.mod/pkg/bugfix-newer.example/cue.mod/module.cue -- 80 + module: "bugfix-newer.example" 81 + language: version: "${CUE_LANGUAGE_VERSION_BUGFIX}" 82 + -- bugfix-newer/cue.mod/pkg/bugfix-newer.example/root.cue -- 83 + package root 84 + import "bugfix-newer.example/subpkg" 85 + subpkg 86 + -- bugfix-newer/cue.mod/pkg/bugfix-newer.example/subpkg/subpkg.cue -- 87 + package subpkg 88 + "hello from bugfix-newer.example" 37 89 38 90 -- v0.99.0-toonew.stderr -- 39 91 language version "v0.99.0" declared in module.cue is too new for current language version "v0.10.0"