...

Text file src/cmd/go/testdata/script/mod_get_workspace_incomplete.txt

Documentation: cmd/go/testdata/script

     1# Enter the first set of test cases. In this test case, package
     2# example.com/m has an import of example.com/n, which is also
     3# in the workspace, but is not required by example.com/m, and does not exist
     4# upstream. It also has an import of rsc.io/quote, which
     5# is also not required by example.com/m but does exist upstream. get should resolve
     6# rsc.io/quote and not try to resolve example.com/n.
     7cd m
     8cp go.mod go.mod.orig
     9
    10# Test go get with an incomplete module using a local query.
    11cp go.mod.orig go.mod
    12go get
    13cmp go.mod go.mod.want
    14cmp go.sum go.sum.want
    15
    16# Test go get with an incomplete module using a wildcard query.
    17cp go.mod.orig go.mod
    18rm go.sum
    19go get ./...
    20cmp go.mod go.mod.want
    21cmp go.sum go.sum.want
    22
    23# Test go get with an incomplete module using a "work" query.
    24cp go.mod.orig go.mod
    25rm go.sum
    26go get work
    27cmp go.mod go.mod.want
    28cmp go.sum go.sum.want
    29
    30# Test go get with an incomplete module using a path query that can be resolved.
    31cp go.mod.orig go.mod
    32rm go.sum
    33go get rsc.io/quote
    34cmp go.mod go.mod.want.path_query # query wasn't resolved through import, so don't know if it's direct
    35cmp go.sum go.sum.want
    36
    37# Test go get with a path query that is to a workspace module but that can't be resolved.
    38# Normally, when we encounter an unresolved import of a workspace module, it's
    39# ignored, but a path query of the module was asked for explicitly and isn't ignored.
    40cp go.mod.orig go.mod
    41rm go.sum
    42! go get example.com/n
    43# The following error is returned because module example.com does exist in the proxy we use
    44# to run these tests, and because its is a prefix of example.com/n, it is a candidate to
    45# satisfy the import.
    46stderr 'module example.com@upgrade found \(v1\.0\.0\), but does not contain package example.com/n'
    47
    48# Test go get with an incomplete module using an "all" query.
    49cp go.mod.orig go.mod
    50rm go.sum
    51go get all
    52cmp go.mod go.mod.want.all # all loads a different graph so the requirements get bumped up
    53cmp go.sum go.sum.want.all
    54
    55# Test go get with an incomplete module using a tool query
    56# The hastool directory has its own go.work file than includes example.com/n and hastool.
    57cd ../hastool
    58go get tool
    59cmp go.mod go.mod.want
    60
    61# Test that missing imports from loading the workspace are reported.
    62# In this example, there is a workspace with the
    63# example.com/missingworkspaceimport and example.com/withmissing modules.
    64# missingworkspaceimport imports withmissing, and withmissing in turn
    65# imports rsc.io/quote, but doesn't have a requirement on it.
    66# The get operation won't resolve rsc.io/quote because it doesn't
    67# appear in the missingworkspaceimport's module graph, and the
    68# workspace will fail to load in checkPackageProblems because of the missing import.
    69cd ../missingworkspaceimport
    70! go get ./...
    71stderr 'cannot find module providing package rsc.io/quote'
    72
    73# Test that missing imports are not reported if they're not in the package
    74# graph. This test case is the same as the above except that there's no
    75# import from the missingworkspaceimport package to the one that
    76# imports the unresolved rsc.io/quote dependency. The example.com/missingworkspaceimport
    77# package imports example.com/withmissing/other so it still depends on the example.com/missing
    78# module, but not on the withmissing package itself. The example.com/withmissing
    79# module still has an import on the rsc.io/quote package, but the package
    80# with the import doesn't appear in the loaded package graph.
    81cd ../missingworkspaceimport_disconnected
    82go get ./...
    83
    84# Test that deprecations are reported using the workspace.
    85# First, the control case: without the workspace, the deprecated module
    86# is an indirect dependency of example.com/withdeprecation/indirect,
    87# so we shouldn't get a deprecation warning.
    88cd ../withdeprecation/indirect
    89cp go.mod go.mod.orig
    90env GOWORK=off
    91go get ./...
    92! stderr 'is deprecated'
    93cmp go.mod go.mod.want
    94# Now, in the workspace, we should get a deprecation warning, because
    95# the deprecated module is a direct dependency of example.com/withdeprecation/direct, which
    96# is a workspace module.
    97cp go.mod.orig go.mod
    98env GOWORK=
    99go get ./...
   100stderr 'go: module example.com/deprecated/b is deprecated: in example.com/deprecated/b@v1.9.0'
   101cmp go.mod go.mod.want
   102
   103# Test that retractions are reported using the workspace.
   104# First, the control case. Even though a workspace module depends on
   105# a retracted version, because we didn't ask for it on the command line,
   106# we didn't resolve that retracted module to satisfy an import,
   107# or need it to build a requested package, we don't produce the warning.
   108cd ../../withretraction/doesnotrequireretracted
   109cp go.mod go.mod.orig
   110go get rsc.io/quote
   111! stderr 'retracted'
   112# If we do request a non-retracted version of the module but the workspace
   113# is off, we also won't see the retraction warning because the retracted
   114# module isn't selected in the graph.
   115cp go.mod.orig go.mod
   116env GOWORK=off
   117go get example.com/retract@v1.0.0-good
   118! stderr 'retracted'
   119# Now, with the workspace on, because example.com/retract@v1.0.0-unused
   120# is a higher version, it will be selected and the retraction will
   121# be reported.
   122cp go.mod.orig go.mod
   123env GOWORK=
   124go get example.com/retract@v1.0.0-good
   125stderr 'retracted'
   126# Finally, with the workspace on, if the other workspace depends on
   127# example.com/retract@v1.0.0-bad rather than 'v1.0.0-unused', because
   128# 'v1.0.0-bad' is considered a lower version than 'v1.0.0-good', 'v1.0.0-good'
   129# will be selected and the deprecation will not be reported.
   130cp go.mod.orig go.mod
   131cd ../requiresretracted
   132go get example.com/retract@v1.0.0-bad # set the verison to 'v1.0.0-bad'
   133stderr 'retracted'
   134cd ../doesnotrequireretracted
   135go get example.com/retract@v1.0.0-good
   136! stderr 'retracted'
   137
   138-- go.work --
   139go 1.25
   140
   141use (
   142	m
   143	n
   144)
   145-- q/go.mod --
   146module example.com/q
   147
   148go 1.25
   149-- q/q.go --
   150package q
   151
   152import "rsc.io/quote"
   153
   154func Q() {
   155	quote.Hello()
   156}
   157-- m/go.mod --
   158module example.com/m
   159
   160go 1.25
   161-- m/go.mod.want --
   162module example.com/m
   163
   164go 1.25
   165
   166require rsc.io/quote v1.5.2
   167
   168require (
   169	golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c // indirect
   170	rsc.io/sampler v1.3.0 // indirect
   171)
   172-- m/go.mod.want.path_query --
   173module example.com/m
   174
   175go 1.25
   176
   177require (
   178	golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c // indirect
   179	rsc.io/quote v1.5.2 // indirect
   180	rsc.io/sampler v1.3.0 // indirect
   181)
   182-- m/go.sum.want --
   183golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c h1:pvCbr/wm8HzDD3fVywevekufpn6tCGPY3spdHeZJEsw=
   184golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
   185rsc.io/quote v1.5.2 h1:3fEykkD9k7lYzXqCYrwGAf7iNhbk4yCjHmKBN9td4L0=
   186rsc.io/quote v1.5.2/go.mod h1:LzX7hefJvL54yjefDEDHNONDjII0t9xZLPXsUe+TKr0=
   187rsc.io/sampler v1.3.0 h1:HLGR/BgEtI3r0uymSP/nl2uPLsUnNJX8toRyhfpBTII=
   188rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
   189-- m/go.mod.want.all --
   190module example.com/m
   191
   192go 1.25
   193
   194require rsc.io/quote v1.5.2
   195
   196require (
   197	golang.org/x/text v0.3.0 // indirect
   198	rsc.io/sampler v1.99.99 // indirect
   199)
   200-- m/go.sum.want.all --
   201golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
   202golang.org/x/text v0.3.0 h1:ivTorhoiROmZ1mcs15mO2czVF0uy0tnezXpBVNzgrmA=
   203golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
   204rsc.io/quote v1.5.2 h1:3fEykkD9k7lYzXqCYrwGAf7iNhbk4yCjHmKBN9td4L0=
   205rsc.io/quote v1.5.2/go.mod h1:LzX7hefJvL54yjefDEDHNONDjII0t9xZLPXsUe+TKr0=
   206rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
   207rsc.io/sampler v1.99.99 h1:iMG9lbEG/8MdeR4lgL+Q8IcwbLNw7ijW7fTiK8Miqts=
   208rsc.io/sampler v1.99.99/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
   209-- m/m.go --
   210package m
   211
   212import (
   213	"example.com/n"
   214	"rsc.io/quote"
   215)
   216
   217func M() {
   218	n.Hello()
   219	quote.Hello()
   220}
   221-- n/go.mod --
   222module example.com/n
   223
   224go 1.25
   225-- n/n.go --
   226package n
   227
   228func Hello() {
   229}
   230-- hastool/go.work --
   231go 1.25
   232
   233use (
   234	.
   235	../n
   236)
   237-- hastool/go.mod --
   238module example.com/hastool
   239
   240go 1.25
   241
   242tool rsc.io/fortune
   243-- hastool/go.mod.want --
   244module example.com/hastool
   245
   246go 1.25
   247
   248tool rsc.io/fortune
   249
   250require (
   251	golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c // indirect
   252	rsc.io/fortune v1.0.0 // indirect
   253	rsc.io/quote v1.5.2 // indirect
   254	rsc.io/sampler v1.3.0 // indirect
   255)
   256-- hastool/p.go --
   257package hastool
   258
   259import "example.com/n"
   260
   261func T() {
   262	n.Hello()
   263}
   264-- missingworkspaceimport/go.work --
   265go 1.25
   266
   267use (
   268	.
   269	withmissing
   270)
   271-- missingworkspaceimport/go.mod --
   272module example.com/missingworkspaceimport
   273
   274go 1.25
   275-- missingworkspaceimport/m.go --
   276package m
   277
   278import _ "example.com/withmissing"
   279-- missingworkspaceimport/withmissing/go.mod --
   280module example.com/withmissing
   281
   282go 1.25
   283-- missingworkspaceimport/withmissing/w.go --
   284package w
   285
   286import _ "rsc.io/quote"
   287-- missingworkspaceimport_disconnected/go.work --
   288go 1.25
   289
   290use (
   291	.
   292	withmissing
   293)
   294-- missingworkspaceimport_disconnected/go.mod --
   295module example.com/missingworkspaceimport
   296
   297go 1.25
   298-- missingworkspaceimport_disconnected/m.go --
   299package m
   300
   301import _ "example.com/withmissing/other"
   302-- missingworkspaceimport_disconnected/withmissing/go.mod --
   303module example.com/withmissing
   304
   305go 1.25
   306-- missingworkspaceimport_disconnected/withmissing/w.go --
   307package w
   308
   309import _ "rsc.io/quote"
   310-- missingworkspaceimport_disconnected/withmissing/other/other.go --
   311package other
   312-- withdeprecation/go.work --
   313go 1.25
   314
   315use (
   316	indirect
   317	direct
   318)
   319
   320replace example.com/requiresdeprecatednotworkspace => ./requiresdeprecatednotworkspace
   321-- withdeprecation/indirect/go.mod --
   322module example.com/withdeprecation/indirect
   323
   324go 1.25
   325
   326replace example.com/requiresdeprecatednotworkspace => ../requiresdeprecatednotworkspace
   327-- withdeprecation/indirect/go.mod.want --
   328module example.com/withdeprecation/indirect
   329
   330go 1.25
   331
   332replace example.com/requiresdeprecatednotworkspace => ../requiresdeprecatednotworkspace
   333
   334require example.com/requiresdeprecatednotworkspace v0.0.0-00010101000000-000000000000
   335
   336require example.com/deprecated/b v1.9.0 // indirect
   337-- withdeprecation/indirect/go.mod.want.direct --
   338module example.com/withdeprecation/indirect
   339
   340go 1.25
   341
   342replace example.com/requiresdeprecatednotworkspace => ../requiresdeprecatednotworkspace
   343
   344require example.com/requiresdeprecatednotworkspace v0.0.0-00010101000000-000000000000
   345
   346require example.com/deprecated/b v1.9.0
   347-- withdeprecation/indirect/a.go --
   348package indirect
   349
   350import "example.com/requiresdeprecatednotworkspace"
   351-- withdeprecation/direct/go.mod --
   352module example.com/withdeprecation/direct
   353
   354go 1.25
   355
   356require "example.com/deprecated/b" v1.9.0
   357-- withdeprecation/direct/import.go --
   358package direct
   359
   360import "example.com/deprecated/b"
   361-- withdeprecation/requiresdeprecatednotworkspace/go.mod --
   362module example.com/requiresdeprecatednotworkspace
   363
   364go 1.25
   365-- withdeprecation/requiresdeprecatednotworkspace/a.go --
   366package a
   367
   368import "example.com/deprecated/b"
   369-- withretraction/go.work --
   370go 1.25
   371
   372use (
   373	doesnotrequireretracted
   374	requiresretracted
   375)
   376-- withretraction/doesnotrequireretracted/go.mod --
   377module example.com/withretraction/doesnotrequireretracted
   378
   379go 1.25
   380-- withretraction/requiresretracted/go.mod --
   381module example.com/withretraction/requiresretracted
   382
   383go 1.25
   384
   385require example.com/retract v1.0.0-unused

View as plain text