github.com/ydb-platform/ydb-go-sdk/v3@v3.57.0/internal/xtest/logger.go (about)

     1  package xtest
     2  
     3  import (
     4  	"sync"
     5  	"testing"
     6  )
     7  
     8  func MakeSyncedTest(t testing.TB) *SyncedTest {
     9  	return &SyncedTest{
    10  		TB: t,
    11  	}
    12  }
    13  
    14  type SyncedTest struct {
    15  	m sync.Mutex
    16  	testing.TB
    17  }
    18  
    19  func (s *SyncedTest) Cleanup(f func()) {
    20  	s.m.Lock()
    21  	defer s.m.Unlock()
    22  	s.TB.Helper()
    23  
    24  	s.TB.Cleanup(f)
    25  }
    26  
    27  func (s *SyncedTest) Error(args ...interface{}) {
    28  	s.m.Lock()
    29  	defer s.m.Unlock()
    30  	s.TB.Helper()
    31  
    32  	s.TB.Error(args...)
    33  }
    34  
    35  func (s *SyncedTest) Errorf(format string, args ...interface{}) {
    36  	s.m.Lock()
    37  	defer s.m.Unlock()
    38  	s.TB.Helper()
    39  
    40  	s.TB.Errorf(format, args...)
    41  }
    42  
    43  func (s *SyncedTest) Fail() {
    44  	s.m.Lock()
    45  	defer s.m.Unlock()
    46  	s.TB.Helper()
    47  
    48  	s.TB.Fail()
    49  }
    50  
    51  func (s *SyncedTest) FailNow() {
    52  	s.m.Lock()
    53  	defer s.m.Unlock()
    54  	s.TB.Helper()
    55  
    56  	s.TB.FailNow()
    57  }
    58  
    59  func (s *SyncedTest) Failed() bool {
    60  	s.m.Lock()
    61  	defer s.m.Unlock()
    62  	s.TB.Helper()
    63  
    64  	return s.TB.Failed()
    65  }
    66  
    67  func (s *SyncedTest) Fatal(args ...interface{}) {
    68  	s.m.Lock()
    69  	defer s.m.Unlock()
    70  	s.TB.Helper()
    71  
    72  	s.TB.Fatal(args...)
    73  }
    74  
    75  func (s *SyncedTest) Fatalf(format string, args ...interface{}) {
    76  	s.m.Lock()
    77  	defer s.m.Unlock()
    78  	s.TB.Helper()
    79  
    80  	s.TB.Fatalf(format, args...)
    81  }
    82  
    83  // must direct called
    84  // func (s *SyncedTest) Helper() {
    85  //	s.m.Lock()
    86  //	defer s.m.Unlock()
    87  //	s.TB.Helper()
    88  //}
    89  
    90  func (s *SyncedTest) Log(args ...interface{}) {
    91  	s.m.Lock()
    92  	defer s.m.Unlock()
    93  	s.TB.Helper()
    94  
    95  	s.TB.Log(args...)
    96  }
    97  
    98  func (s *SyncedTest) Logf(format string, args ...interface{}) {
    99  	s.m.Lock()
   100  	defer s.m.Unlock()
   101  	s.TB.Helper()
   102  
   103  	s.TB.Logf(format, args...)
   104  }
   105  
   106  func (s *SyncedTest) Name() string {
   107  	s.m.Lock()
   108  	defer s.m.Unlock()
   109  	s.TB.Helper()
   110  
   111  	return s.TB.Name()
   112  }
   113  
   114  func (s *SyncedTest) Setenv(key, value string) {
   115  	panic("not implemented")
   116  }
   117  
   118  func (s *SyncedTest) Skip(args ...interface{}) {
   119  	s.m.Lock()
   120  	defer s.m.Unlock()
   121  	s.TB.Helper()
   122  
   123  	s.TB.Skip(args...)
   124  }
   125  
   126  func (s *SyncedTest) SkipNow() {
   127  	s.m.Lock()
   128  	defer s.m.Unlock()
   129  	s.TB.Helper()
   130  
   131  	s.TB.SkipNow()
   132  }
   133  
   134  func (s *SyncedTest) Skipf(format string, args ...interface{}) {
   135  	s.m.Lock()
   136  	defer s.m.Unlock()
   137  	s.TB.Helper()
   138  	s.TB.Skipf(format, args...)
   139  }
   140  
   141  func (s *SyncedTest) Skipped() bool {
   142  	s.m.Lock()
   143  	defer s.m.Unlock()
   144  	s.TB.Helper()
   145  
   146  	return s.TB.Skipped()
   147  }
   148  
   149  func (s *SyncedTest) TempDir() string {
   150  	s.m.Lock()
   151  	defer s.m.Unlock()
   152  	s.TB.Helper()
   153  
   154  	return s.TB.TempDir()
   155  }