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 testscript running commands inside cue.mod

Test running cue commands inside the cue.mod directory,
as well as interacting with packages and files inside of it.

CUE files "inside a module" should be in a directory tree that contains
a cue.mod directory, but not actually inside the cue.mod directory.
However, it's easy for new users to think otherwise and drop CUE code
inside the cue.mod directory somewhere, leading to confusing results.

This commit does not change any behavior; we simply reflect
the current behavior via a test.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: I943f8b29e2bceb7a480b0b2c11d9cb6772bb4ffa
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1229768
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Reviewed-by: Matthew Sackman <matthew@cue.works>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>

+75
+75
cmd/cue/cmd/testdata/script/inside_cuemod.txtar
··· 1 + # Test running cue commands inside the cue.mod directory, 2 + # as well as interacting with packages and files inside of it. 3 + # 4 + # CUE files "inside a module" should be in a directory tree that contains 5 + # a cue.mod directory, but not actually inside the cue.mod directory itself. 6 + # However, it's easy for new users to think otherwise and drop their CUE code 7 + # inside the cue.mod directory somewhere, which can lead to confusing results. 8 + 9 + # From the module root, reaching into cue.mod. 10 + ! exec cue export ./cue.mod 11 + stderr 'unknown file extension .mod' 12 + # TODO: should this work? perhaps offer `cue mod edit --json` like Go does. 13 + exec cue export cue.mod/module.cue 14 + cmp stdout $WORK/export-module.stdout 15 + 16 + # From cue.mod, reaching into the module root. 17 + # TODO: none of these should work; we should guide the user outside of cue.mod. 18 + # Note that some of these did not work on Windows either. 19 + cd $WORK/cue.mod 20 + [!windows] exec cue export .. 21 + exec cue export ../root.cue 22 + 23 + # From cue.mod. 24 + # TODO: none of these should work; we should guide the user outside of cue.mod. 25 + cd $WORK/cue.mod 26 + exec cue mod tidy 27 + exec cue export . 28 + exec cue export somefile.cue 29 + exec cue export module.cue 30 + # Interestingly, these fail but with internal or confusing errors. 31 + ! exec cue export ./subdir 32 + stderr 'internal error:.*non-internal package' 33 + ! exec cue vet ./... 34 + stderr 'pattern not allowed in external package path' 35 + 36 + # From cue.mod/subdir. 37 + # TODO: none of these should work; we should guide the user outside of cue.mod. 38 + cd $WORK/cue.mod/subdir 39 + exec cue mod tidy 40 + exec cue export . 41 + 42 + # From cue.mod/pkg/foo.com/bar. 43 + # Arguably this should not work, but historically it has, and placing packages 44 + # in this directory structure is still supported as the old mechanism 45 + # to add package dependencies. For now, it continues to work. 46 + cd $WORK/cue.mod/pkg/foo.com/bar 47 + exec cue export . 48 + 49 + -- root.cue -- 50 + package root 51 + 52 + location: "at module root" 53 + -- cue.mod/module.cue -- 54 + module: "example.com@v0" 55 + language: version: "v0.9.0" 56 + 57 + -- cue.mod/somefile.cue -- 58 + package somefile 59 + 60 + location: "in cue.mod" 61 + -- cue.mod/subdir/data.cue -- 62 + package subdir 63 + 64 + location: "in cue.mod/subdir" 65 + -- cue.mod/pkg/foo.com/bar/data.cue -- 66 + package bar 67 + 68 + location: "in cue.mod/pkg/foo.com/bar" 69 + -- export-module.stdout -- 70 + { 71 + "module": "example.com@v0", 72 + "language": { 73 + "version": "v0.9.0" 74 + } 75 + }