...

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

Documentation: cmd/go/testdata/script

     1[short] skip
     2
     3# test fail fast
     4! go test ./failfast_test.go -run='TestFailingA' -failfast=true
     5stdout -count=1 'FAIL - '
     6! go test ./failfast_test.go -run='TestFailing[AB]' -failfast=true
     7stdout -count=1 'FAIL - '
     8! go test ./failfast_test.go -run='TestFailing[AB]' -failfast=false
     9stdout -count=2 'FAIL - '
    10
    11# mix with non-failing tests
    12! go test ./failfast_test.go -run='TestA|TestFailing[AB]' -failfast=true
    13stdout -count=1 'FAIL - '
    14! go test ./failfast_test.go -run='TestA|TestFailing[AB]' -failfast=false
    15stdout -count=2 'FAIL - '
    16
    17# mix with parallel tests
    18! go test ./failfast_test.go -run='TestFailingB|TestParallelFailingA' -failfast=true
    19stdout -count=2 'FAIL - '
    20! go test ./failfast_test.go -run='TestFailingB|TestParallelFailingA' -failfast=false
    21stdout -count=2 'FAIL - '
    22! go test ./failfast_test.go -run='TestFailingB|TestParallelFailing[AB]' -failfast=true
    23stdout -count=3 'FAIL - '
    24! go test ./failfast_test.go -run='TestFailingB|TestParallelFailing[AB]' -failfast=false
    25stdout -count=3 'FAIL - '
    26
    27# mix with parallel sub-tests
    28! go test ./failfast_test.go -run='TestFailingB|TestParallelFailing[AB]|TestParallelFailingSubtestsA' -failfast=true
    29stdout -count=3 'FAIL - '
    30! go test ./failfast_test.go -run='TestFailingB|TestParallelFailing[AB]|TestParallelFailingSubtestsA' -failfast=false
    31stdout -count=5 'FAIL - '
    32! go test ./failfast_test.go -run='TestParallelFailingSubtestsA' -failfast=true
    33stdout -count=1 'FAIL - '
    34
    35# only parallels
    36! go test ./failfast_test.go -run='TestParallelFailing[AB]' -failfast=false
    37stdout -count=2 'FAIL - '
    38
    39# non-parallel subtests
    40! go test ./failfast_test.go -run='TestFailingSubtestsA' -failfast=true
    41stdout -count=1 'FAIL - '
    42! go test ./failfast_test.go -run='TestFailingSubtestsA' -failfast=false
    43stdout -count=2 'FAIL - '
    44
    45# fatal test
    46! go test ./failfast_test.go -run='TestFatal[CD]' -failfast=true
    47stdout -count=1 'FAIL - '
    48! go test ./failfast_test.go -run='TestFatal[CD]' -failfast=false
    49stdout -count=2 'FAIL - '
    50
    51# cross package failfast
    52! go test -p 1 -failfast ./a ./b ./c
    53stdout -count=1 'FAIL - '
    54stdout -count=1 'FAIL - TestFailingPkgA'
    55
    56-- go.mod --
    57module m
    58
    59go 1.21.0
    60-- failfast_test.go --
    61// Copyright 2017 The Go Authors. All rights reserved.
    62// Use of this source code is governed by a BSD-style
    63// license that can be found in the LICENSE file.
    64
    65package failfast
    66
    67import "testing"
    68
    69func TestA(t *testing.T) {
    70	// Edge-case testing, mixing unparallel tests too
    71	t.Logf("LOG: %s", t.Name())
    72}
    73
    74func TestFailingA(t *testing.T) {
    75	t.Errorf("FAIL - %s", t.Name())
    76}
    77
    78func TestB(t *testing.T) {
    79	// Edge-case testing, mixing unparallel tests too
    80	t.Logf("LOG: %s", t.Name())
    81}
    82
    83func TestParallelFailingA(t *testing.T) {
    84	t.Parallel()
    85	t.Errorf("FAIL - %s", t.Name())
    86}
    87
    88func TestParallelFailingB(t *testing.T) {
    89	t.Parallel()
    90	t.Errorf("FAIL - %s", t.Name())
    91}
    92
    93func TestParallelFailingSubtestsA(t *testing.T) {
    94	t.Parallel()
    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
   103func TestFailingSubtestsA(t *testing.T) {
   104	t.Run("TestFailingSubtestsA1", func(t *testing.T) {
   105		t.Errorf("FAIL - %s", t.Name())
   106	})
   107	t.Run("TestFailingSubtestsA2", func(t *testing.T) {
   108		t.Errorf("FAIL - %s", t.Name())
   109	})
   110}
   111
   112func TestFailingB(t *testing.T) {
   113	t.Errorf("FAIL - %s", t.Name())
   114}
   115
   116func TestFatalC(t *testing.T) {
   117	t.Fatalf("FAIL - %s", t.Name())
   118}
   119
   120func TestFatalD(t *testing.T) {
   121	t.Fatalf("FAIL - %s", t.Name())
   122}
   123-- a/a_test.go --
   124package a
   125
   126import "testing"
   127
   128func TestFailingPkgA(t *testing.T) {
   129	t.Errorf("FAIL - %s", t.Name())
   130}
   131-- b/b_test.go --
   132package b
   133
   134import "testing"
   135
   136func TestFailingPkgB(t *testing.T) {
   137	t.Errorf("FAIL - %s", t.Name())
   138}
   139-- c/c_test.go --
   140package c
   141
   142import "testing"
   143
   144func TestFailingPkgC(t *testing.T) {
   145	t.Errorf("FAIL - %s", t.Name())
   146}

View as plain text