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

     1  [short] skip
     2  
     3  # test fail fast
     4  ! go test ./failfast_test.go -run='TestFailingA' -failfast=true
     5  stdout -count=1 'FAIL - '
     6  ! go test ./failfast_test.go -run='TestFailing[AB]' -failfast=true
     7  stdout -count=1 'FAIL - '
     8  ! go test ./failfast_test.go -run='TestFailing[AB]' -failfast=false
     9  stdout -count=2 'FAIL - '
    10  
    11  # mix with non-failing tests
    12  ! go test ./failfast_test.go -run='TestA|TestFailing[AB]' -failfast=true
    13  stdout -count=1 'FAIL - '
    14  ! go test ./failfast_test.go -run='TestA|TestFailing[AB]' -failfast=false
    15  stdout -count=2 'FAIL - '
    16  
    17  # mix with parallel tests
    18  ! go test ./failfast_test.go -run='TestFailingB|TestParallelFailingA' -failfast=true
    19  stdout -count=2 'FAIL - '
    20  ! go test ./failfast_test.go -run='TestFailingB|TestParallelFailingA' -failfast=false
    21  stdout -count=2 'FAIL - '
    22  ! go test ./failfast_test.go -run='TestFailingB|TestParallelFailing[AB]' -failfast=true
    23  stdout -count=3 'FAIL - '
    24  ! go test ./failfast_test.go -run='TestFailingB|TestParallelFailing[AB]' -failfast=false
    25  stdout -count=3 'FAIL - '
    26  
    27  # mix with parallel sub-tests
    28  ! go test ./failfast_test.go -run='TestFailingB|TestParallelFailing[AB]|TestParallelFailingSubtestsA' -failfast=true
    29  stdout -count=3 'FAIL - '
    30  ! go test ./failfast_test.go -run='TestFailingB|TestParallelFailing[AB]|TestParallelFailingSubtestsA' -failfast=false
    31  stdout -count=5 'FAIL - '
    32  ! go test ./failfast_test.go -run='TestParallelFailingSubtestsA' -failfast=true
    33  stdout -count=1 'FAIL - '
    34  
    35  # only parallels
    36  ! go test ./failfast_test.go -run='TestParallelFailing[AB]' -failfast=false
    37  stdout -count=2 'FAIL - '
    38  
    39  # non-parallel subtests
    40  ! go test ./failfast_test.go -run='TestFailingSubtestsA' -failfast=true
    41  stdout -count=1 'FAIL - '
    42  ! go test ./failfast_test.go -run='TestFailingSubtestsA' -failfast=false
    43  stdout -count=2 'FAIL - '
    44  
    45  # fatal test
    46  ! go test ./failfast_test.go -run='TestFatal[CD]' -failfast=true
    47  stdout -count=1 'FAIL - '
    48  ! go test ./failfast_test.go -run='TestFatal[CD]' -failfast=false
    49  stdout -count=2 'FAIL - '
    50  
    51  -- failfast_test.go --
    52  // Copyright 2017 The Go Authors. All rights reserved.
    53  // Use of this source code is governed by a BSD-style
    54  // license that can be found in the LICENSE file.
    55  
    56  package failfast
    57  
    58  import "testing"
    59  
    60  func TestA(t *testing.T) {
    61  	// Edge-case testing, mixing unparallel tests too
    62  	t.Logf("LOG: %s", t.Name())
    63  }
    64  
    65  func TestFailingA(t *testing.T) {
    66  	t.Errorf("FAIL - %s", t.Name())
    67  }
    68  
    69  func TestB(t *testing.T) {
    70  	// Edge-case testing, mixing unparallel tests too
    71  	t.Logf("LOG: %s", t.Name())
    72  }
    73  
    74  func TestParallelFailingA(t *testing.T) {
    75  	t.Parallel()
    76  	t.Errorf("FAIL - %s", t.Name())
    77  }
    78  
    79  func TestParallelFailingB(t *testing.T) {
    80  	t.Parallel()
    81  	t.Errorf("FAIL - %s", t.Name())
    82  }
    83  
    84  func TestParallelFailingSubtestsA(t *testing.T) {
    85  	t.Parallel()
    86  	t.Run("TestFailingSubtestsA1", func(t *testing.T) {
    87  		t.Errorf("FAIL - %s", t.Name())
    88  	})
    89  	t.Run("TestFailingSubtestsA2", func(t *testing.T) {
    90  		t.Errorf("FAIL - %s", t.Name())
    91  	})
    92  }
    93  
    94  func TestFailingSubtestsA(t *testing.T) {
    95  	t.Run("TestFailingSubtestsA1", func(t *testing.T) {
    96  		t.Errorf("FAIL - %s", t.Name())
    97  	})
    98  	t.Run("TestFailingSubtestsA2", func(t *testing.T) {
    99  		t.Errorf("FAIL - %s", t.Name())
   100  	})
   101  }
   102  
   103  func TestFailingB(t *testing.T) {
   104  	t.Errorf("FAIL - %s", t.Name())
   105  }
   106  
   107  func TestFatalC(t *testing.T) {
   108  	t.Fatalf("FAIL - %s", t.Name())
   109  }
   110  
   111  func TestFatalD(t *testing.T) {
   112  	t.Fatalf("FAIL - %s", t.Name())
   113  }
   114  

View as plain text