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

     1  env OLD=$PWD
     2  
     3  # basic -C functionality
     4  cd $GOROOT/src/math
     5  go list -C ../strings
     6  stdout strings
     7  ! go list -C ../nonexist
     8  stderr 'chdir.*nonexist'
     9  
    10  # check for -C in subcommands with custom flag parsing
    11  # cmd/go/chdir_test.go handles the normal ones more directly.
    12  
    13  # go doc
    14  go doc -C ../strings HasPrefix
    15  
    16  # go env
    17  go env -C $OLD/custom GOMOD
    18  stdout 'custom[\\/]go.mod'
    19  ! go env -C ../nonexist
    20  stderr '^go: chdir ../nonexist: '
    21  
    22  # go test
    23  go test -C ../strings -n
    24  stderr 'strings\.test'
    25  
    26  # go vet
    27  go vet -C ../strings -n
    28  stderr strings_test
    29  
    30  # -C must be first on command line (as of Go 1.21)
    31  ! go test -n -C ../strings
    32  stderr '^invalid value "../strings" for flag -C: -C flag must be first flag on command line$'
    33  
    34  -- custom/go.mod --
    35  module m
    36  

View as plain text