github.com/gagliardetto/golang-go@v0.0.0-20201020153340-53909ea70814/cmd/go/testdata/script/mod_invalid_version.txt (about)

     1  [!net] skip
     2  [!exec:git] skip
     3  
     4  env GO111MODULE=on
     5  env GOPROXY=direct
     6  env GOSUMDB=off
     7  
     8  # Regression test for golang.org/issue/27173: if the user (or go.mod file)
     9  # requests a pseudo-version that does not match both the module path and commit
    10  # metadata, reject it with a helpful error message.
    11  #
    12  # TODO(bcmills): Replace the github.com/pierrec/lz4 examples with something
    13  # equivalent on vcs-test.golang.org.
    14  
    15  # An incomplete commit hash is not a valid semantic version,
    16  # but can appear in the main go.mod file anyway and should be resolved.
    17  cp go.mod.orig go.mod
    18  go mod edit -require golang.org/x/text@14c0d48ead0c
    19  cd outside
    20  ! go list -m golang.org/x/text
    21  stderr 'go: example.com@v0.0.0: parsing ../go.mod: '$WORK'/gopath/src/go.mod:5: require golang.org/x/text: version "14c0d48ead0c" invalid: must be of the form v1.2.3'
    22  cd ..
    23  go list -m golang.org/x/text
    24  stdout 'golang.org/x/text v0.1.1-0.20170915032832-14c0d48ead0c'
    25  grep 'golang.org/x/text v0.1.1-0.20170915032832-14c0d48ead0c' go.mod
    26  
    27  # A module path below the repo root that does not contain a go.mod file is invalid.
    28  cp go.mod.orig go.mod
    29  go mod edit -require golang.org/x/text/unicode@v0.0.0-20170915032832-14c0d48ead0c
    30  cd outside
    31  ! go list -m golang.org/x/text
    32  stderr 'go: example.com@v0.0.0 requires\n\tgolang.org/x/text/unicode@v0.0.0-20170915032832-14c0d48ead0c: invalid version: missing golang.org/x/text/unicode/go.mod at revision 14c0d48ead0c'
    33  cd ..
    34  ! go list -m golang.org/x/text
    35  stderr 'golang.org/x/text/unicode@v0.0.0-20170915032832-14c0d48ead0c: invalid version: missing golang.org/x/text/unicode/go.mod at revision 14c0d48ead0c'
    36  
    37  # However, arguments to 'go get' can name packages above the root.
    38  cp go.mod.orig go.mod
    39  go get -d golang.org/x/text/unicode@v0.0.0-20170915032832-14c0d48ead0c
    40  go list -m golang.org/x/text/...
    41  stdout 'golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c'
    42  ! stdout 'golang.org/x/text/unicode'
    43  
    44  # A major version that does not match the module path is invalid.
    45  cp go.mod.orig go.mod
    46  go mod edit -require golang.org/x/text@v2.1.1-0.20170915032832-14c0d48ead0c
    47  cd outside
    48  ! go list -m golang.org/x/text
    49  stderr 'go: example.com@v0.0.0: parsing ../go.mod: '$WORK'/gopath/src/go.mod:5: require golang.org/x/text: version "v2.1.1-0.20170915032832-14c0d48ead0c" invalid: should be v0 or v1, not v2'
    50  cd ..
    51  ! go list -m golang.org/x/text
    52  stderr $WORK'/gopath/src/go.mod:5: require golang.org/x/text: version "v2.1.1-0.20170915032832-14c0d48ead0c" invalid: should be v0 or v1, not v2'
    53  
    54  # A pseudo-version with fewer than 12 digits of SHA-1 prefix is invalid.
    55  cp go.mod.orig go.mod
    56  go mod edit -require golang.org/x/text@v0.1.1-0.20170915032832-14c0d48ead0
    57  cd outside
    58  ! go list -m golang.org/x/text
    59  stderr 'go: example.com@v0.0.0 requires\n\tgolang.org/x/text@v0.1.1-0.20170915032832-14c0d48ead0: invalid pseudo-version: revision is shorter than canonical \(14c0d48ead0c\)'
    60  cd ..
    61  ! go list -m golang.org/x/text
    62  stderr 'golang.org/x/text@v0.1.1-0.20170915032832-14c0d48ead0: invalid pseudo-version: revision is shorter than canonical \(14c0d48ead0c\)'
    63  
    64  # A pseudo-version with more than 12 digits of SHA-1 prefix is invalid.
    65  cp go.mod.orig go.mod
    66  go mod edit -require golang.org/x/text@v0.1.1-0.20170915032832-14c0d48ead0cd47e3104ada247d91be04afc7a5a
    67  cd outside
    68  ! go list -m golang.org/x/text
    69  stderr 'go: example.com@v0.0.0 requires\n\tgolang.org/x/text@v0.1.1-0.20170915032832-14c0d48ead0cd47e3104ada247d91be04afc7a5a: invalid pseudo-version: revision is longer than canonical \(14c0d48ead0c\)'
    70  cd ..
    71  ! go list -m golang.org/x/text
    72  stderr 'golang.org/x/text@v0.1.1-0.20170915032832-14c0d48ead0cd47e3104ada247d91be04afc7a5a: invalid pseudo-version: revision is longer than canonical \(14c0d48ead0c\)'
    73  
    74  # A pseudo-version that does not match the commit timestamp is invalid.
    75  cp go.mod.orig go.mod
    76  go mod edit -require golang.org/x/text@v0.1.1-0.20190915032832-14c0d48ead0c
    77  cd outside
    78  ! go list -m golang.org/x/text
    79  stderr 'go: example.com@v0.0.0 requires\n\tgolang.org/x/text@v0.1.1-0.20190915032832-14c0d48ead0c: invalid pseudo-version: does not match version-control timestamp \(2017-09-15T03:28:32Z\)'
    80  cd ..
    81  ! go list -m golang.org/x/text
    82  stderr 'golang.org/x/text@v0.1.1-0.20190915032832-14c0d48ead0c: invalid pseudo-version: does not match version-control timestamp \(2017-09-15T03:28:32Z\)'
    83  
    84  # A 'replace' directive in the main module can replace an invalid timestamp
    85  # with a valid one.
    86  go mod edit -replace golang.org/x/text@v0.1.1-0.20190915032832-14c0d48ead0c=golang.org/x/text@14c0d48ead0c
    87  cd outside
    88  ! go list -m golang.org/x/text
    89  stderr 'go: example.com@v0.0.0 requires\n\tgolang.org/x/text@v0.1.1-0.20190915032832-14c0d48ead0c: invalid pseudo-version: does not match version-control timestamp \(2017-09-15T03:28:32Z\)'
    90  cd ..
    91  go list -m golang.org/x/text
    92  stdout 'golang.org/x/text v0.1.1-0.20190915032832-14c0d48ead0c => golang.org/x/text v0.1.1-0.20170915032832-14c0d48ead0c'
    93  
    94  # A pseudo-version that is not derived from a tag is invalid.
    95  cp go.mod.orig go.mod
    96  go mod edit -require golang.org/x/text@v1.999.999-0.20170915032832-14c0d48ead0c
    97  cd outside
    98  ! go list -m golang.org/x/text
    99  stderr 'go: example.com@v0.0.0 requires\n\tgolang.org/x/text@v1.999.999-0.20170915032832-14c0d48ead0c: invalid pseudo-version: preceding tag \(v1.999.998\) not found'
   100  cd ..
   101  ! go list -m golang.org/x/text
   102  stderr 'golang.org/x/text@v1.999.999-0.20170915032832-14c0d48ead0c: invalid pseudo-version: preceding tag \(v1.999.998\) not found'
   103  
   104  # A v1.0.0- pseudo-version that is not derived from a tag is invalid:
   105  # v1.0.0- implies no tag, but the correct no-tag prefix for a module path
   106  # without a major-version suffix is v0.0.0-.
   107  cp go.mod.orig go.mod
   108  go mod edit -require golang.org/x/text@v1.0.0-20170915032832-14c0d48ead0c
   109  cd outside
   110  ! go list -m golang.org/x/text
   111  stderr 'go: example.com@v0.0.0 requires\n\tgolang.org/x/text@v1.0.0-20170915032832-14c0d48ead0c: invalid pseudo-version: major version without preceding tag must be v0, not v1'
   112  cd ..
   113  ! go list -m golang.org/x/text
   114  stderr 'golang.org/x/text@v1.0.0-20170915032832-14c0d48ead0c: invalid pseudo-version: major version without preceding tag must be v0, not v1'
   115  
   116  # A pseudo-version vX.Y.Z+1 cannot have Z+1 == 0, since that would
   117  # imply a base tag with a negative patch field.
   118  cp go.mod.orig go.mod
   119  go mod edit -require golang.org/x/text@v0.0.0-0.20170915032832-14c0d48ead0c
   120  cd outside
   121  ! go list -m golang.org/x/text
   122  stderr 'go: example.com@v0.0.0 requires\n\tgolang.org/x/text@v0.0.0-0.20170915032832-14c0d48ead0c: invalid pseudo-version: version before v0.0.0 would have negative patch number'
   123  cd ..
   124  ! go list -m golang.org/x/text
   125  stderr 'golang.org/x/text@v0.0.0-0.20170915032832-14c0d48ead0c: invalid pseudo-version: version before v0.0.0 would have negative patch number'
   126  
   127  # A 'replace' directive in the main module can replace an
   128  # invalid pseudo-version base with a valid one.
   129  go mod edit -replace golang.org/x/text@v0.0.0-0.20170915032832-14c0d48ead0c=golang.org/x/text@v0.0.0-20170915032832-14c0d48ead0c
   130  cd outside
   131  ! go list -m golang.org/x/text
   132  stderr 'go: example.com@v0.0.0 requires\n\tgolang.org/x/text@v0.0.0-0.20170915032832-14c0d48ead0c: invalid pseudo-version: version before v0.0.0 would have negative patch number'
   133  cd ..
   134  go list -m golang.org/x/text
   135  stdout 'golang.org/x/text v0.0.0-0.20170915032832-14c0d48ead0c => golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c'
   136  
   137  # A 'replace' directive can replace an invalid 'latest' version, and
   138  # should suppress errors for that version in 'go get -u'
   139  cp go.mod.orig go.mod
   140  go mod edit -require golang.org/x/text@v1.999999.0
   141  go mod edit -replace golang.org/x/text@v1.999999.0=golang.org/x/text@v0.0.0-20170915032832-14c0d48ead0c
   142  cd outside
   143  ! go get -d golang.org/x/text@upgrade
   144  stderr 'go: example.com@v0.0.0 requires\n\tgolang.org/x/text@v1.999999.0: reading golang.org/x/text/go.mod at revision v1.999999.0: unknown revision v1.999999.0'
   145  cd ..
   146  go get -d golang.org/x/text@upgrade
   147  go list -m golang.org/x/text
   148  stdout 'golang.org/x/text v1.999999.0 => golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c'
   149  
   150  # A pseudo-version derived from a non-ancestor tag is invalid.
   151  cp go.mod.orig go.mod
   152  go mod edit -require golang.org/x/text@v0.2.1-0.20170915032832-14c0d48ead0c
   153  cd outside
   154  ! go list -m golang.org/x/text
   155  stderr 'go: example.com@v0.0.0 requires\n\tgolang.org/x/text@v0.2.1-0.20170915032832-14c0d48ead0c: invalid pseudo-version: revision 14c0d48ead0c is not a descendent of preceding tag \(v0.2.0\)'
   156  cd ..
   157  ! go list -m golang.org/x/text
   158  stderr 'golang.org/x/text@v0.2.1-0.20170915032832-14c0d48ead0c: invalid pseudo-version: revision 14c0d48ead0c is not a descendent of preceding tag \(v0.2.0\)'
   159  
   160  # A pseudo-version derived from a canonical tag on the same revision is invalid.
   161  cp go.mod.orig go.mod
   162  go mod edit -require golang.org/x/text@v0.2.1-0.20171213102548-c4d099d611ac
   163  cd outside
   164  ! go list -m golang.org/x/text
   165  stderr 'go: example.com@v0.0.0 requires\n\tgolang.org/x/text@v0.2.1-0.20171213102548-c4d099d611ac: invalid pseudo-version: tag \(v0.2.0\) found on revision c4d099d611ac is already canonical, so should not be replaced with a pseudo-version derived from that tag'
   166  cd ..
   167  ! go list -m golang.org/x/text
   168  stderr 'golang.org/x/text@v0.2.1-0.20171213102548-c4d099d611ac: invalid pseudo-version: tag \(v0.2.0\) found on revision c4d099d611ac is already canonical, so should not be replaced with a pseudo-version derived from that tag'
   169  
   170  # A +incompatible suffix is not allowed on a version that is actually compatible.
   171  cp go.mod.orig go.mod
   172  go mod edit -require golang.org/x/text@v0.1.1-0.20170915032832-14c0d48ead0c+incompatible
   173  cd outside
   174  ! go list -m golang.org/x/text
   175  stderr 'go: example.com@v0.0.0 requires\n\tgolang.org/x/text@v0.1.1-0.20170915032832-14c0d48ead0c\+incompatible: invalid version: \+incompatible suffix not allowed: major version v0 is compatible'
   176  cd ..
   177  ! go list -m golang.org/x/text
   178  stderr 'golang.org/x/text@v0.1.1-0.20170915032832-14c0d48ead0c\+incompatible: invalid version: \+incompatible suffix not allowed: major version v0 is compatible'
   179  
   180  # The pseudo-version for a commit after a tag with a non-matching major version
   181  # should instead be based on the last matching tag.
   182  cp go.mod.orig go.mod
   183  go mod edit -require github.com/pierrec/lz4@473cd7ce01a1
   184  go list -m github.com/pierrec/lz4
   185  stdout 'github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1'
   186  cd outside
   187  go list -m github.com/pierrec/lz4
   188  stdout 'github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1'
   189  cd ..
   190  
   191  # A +incompatible pseudo-version for a module that has an explicit go.mod file is invalid.
   192  cp go.mod.orig go.mod
   193  go mod edit -require github.com/pierrec/lz4@v2.0.9-0.20190209155647-9a39efadad3d+incompatible
   194  cd outside
   195  ! go list -m github.com/pierrec/lz4
   196  stderr 'go: example.com@v0.0.0 requires\n\tgithub.com/pierrec/lz4@v2.0.9-0.20190209155647-9a39efadad3d\+incompatible: invalid version: \+incompatible suffix not allowed: module contains a go.mod file, so semantic import versioning is required'
   197  cd ..
   198  ! go list -m github.com/pierrec/lz4
   199  stderr 'github.com/pierrec/lz4@v2.0.9-0.20190209155647-9a39efadad3d\+incompatible: invalid version: \+incompatible suffix not allowed: module contains a go.mod file, so semantic import versioning is required'
   200  
   201  # A +incompatible pseudo-version is valid for a revision of the module
   202  # that lacks a go.mod file.
   203  cp go.mod.orig go.mod
   204  go mod edit -require github.com/pierrec/lz4@v2.0.4-0.20180826165652-dbe9298ce099+incompatible
   205  cd outside
   206  go list -m github.com/pierrec/lz4
   207  stdout 'github.com/pierrec/lz4 v2.0.4-0.20180826165652-dbe9298ce099\+incompatible'
   208  cd ..
   209  go list -m github.com/pierrec/lz4
   210  stdout 'github.com/pierrec/lz4 v2.0.4-0.20180826165652-dbe9298ce099\+incompatible'
   211  
   212  # 'go get' for a mismatched major version without a go.mod file should resolve
   213  # to the equivalent +incompatible version, not a pseudo-version with a different
   214  # major version.
   215  cp go.mod.orig go.mod
   216  go get -d github.com/pierrec/lz4@v2.0.5
   217  go list -m github.com/pierrec/lz4
   218  stdout 'github.com/pierrec/lz4 v2.0.5\+incompatible'
   219  
   220  # 'go get' for a mismatched major version with a go.mod file should error out,
   221  # not resolve to a pseudo-version with a different major version.
   222  cp go.mod.orig go.mod
   223  ! go get -d github.com/pierrec/lz4@v2.0.8
   224  stderr 'go get github.com/pierrec/lz4@v2.0.8: github.com/pierrec/lz4@v2.0.8: invalid version: module contains a go.mod file, so major version must be compatible: should be v0 or v1, not v2'
   225  
   226  # An invalid +incompatible suffix for a canonical version should error out,
   227  # not resolve to a pseudo-version.
   228  #
   229  # TODO(bcmills): The "outside" view for this failure mode is missing its import stack.
   230  # Figure out why and fix it.
   231  cp go.mod.orig go.mod
   232  go mod edit -require github.com/pierrec/lz4@v2.0.8+incompatible
   233  cd outside
   234  ! go list -m github.com/pierrec/lz4
   235  stderr 'github.com/pierrec/lz4@v2.0.8\+incompatible: invalid version: \+incompatible suffix not allowed: module contains a go.mod file, so semantic import versioning is required'
   236  cd ..
   237  ! go list -m github.com/pierrec/lz4
   238  stderr 'github.com/pierrec/lz4@v2.0.8\+incompatible: invalid version: \+incompatible suffix not allowed: module contains a go.mod file, so semantic import versioning is required'
   239  
   240  -- go.mod.orig --
   241  module example.com
   242  
   243  go 1.13
   244  -- outside/go.mod --
   245  module example.com/outside
   246  
   247  go 1.13
   248  
   249  require example.com v0.0.0
   250  replace example.com v0.0.0 => ./..