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

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

View as plain text