Black Lives Matter. Support the Equal Justice Initiative.

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

Documentation: cmd/go/testdata/script

     1  [short] skip
     2  
     3  # Test file
     4  ! go test p1_test.go
     5  stderr 'Logf format %d'
     6  go test -vet=off
     7  stdout '^ok'
     8  
     9  # Non-test file
    10  ! go test p1.go
    11  stderr 'Printf format %d'
    12  go test -x -vet=shift p1.go
    13  stderr '[\\/]vet.*-shift'
    14  stdout '\[no test files\]'
    15  go test -vet=off p1.go
    16  ! stderr '[\\/]vet.*-shift'
    17  stdout '\[no test files\]'
    18  
    19  # Test issue #22890
    20  go test m/vetcycle
    21  stdout 'm/vetcycle.*\[no test files\]'
    22  
    23  # Test with ...
    24  ! go test ./vetfail/...
    25  stderr 'Printf format %d'
    26  stdout 'ok\s+m/vetfail/p2'
    27  
    28  # Check there's no diagnosis of a bad build constraint in vetxonly mode.
    29  # Use -a so that we need to recompute the vet-specific export data for
    30  # vetfail/p1.
    31  go test -a m/vetfail/p2
    32  ! stderr 'invalid.*constraint'
    33  
    34  -- go.mod --
    35  module m
    36  
    37  go 1.16
    38  -- p1_test.go --
    39  package p
    40  
    41  import "testing"
    42  
    43  func Test(t *testing.T) {
    44  	t.Logf("%d") // oops
    45  }
    46  -- p1.go --
    47  package p
    48  
    49  import "fmt"
    50  
    51  func F() {
    52  	fmt.Printf("%d") // oops
    53  }
    54  -- vetcycle/p.go --
    55  package p
    56  
    57  type (
    58  	_  interface{ m(B1) }
    59  	A1 interface{ a(D1) }
    60  	B1 interface{ A1 }
    61  	C1 interface {
    62  		B1 /* ERROR issue #18395 */
    63  	}
    64  	D1 interface{ C1 }
    65  )
    66  
    67  var _ A1 = C1 /* ERROR cannot use C1 */ (nil)
    68  -- vetfail/p1/p1.go --
    69  // +build !foo-bar
    70  
    71  package p1
    72  
    73  import "fmt"
    74  
    75  func F() {
    76  	fmt.Printf("%d", "hello") // causes vet error
    77  }
    78  -- vetfail/p2/p2.go --
    79  package p2
    80  
    81  import _ "m/vetfail/p1"
    82  
    83  func F() {
    84  }
    85  -- vetfail/p2/p2_test.go --
    86  package p2
    87  
    88  import "testing"
    89  
    90  func TestF(t *testing.T) {
    91  	F()
    92  }
    93  

View as plain text