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

     1  # Regression test for https://golang.org/issue/46659.
     2  #
     3  # If a 'replace' directive specifies an older-than-selected version of a module,
     4  # 'go mod tidy' shouldn't try to add that version to the build list to resolve a
     5  # missing package: it won't be selected, and would cause the module loader to
     6  # loop indefinitely trying to resolve the package.
     7  
     8  cp go.mod go.mod.orig
     9  
    10  ! go mod tidy
    11  ! stderr panic
    12  stderr '^golang\.org/issue46659 imports\n\texample\.com/missingpkg/deprecated: package example\.com/missingpkg/deprecated provided by example\.com/missingpkg at latest version v1\.0\.0 but not at required version v1\.0\.1-beta$'
    13  
    14  go mod tidy -e
    15  
    16  cmp go.mod go.mod.orig
    17  
    18  -- go.mod --
    19  module golang.org/issue46659
    20  
    21  go 1.17
    22  
    23  replace example.com/missingpkg v1.0.1-alpha => example.com/missingpkg v1.0.0
    24  
    25  require example.com/usemissingpre v1.0.0
    26  
    27  require example.com/missingpkg v1.0.1-beta // indirect
    28  -- m.go --
    29  package m
    30  
    31  import (
    32  	_ "example.com/missingpkg/deprecated"
    33  	_ "example.com/usemissingpre"
    34  )
    35  

View as plain text