@@ -69,83 +69,6 @@ func (tg *testgoData) extract(file string) {
69
69
}
70
70
}
71
71
72
- func TestModGO111MODULE (t * testing.T ) {
73
- tg := testGoModules (t )
74
- defer tg .cleanup ()
75
-
76
- tg .tempFile ("gp/src/x/y/z/go.mod" , "module x/y/z" )
77
- tg .tempFile ("gp/src/x/y/z/w/w.txt" , "" )
78
- tg .tempFile ("gp/foo/go.mod" , "module example.com/mod" )
79
- tg .tempFile ("gp/foo/bar/baz/quux.txt" , "" )
80
- tg .tempFile ("gp/bar/x.txt" , "" )
81
- tg .setenv ("GOPATH" , tg .path ("gp" ))
82
-
83
- // In GOPATH/src with go.mod.
84
- tg .cd (tg .path ("gp/src/x/y/z" ))
85
- tg .setenv ("GO111MODULE" , "auto" )
86
- tg .run ("env" , "GOMOD" )
87
- tg .grepStdoutNot (`go.mod` , "expected module mode disabled" )
88
-
89
- tg .cd (tg .path ("gp/src/x/y/z/w" ))
90
- tg .run ("env" , "GOMOD" )
91
- tg .grepStdoutNot (`go.mod` , "expected module mode disabled" )
92
-
93
- tg .setenv ("GO111MODULE" , "off" )
94
- tg .run ("env" , "GOMOD" )
95
- tg .grepStdoutNot (`go.mod` , "expected module mode disabled" )
96
-
97
- tg .setenv ("GO111MODULE" , "on" )
98
- tg .run ("env" , "GOMOD" )
99
- tg .grepStdout (`.*z[/\\]go.mod$` , "expected module mode enabled" )
100
-
101
- // In GOPATH/src without go.mod.
102
- tg .cd (tg .path ("gp/src/x/y" ))
103
- tg .setenv ("GO111MODULE" , "auto" )
104
- tg .run ("env" , "GOMOD" )
105
- tg .grepStdoutNot (`go.mod` , "expected module mode disabled" )
106
-
107
- tg .setenv ("GO111MODULE" , "off" )
108
- tg .run ("env" , "GOMOD" )
109
- tg .grepStdoutNot (`go.mod` , "expected module mode disabled" )
110
-
111
- tg .setenv ("GO111MODULE" , "on" )
112
- tg .runFail ("env" , "GOMOD" )
113
- tg .grepStderr (`cannot find main module root` , "expected module mode failure" )
114
-
115
- // Outside GOPATH/src with go.mod.
116
- tg .cd (tg .path ("gp/foo" ))
117
- tg .setenv ("GO111MODULE" , "auto" )
118
- tg .run ("env" , "GOMOD" )
119
- tg .grepStdout (`.*foo[/\\]go.mod$` , "expected module mode enabled" )
120
-
121
- tg .cd (tg .path ("gp/foo/bar/baz" ))
122
- tg .run ("env" , "GOMOD" )
123
- tg .grepStdout (`.*foo[/\\]go.mod$` , "expected module mode enabled" )
124
-
125
- tg .setenv ("GO111MODULE" , "off" )
126
- tg .run ("env" , "GOMOD" )
127
- tg .grepStdoutNot (`go.mod` , "expected module mode disabled" )
128
- }
129
-
130
- func TestModVersionsInGOPATHMode (t * testing.T ) {
131
- tg := testgo (t )
132
- tg .setenv ("GO111MODULE" , "off" ) // GOPATH mode
133
- defer tg .cleanup ()
134
- tg .makeTempdir ()
135
-
136
- tg .runFail ("get" , "rsc.io/quote@v1.5.1" )
137
- tg .grepStderr (`go: cannot use path@version syntax in GOPATH mode` , "expected path@version error" )
138
-
139
- tg .runFail ("build" , "rsc.io/quote@v1.5.1" )
140
- tg .grepStderr (`can't load package:.* cannot use path@version syntax in GOPATH mode` , "expected path@version error" )
141
-
142
- tg .setenv ("GO111MODULE" , "on" ) // GOPATH mode
143
- tg .tempFile ("x/go.mod" , "module x" )
144
- tg .cd (tg .path ("x" ))
145
- tg .runFail ("build" , "rsc.io/quote@v1.5.1" )
146
- tg .grepStderr (`can't load package:.* can only use path@version syntax with 'go get'` , "expected path@version error" )
147
- }
148
-
149
72
func TestModFindModuleRoot (t * testing.T ) {
150
73
tg := testGoModules (t )
151
74
defer tg .cleanup ()
@@ -328,16 +251,6 @@ func TestModFindModulePath(t *testing.T) {
328
251
// }
329
252
}
330
253
331
- func TestModImportModFails (t * testing.T ) {
332
- tg := testGoModules (t )
333
- defer tg .cleanup ()
334
-
335
- tg .setenv ("GO111MODULE" , "off" )
336
- tg .tempFile ("gopath/src/mod/foo/foo.go" , "package foo" )
337
- tg .runFail ("list" , "mod/foo" )
338
- tg .grepStderr (`disallowed import path` , "expected disallowed because of module cache" )
339
- }
340
-
341
254
func TestModEdit (t * testing.T ) {
342
255
// Test that local replacements work
343
256
// and that they can use a dummy name
@@ -502,91 +415,6 @@ require x.3 v1.99.0
502
415
` )
503
416
}
504
417
505
- func TestModLocalModule (t * testing.T ) {
506
- // Test that local replacements work
507
- // and that they can use a dummy name
508
- // that isn't resolvable and need not even
509
- // include a dot. See golang.org/issue/24100.
510
- tg := testGoModules (t )
511
- defer tg .cleanup ()
512
-
513
- tg .must (os .MkdirAll (tg .path ("x/y" ), 0777 ))
514
- tg .must (os .MkdirAll (tg .path ("x/z" ), 0777 ))
515
- tg .must (ioutil .WriteFile (tg .path ("x/y/go.mod" ), []byte (`
516
- module x/y
517
- require zz v1.0.0
518
- replace zz v1.0.0 => ../z
519
- ` ), 0666 ))
520
- tg .must (ioutil .WriteFile (tg .path ("x/y/y.go" ), []byte (`package y; import _ "zz"` ), 0666 ))
521
- tg .must (ioutil .WriteFile (tg .path ("x/z/go.mod" ), []byte (`
522
- module x/z
523
- ` ), 0666 ))
524
- tg .must (ioutil .WriteFile (tg .path ("x/z/z.go" ), []byte (`package z` ), 0666 ))
525
- tg .cd (tg .path ("x/y" ))
526
- tg .run ("build" )
527
- }
528
-
529
- func TestModTags (t * testing.T ) {
530
- // Test that build tags are used. See golang.org/issue/24053.
531
- tg := testGoModules (t )
532
- defer tg .cleanup ()
533
-
534
- tg .must (os .MkdirAll (tg .path ("x" ), 0777 ))
535
- tg .must (ioutil .WriteFile (tg .path ("x/go.mod" ), []byte (`
536
- module x
537
- ` ), 0666 ))
538
- tg .must (ioutil .WriteFile (tg .path ("x/x.go" ), []byte (`// +build tag1
539
-
540
- package y
541
- ` ), 0666 ))
542
- tg .must (ioutil .WriteFile (tg .path ("x/y.go" ), []byte (`// +build tag2
543
-
544
- package y
545
- ` ), 0666 ))
546
- tg .cd (tg .path ("x" ))
547
-
548
- tg .runFail ("list" , "-f={{.GoFiles}}" )
549
- tg .grepStderr ("build constraints exclude all Go files" , "no Go source files without tags" )
550
-
551
- tg .run ("list" , "-f={{.GoFiles}}" , "-tags=tag1" )
552
- tg .grepStdout (`\[x.go\]` , "Go source files for tag1" )
553
-
554
- tg .run ("list" , "-f={{.GoFiles}}" , "-tags" , "tag2" )
555
- tg .grepStdout (`\[y.go\]` , "Go source files for tag2" )
556
-
557
- tg .run ("list" , "-f={{.GoFiles}}" , "-tags" , "tag1 tag2" )
558
- tg .grepStdout (`\[x.go y.go\]` , "Go source files for tag1 and tag2" )
559
- }
560
-
561
- func TestModFSPatterns (t * testing.T ) {
562
- tg := testGoModules (t )
563
- defer tg .cleanup ()
564
-
565
- tg .must (os .MkdirAll (tg .path ("x/vendor/v" ), 0777 ))
566
- tg .must (os .MkdirAll (tg .path ("x/y/z/w" ), 0777 ))
567
- tg .must (ioutil .WriteFile (tg .path ("x/go.mod" ), []byte (`
568
- module m
569
- ` ), 0666 ))
570
-
571
- tg .must (ioutil .WriteFile (tg .path ("x/x.go" ), []byte (`package x` ), 0666 ))
572
- tg .must (ioutil .WriteFile (tg .path ("x/vendor/v/v.go" ), []byte (`package v; import "golang.org/x/crypto"` ), 0666 ))
573
- tg .must (ioutil .WriteFile (tg .path ("x/vendor/v.go" ), []byte (`package main` ), 0666 ))
574
- tg .must (ioutil .WriteFile (tg .path ("x/y/y.go" ), []byte (`package y` ), 0666 ))
575
- tg .must (ioutil .WriteFile (tg .path ("x/y/z/go.mod" ), []byte (`syntax error` ), 0666 ))
576
- tg .must (ioutil .WriteFile (tg .path ("x/y/z/z.go" ), []byte (`package z` ), 0666 ))
577
- tg .must (ioutil .WriteFile (tg .path ("x/y/z/w/w.go" ), []byte (`package w` ), 0666 ))
578
-
579
- tg .cd (tg .path ("x" ))
580
- for _ , pattern := range []string {"all" , "m/..." , "./..." } {
581
- tg .run ("list" , pattern )
582
- tg .grepStdout (`^m$` , "expected m" )
583
- tg .grepStdout (`^m/vendor$` , "must see package named vendor" )
584
- tg .grepStdoutNot (`vendor/` , "must not see vendored packages" )
585
- tg .grepStdout (`^m/y$` , "expected m/y" )
586
- tg .grepStdoutNot (`^m/y/z` , "should ignore submodule m/y/z..." )
587
- }
588
- }
589
-
590
418
func TestModGetVersions (t * testing.T ) {
591
419
tg := testGoModules (t )
592
420
defer tg .cleanup ()
0 commit comments