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

     1  # This test demonstrates go commands that combine the 'all' pattern
     2  # with packages outside of 'all'.
     3  
     4  # With -deps, 'all' should include test dependencies of packages in the main
     5  # module, but not should not include test dependencies of packages imported only
     6  # by other root patterns.
     7  
     8  env GOFLAGS=-mod=mod
     9  cp go.mod go.mod.orig
    10  
    11  go list -deps all x/otherroot
    12  
    13  stdout '^x/inall$'
    14  stdout '^x/inall/fromtest$'
    15  stdout '^x/inall/fromtestinall$'
    16  stdout '^x/otherroot$'
    17  stdout '^x/otherdep$'
    18  
    19  ! stdout '^x/fromotherroottest$'
    20  ! stdout '^y/fromotherdeptest$'
    21  
    22  cmp go.mod go.mod.orig
    23  
    24  # With -deps -test, test dependencies of other roots should be included,
    25  # but test dependencies of non-roots should not.
    26  
    27  go list -deps -test all x/otherroot
    28  stdout '^x/inall$'
    29  stdout '^x/inall/fromtest$'
    30  stdout '^x/inall/fromtestinall$'
    31  stdout '^x/otherroot$'
    32  stdout '^x/otherdep$'
    33  
    34  stdout '^x/fromotherroottest$'
    35  ! stdout '^y/fromotherdeptest$'
    36  
    37  cmp go.mod go.mod.orig
    38  
    39  -- m.go --
    40  package m
    41  
    42  import _ "x/inall"
    43  -- m_test.go --
    44  package m_test
    45  
    46  import _ "x/inall/fromtest"
    47  -- go.mod --
    48  module m
    49  
    50  go 1.15
    51  
    52  require x v0.1.0
    53  
    54  replace (
    55  	x v0.1.0 => ./x
    56  	y v0.1.0 => ./y
    57  )
    58  -- x/go.mod --
    59  module x
    60  
    61  go 1.15
    62  -- x/inall/inall.go --
    63  package inall
    64  -- x/inall/inall_test.go --
    65  package inall_test
    66  
    67  import _ "x/inall/fromtestinall"
    68  -- x/inall/fromtest/fromtest.go --
    69  package fromtest
    70  -- x/inall/fromtestinall/fromtestinall.go --
    71  package fromtestinall
    72  -- x/otherroot/otherroot.go --
    73  package otherroot
    74  
    75  import _ "x/otherdep"
    76  -- x/otherroot/otherroot_test.go --
    77  package otherroot_test
    78  
    79  import _ "x/fromotherroottest"
    80  -- x/fromotherroottest/fromotherroottest.go --
    81  package fromotherroottest
    82  -- x/otherdep/otherdep.go --
    83  package otherdep
    84  -- x/otherdep/otherdep_test.go --
    85  package otherdep_test
    86  
    87  import _ "y/fromotherdeptest"
    88  -- x/otherroot/testonly/testonly.go --
    89  package testonly
    90  -- y/go.mod --
    91  module y
    92  
    93  go 1.15
    94  -- y/fromotherdeptest/fromotherdeptest.go --
    95  // Package fromotherdeptest is a test dependency of x/otherdep that is
    96  // not declared in x/go.mod. If the loader resolves this package,
    97  // it will add this module to the main module's go.mod file,
    98  // and we can detect the mistake.
    99  package fromotherdeptest
   100  

View as plain text