...

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

Documentation: cmd/go/testdata/script

     1# Run parallel chatty tests. Assert on CONT or NAME lines. This test makes sure that
     2# multiple parallel outputs have the appropriate CONT lines between them.
     3go test -parallel 3 chatty_parallel -v
     4
     5stdout '=== RUN   TestInterruptor/interruption\n=== (CONT|NAME)  TestLog\n    chatty_parallel_test.go:28: this is the second TestLog log\n--- PASS: Test(Log|Interruptor) \([0-9.]{4}s\)'
     6
     7-- go.mod --
     8module chatty_parallel
     9
    10go 1.18
    11-- chatty_parallel_test.go --
    12package chatty_parallel_test
    13
    14import (
    15	"testing"
    16)
    17
    18var (
    19	afterFirstLog = make(chan struct{})
    20	afterSubTest  = make(chan struct{})
    21	afterSecondLog = make(chan struct{})
    22)
    23
    24func TestInterruptor(t *testing.T) {
    25	t.Parallel()
    26
    27	<-afterFirstLog
    28	t.Run("interruption", func (t *testing.T) {})
    29	close(afterSubTest)
    30	<-afterSecondLog // Delay the "PASS: TestInterruptor" line until after "CONT  TestLog".
    31}
    32
    33func TestLog(t *testing.T) {
    34	t.Parallel()
    35
    36	t.Logf("this is the first TestLog log")
    37	close(afterFirstLog)
    38	<-afterSubTest
    39	t.Logf("this is the second TestLog log")
    40	close(afterSecondLog)
    41}

View as plain text