-
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,cue/load: add tests for underscore packages
This change adds some tests that cover CUE's behavior with respect to underscore package identifiers. See issue #3167 for some previous discussion on this area. For #3167 For #3244 Signed-off-by: Roger Peppe <[email protected]> Change-Id: Ib99400373e49065be6cbe50642c771a19df571d5 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1196719 Reviewed-by: Daniel Martí <[email protected]> TryBot-Result: CUEcueckoo <[email protected]> Unity-Result: CUE porcuepine <[email protected]>
- Loading branch information
Showing
15 changed files
with
153 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,8 +36,6 @@ cd .. | |
-- data.cue -- | ||
foo:3 | ||
-- t.cue -- | ||
package _ | ||
|
||
foo: int | ||
bar: 3 | ||
-- kube.cue -- | ||
|
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,34 @@ | ||
# Test whether an import with a _ qualifer is allowed or not. | ||
|
||
# TODO(rog): this should fail; see https://cuelang.org/issue/3167 | ||
exec cue export ./foo | ||
cmp stdout want-stdout | ||
|
||
# Check that it also fails with an explicit _ qualifier | ||
# specified on the command line. | ||
# TODO(rog): this should fail similarly. | ||
exec cue export other.example/m:_ | ||
cmp stdout want-stdout | ||
-- want-stdout -- | ||
{ | ||
"x": 20 | ||
} | ||
-- cue.mod/gen/other.example/m/m.cue -- | ||
package _ | ||
x: 20 | ||
|
||
-- cue.mod/module.cue -- | ||
module: "test.example/foo" | ||
language: version: "v0.9.0" | ||
|
||
-- foo/foo.cue -- | ||
// Note: the package name does not match the directory name, | ||
// which means that this is only resolvable with an explicit | ||
// qualifier when used as an import path, but is allowed | ||
// on the cue command line because there's only one | ||
// package in the directory. | ||
package bar | ||
|
||
import m "other.example/m:_" | ||
|
||
x: m.x |
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,35 @@ | ||
# Test that the command-line "allow single package | ||
# even when the package name does not match the import | ||
# path" logic works correctly in the presence of an | ||
# non-package CUE file, which can never be part | ||
# of a package. | ||
# See https://cuelang.org/issue/3244 | ||
|
||
cd foo | ||
# TODO(rog): this should succeed | ||
! exec cue export | ||
cmp stderr $WORK/want-stderr | ||
-- want-stderr -- | ||
test.example/foo@v0: import failed: no dependency found for package "other.example/m": | ||
./foo.cue:8:8 | ||
-- cue.mod/gen/other.example/m/m.cue -- | ||
package m | ||
x: 20 | ||
|
||
-- cue.mod/module.cue -- | ||
module: "test.example" | ||
language: version: "v0.9.0" | ||
|
||
-- foo/foo.cue -- | ||
// Note: the package name does not match the directory name, | ||
// which means that this is only resolvable with an explicit | ||
// qualifier when used as an import path, but is allowed | ||
// on the cue command line because there's only one | ||
// package in the directory. | ||
package bar | ||
|
||
import "other.example/m" | ||
|
||
x: m.x | ||
-- foo/unnamed.cue -- | ||
import () |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
x: 1 | ||
|
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,5 @@ | ||
// Test data - not compiled. | ||
|
||
package main | ||
|
||
{} |
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,5 @@ | ||
// Test data - not compiled. | ||
|
||
package test_package | ||
|
||
{} |
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,2 @@ | ||
x: 1 | ||
|
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,7 @@ | ||
// The underscore package should be treated the same as an omitted package | ||
// clause. | ||
|
||
package _ | ||
|
||
x: 1 | ||
|
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,5 @@ | ||
// Test data - not compiled. | ||
|
||
package main | ||
|
||
{} |
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,5 @@ | ||
// Test data - not compiled. | ||
|
||
package main | ||
|
||
{} |
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,5 @@ | ||
// Test data - not compiled. | ||
|
||
package test_package | ||
|
||
{} |
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,2 @@ | ||
x: 1 | ||
|
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,7 @@ | ||
// The underscore package should be treated the same as an omitted package | ||
// clause. | ||
|
||
package _ | ||
|
||
x: 1 | ||
|
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,7 @@ | ||
// The underscore package should be treated the same as an omitted package | ||
// clause. | ||
|
||
package _ | ||
|
||
x: 1 | ||
|