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

     1  # Run parallel chatty tests. Assert on CONT lines. This test makes sure that
     2  # multiple parallel outputs have the appropriate CONT lines between them.
     3  go test -parallel 3 chatty_parallel_test.go -v
     4  
     5  stdout '--- PASS: TestFast \([0-9.]{4}s\)\n=== CONT  TestSlow\n    chatty_parallel_test.go:31: this is the second TestSlow log\n--- PASS: TestSlow \([0-9.]{4}s\)'
     6  
     7  -- chatty_parallel_test.go --
     8  package chatty_parallel_test
     9  
    10  import (
    11  	"testing"
    12  	"time"
    13  )
    14  
    15  var (
    16  	run           = make(chan struct{})
    17  	afterFirstLog = make(chan struct{})
    18  	afterPass     = make(chan struct{})
    19  )
    20  
    21  func TestFast(t *testing.T) {
    22  	t.Parallel()
    23  
    24  	<-afterFirstLog
    25  	t.Cleanup(func() {
    26  		close(afterPass)
    27  	})
    28  }
    29  
    30  func TestSlow(t *testing.T) {
    31  	t.Parallel()
    32  
    33  	t.Logf("this is the first TestSlow log")
    34  	close(afterFirstLog)
    35  
    36  	<-afterPass
    37  	time.Sleep(100 * time.Millisecond)
    38  	t.Logf("this is the second TestSlow log")
    39  }
    40  

View as plain text