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

     1  [short] skip
     2  
     3  # Test that a loading error in a test file is reported as a "setup failed" error
     4  # and doesn't prevent running other tests.
     5  ! go test -o=$devnull ./t1/p ./t
     6  stderr '# m/t1/p\n.*package x is not in std'
     7  stdout 'FAIL	m/t1/p \[setup failed\]'
     8  stdout 'ok  	m/t'
     9  
    10  # Test a loading error in a test package, but not in the test file
    11  ! go test -o=$devnull ./t2/p ./t
    12  stderr '# m/t2/p\n.*package x is not in std'
    13  stdout 'FAIL	m/t2/p \[setup failed\]'
    14  stdout 'ok  	m/t'
    15  
    16  # Test a loading error in a package imported by a test file
    17  ! go test -o=$devnull ./t3/p ./t
    18  stderr '# m/t3/p\n.*package x is not in std'
    19  stdout 'FAIL	m/t3/p \[setup failed\]'
    20  stdout 'ok  	m/t'
    21  
    22  # Test a loading error in a package imported by a test package
    23  ! go test -o=$devnull ./t4/p ./t
    24  stderr '# m/t4/p\n.*package x is not in std'
    25  stdout 'FAIL	m/t4/p \[setup failed\]'
    26  stdout 'ok  	m/t'
    27  
    28  # Test that two loading errors are both reported.
    29  ! go test -o=$devnull ./t1/p ./t2/p ./t
    30  stderr '# m/t1/p\n.*package x is not in std'
    31  stdout 'FAIL	m/t1/p \[setup failed\]'
    32  stderr '# m/t2/p\n.*package x is not in std'
    33  stdout 'FAIL	m/t2/p \[setup failed\]'
    34  stdout 'ok  	m/t'
    35  
    36  # Finally, this one is a build error, but produced by cmd/go directly
    37  ! go test -o=$devnull . ./t
    38  stderr '^\.: no Go files in '$PWD'$'
    39  stdout 'FAIL	. \[build failed\]'
    40  stdout 'ok  	m/t'
    41  
    42  -- go.mod --
    43  module m
    44  go 1.21
    45  -- t/t_test.go --
    46  package t
    47  
    48  import "testing"
    49  
    50  func TestGood(t *testing.T) {}
    51  -- t1/p/p_test.go --
    52  package p
    53  
    54  import "x"
    55  -- t2/p/p_test.go --
    56  package p
    57  -- t2/p/p.go --
    58  package p
    59  
    60  import "x"
    61  -- t3/p/p_test.go --
    62  package p
    63  
    64  import "m/bad"
    65  -- t4/p/p_test.go --
    66  package p
    67  -- t4/p/p.go --
    68  package p
    69  
    70  import "m/bad"
    71  -- bad/bad.go --
    72  package bad
    73  
    74  import "x"
    75  

View as plain text