Skip to content

Commit 801f976

Browse files
committed
cmd/cue: add a test case to reproduce #3644
Expand the existing non-local `cue get go` testscript so that we need to keep looking for CUE files even when we find a non-CUE file first. I introduced that bug recently, but unfortunately the test happened to sidestep the issue. Also rename externalmod.test/blah to externalmod.test/mixfiles to clarify that its purpose is to mix CUE and non-CUE files, and describe its purpose in its module.cue file. For #3644. Signed-off-by: Daniel Martí <[email protected]> Change-Id: I0c1bc012804e9d130d69f4256c028556b5e3726b Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1207329 Reviewed-by: Roger Peppe <[email protected]> Unity-Result: CUE porcuepine <[email protected]> TryBot-Result: CUEcueckoo <[email protected]> Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1207624 Reviewed-by: Paul Jolly <[email protected]>
1 parent a1fbeaa commit 801f976

File tree

4 files changed

+70
-35
lines changed

4 files changed

+70
-35
lines changed

cmd/cue/cmd/testdata/mod/externalmod.test_blah_v1.0.0.txtar

-18
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
-- .mod --
2+
module externalmod.test/mixfiles
3+
4+
-- .info --
5+
{"Version":"v1.0.0","Time":"2018-10-22T18:45:39Z"}
6+
7+
-- go.mod --
8+
// A module which mixes CUE, Go, and other files, to be tested with `cue get go`.
9+
10+
module externalmod.test/mixfiles
11+
12+
-- aa_first_noextension --
13+
Mix an uninteresting file at the beginning of the directory list
14+
to verify that we don't stop looking at the rest of the files.
15+
-- code_one.go --
16+
package mixfiles
17+
18+
// Some fruit
19+
const NameOne = "Orange"
20+
-- code_two.go --
21+
package mixfiles
22+
23+
const NameTwo = "Apple"
24+
-- config_one.cue --
25+
package mixfiles
26+
27+
Type: "Fruit"
28+
-- config_two.cue --
29+
package mixfiles
30+
31+
Type: string
32+
-- zz_last_noextension --

cmd/cue/cmd/testdata/script/get_go_non_local.txtar

+34-13
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,18 @@
44
# But this is going to change: "cue get go" will be renamed "cue import go".
55
# When that change happens, cue import go will assume that all
66
# required dependencies are present, and fail otherwise.
7-
go get externalmod.test/blah@v1.0.0
7+
go get externalmod.test/mixfiles@v1.0.0
88
go mod tidy
99

1010
# cue get go
11-
exec cue get go externalmod.test/blah
12-
cmp cue.mod/gen/externalmod.test/blah/blah_go_gen.cue cue.mod/gen/externalmod.test/blah/blah_go_gen.cue.golden
13-
cmp cue.mod/gen/externalmod.test/blah/blah_gen.cue cue.mod/gen/externalmod.test/blah/blah_gen.cue.golden
11+
exec cue get go externalmod.test/mixfiles
12+
cmp cue.mod/gen/externalmod.test/mixfiles/code_one_go_gen.cue cue.mod/gen/externalmod.test/mixfiles/code_one_go_gen.cue.golden
13+
cmp cue.mod/gen/externalmod.test/mixfiles/code_two_go_gen.cue cue.mod/gen/externalmod.test/mixfiles/code_two_go_gen.cue.golden
14+
# TODO(mvdan): fix https://cuelang.org/issue/3644
15+
! exists cue.mod/gen/externalmod.test/mixfiles/config_one_gen.cue
16+
! exists cue.mod/gen/externalmod.test/mixfiles/config_two_gen.cue
17+
# cmp cue.mod/gen/externalmod.test/mixfiles/config_one_gen.cue cue.mod/gen/externalmod.test/mixfiles/config_one_gen.cue.golden
18+
# cmp cue.mod/gen/externalmod.test/mixfiles/config_two_gen.cue cue.mod/gen/externalmod.test/mixfiles/config_two_gen.cue.golden
1419

1520
# Verify dependencies are as expected
1621
cmp go.mod go.mod.golden
@@ -40,28 +45,44 @@ module mod.test/local
4045

4146
go 1.14
4247

43-
require externalmod.test/blah v1.0.0
48+
require externalmod.test/mixfiles v1.0.0
4449
-- cuedeps.go --
4550
// +build cuedeps
4651

4752
package cuedeps
4853

4954
import (
50-
_ "externalmod.test/blah"
55+
_ "externalmod.test/mixfiles"
5156
)
52-
-- cue.mod/gen/externalmod.test/blah/blah_go_gen.cue.golden --
57+
-- cue.mod/gen/externalmod.test/mixfiles/code_one_go_gen.cue.golden --
5358
// Code generated by cue get go. DO NOT EDIT.
5459

55-
//cue:generate cue get go externalmod.test/blah
60+
//cue:generate cue get go externalmod.test/mixfiles
5661

57-
package blah
62+
package mixfiles
5863

59-
#Name: "Orange"
60-
-- cue.mod/gen/externalmod.test/blah/blah_gen.cue.golden --
64+
#NameOne: "Orange"
65+
-- cue.mod/gen/externalmod.test/mixfiles/code_two_go_gen.cue.golden --
6166
// Code generated by cue get go. DO NOT EDIT.
6267

63-
//cue:generate cue get go externalmod.test/blah
68+
//cue:generate cue get go externalmod.test/mixfiles
6469

65-
package blah
70+
package mixfiles
71+
72+
#NameTwo: "Apple"
73+
-- cue.mod/gen/externalmod.test/mixfiles/config_one_gen.cue.golden --
74+
// Code generated by cue get go. DO NOT EDIT.
75+
76+
//cue:generate cue get go externalmod.test/mixfiles
77+
78+
package mixfiles
6679

6780
Type: "Fruit"
81+
-- cue.mod/gen/externalmod.test/mixfiles/config_two_gen.cue.golden --
82+
// Code generated by cue get go. DO NOT EDIT.
83+
84+
//cue:generate cue get go externalmod.test/mixfiles
85+
86+
package mixfiles
87+
88+
Type: string

cmd/cue/cmd/testdata/script/goproxytest.txtar

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Basic test to ensure that the goproxytest instance used by various testscript
22
# tests works as expected.
33

4-
go get externalmod.test/blah
4+
go get externalmod.test/mixfiles
55
go mod tidy
66
cmp go.mod go.mod.golden
77

@@ -15,15 +15,15 @@ package main
1515
import (
1616
"fmt"
1717

18-
"externalmod.test/blah"
18+
"externalmod.test/mixfiles"
1919
)
2020

2121
func main() {
22-
fmt.Println(blah.Orange)
22+
fmt.Println(mixfiles.Orange)
2323
}
2424
-- go.mod.golden --
2525
module test
2626

2727
go 1.14
2828

29-
require externalmod.test/blah v1.0.0
29+
require externalmod.test/mixfiles v1.0.0

0 commit comments

Comments
 (0)