...

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

Documentation: cmd/go/testdata/script

     1# https://golang.org/issue/46141: 'go mod tidy' for a Go 1.17 module should by
     2# default preserve enough checksums for the module to be used by Go 1.16.
     3#
     4# We don't have a copy of Go 1.16 handy, but we can simulate it by editing the
     5# 'go' version in the go.mod file to 1.16, without actually updating the
     6# requirements to match.
     7
     8[short] skip
     9
    10env MODFMT='{{with .Module}}{{.Path}} {{.Version}}{{end}}'
    11
    12
    13# For this module, Go 1.17 produces an error for one module, and Go 1.16
    14# produces a different error for a different module.
    15
    16cp go.mod go.mod.orig
    17
    18! go mod tidy
    19
    20stderr '^go: example\.com/m imports\n\texample\.net/added: module example\.net/added@latest found \(v0\.3\.0, replaced by \./a1\), but does not contain package example\.net/added$'
    21
    22cmp go.mod go.mod.orig
    23
    24
    25# When we run 'go mod tidy -e', we should proceed past the first error and follow
    26# it with a second error describing the version discrepancy.
    27#
    28# We should not provide advice on how to push past the version discrepancy,
    29# because the '-e' flag should already do that, writing out an otherwise-tidied
    30# go.mod file.
    31
    32go mod tidy -e
    33
    34stderr '^go: example\.com/m imports\n\texample\.net/added: module example\.net/added@latest found \(v0\.3\.0, replaced by \./a1\), but does not contain package example\.net/added\ngo: example\.net/added failed to load from any module,\n\tbut go 1\.16 would load it from example\.net/added@v0\.2\.0$'
    35
    36! stderr '\n\tgo mod tidy'
    37
    38cmp go.mod go.mod.tidy
    39
    40
    41-- go.mod --
    42module example.com/m
    43
    44go 1.17
    45
    46replace (
    47	example.net/added v0.1.0 => ./a1
    48	example.net/added v0.2.0 => ./a2
    49	example.net/added v0.3.0 => ./a1
    50	example.net/lazy v0.1.0 => ./lazy
    51	example.net/pruned v0.1.0 => ./pruned
    52)
    53
    54require (
    55	example.net/added v0.1.0
    56	example.net/lazy v0.1.0
    57)
    58-- go.mod.tidy --
    59module example.com/m
    60
    61go 1.17
    62
    63replace (
    64	example.net/added v0.1.0 => ./a1
    65	example.net/added v0.2.0 => ./a2
    66	example.net/added v0.3.0 => ./a1
    67	example.net/lazy v0.1.0 => ./lazy
    68	example.net/pruned v0.1.0 => ./pruned
    69)
    70
    71require example.net/lazy v0.1.0
    72-- m.go --
    73package m
    74
    75import (
    76	_ "example.net/added"
    77	_ "example.net/lazy"
    78)
    79
    80-- a1/go.mod --
    81module example.net/added
    82
    83go 1.17
    84-- a2/go.mod --
    85module example.net/added
    86
    87go 1.17
    88-- a2/added.go --
    89package added
    90
    91-- lazy/go.mod --
    92module example.net/lazy
    93
    94go 1.17
    95
    96require example.net/pruned v0.1.0
    97-- lazy/lazy.go --
    98package lazy
    99
   100-- pruned/go.mod --
   101module example.net/pruned
   102
   103go 1.17
   104
   105require example.net/added v0.2.0

View as plain text