...

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

Documentation: cmd/go/testdata/script

     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
     8env GOFLAGS=-mod=mod
     9cp go.mod go.mod.orig
    10
    11go list -deps all x/otherroot
    12
    13stdout '^x/inall$'
    14stdout '^x/inall/fromtest$'
    15stdout '^x/inall/fromtestinall$'
    16stdout '^x/otherroot$'
    17stdout '^x/otherdep$'
    18
    19! stdout '^x/fromotherroottest$'
    20! stdout '^y/fromotherdeptest$'
    21
    22cmp 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
    27go list -deps -test all x/otherroot
    28stdout '^x/inall$'
    29stdout '^x/inall/fromtest$'
    30stdout '^x/inall/fromtestinall$'
    31stdout '^x/otherroot$'
    32stdout '^x/otherdep$'
    33
    34stdout '^x/fromotherroottest$'
    35! stdout '^y/fromotherdeptest$'
    36
    37cmp go.mod go.mod.orig
    38
    39-- m.go --
    40package m
    41
    42import _ "x/inall"
    43-- m_test.go --
    44package m_test
    45
    46import _ "x/inall/fromtest"
    47-- go.mod --
    48module m
    49
    50go 1.15
    51
    52require x v0.1.0
    53
    54replace (
    55	x v0.1.0 => ./x
    56	y v0.1.0 => ./y
    57)
    58-- x/go.mod --
    59module x
    60
    61go 1.15
    62-- x/inall/inall.go --
    63package inall
    64-- x/inall/inall_test.go --
    65package inall_test
    66
    67import _ "x/inall/fromtestinall"
    68-- x/inall/fromtest/fromtest.go --
    69package fromtest
    70-- x/inall/fromtestinall/fromtestinall.go --
    71package fromtestinall
    72-- x/otherroot/otherroot.go --
    73package otherroot
    74
    75import _ "x/otherdep"
    76-- x/otherroot/otherroot_test.go --
    77package otherroot_test
    78
    79import _ "x/fromotherroottest"
    80-- x/fromotherroottest/fromotherroottest.go --
    81package fromotherroottest
    82-- x/otherdep/otherdep.go --
    83package otherdep
    84-- x/otherdep/otherdep_test.go --
    85package otherdep_test
    86
    87import _ "y/fromotherdeptest"
    88-- x/otherroot/testonly/testonly.go --
    89package testonly
    90-- y/go.mod --
    91module y
    92
    93go 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.
    99package fromotherdeptest

View as plain text