this repo has no description
0
fork

Configure Feed

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

cue/load: report when "tool" pkg is used in non-tool file

Fixes #126

Change-Id: I35fa2d2ad69ab39e5f8c0769c0a96deabe1be466
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/3485
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>

+24
+3
cue/load/import.go
··· 376 376 if !isTest || fp.c.Tests { 377 377 fp.imported[path] = append(fp.imported[path], spec.Pos()) 378 378 } 379 + if !isTool && strings.HasPrefix(path, "tool/") { 380 + badFile(errors.Newf(spec.Pos(), "%s may only be imported in *_tool.cue files", quoted)) 381 + } 379 382 } 380 383 } 381 384 switch {
+12
cue/load/loader_test.go
··· 239 239 root: $CWD/testdata 240 240 dir: $CWD/testdata/toolonly 241 241 display:./toolonly`, 242 + }, { 243 + cfg: &Config{ 244 + Dir: testdataDir, 245 + }, 246 + args: args("./badtool"), 247 + want: ` 248 + err: "tool/cli" may only be imported in *_tool.cue files 249 + path: example.org/test/badtool:bad 250 + module: example.org/test 251 + root: $CWD/testdata 252 + dir: $CWD/testdata/badtool 253 + display:./badtool`, 242 254 }} 243 255 for i, tc := range testCases { 244 256 // if i != 5 {
+9
cue/load/testdata/badtool/bad.cue
··· 1 + package bad 2 + 3 + import "tool/cli" 4 + 5 + command foo task: { 6 + foo: cli.Print & { 7 + text: "foo" 8 + } 9 + }