File tree Expand file tree Collapse file tree 3 files changed +18
-4
lines changed Expand file tree Collapse file tree 3 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -170,7 +170,7 @@ func (w *workload) run(ctx context.Context) {
170170 tc := w .newTestContext (ctx )
171171 // Any assertion failure from this test context will result in process exit due to the
172172 // panic being rethrown. This ensures that failures in test setup are fatal.
173- defer tc .Recover ( true /* rethrow */ )
173+ defer tc .RecoverAndRethrow ( )
174174
175175 xAVAX , pAVAX := e2e .GetWalletBalances (tc , w .wallet )
176176 assert .Reachable ("wallet starting" , map [string ]any {
@@ -215,7 +215,7 @@ func (w *workload) run(ctx context.Context) {
215215func (w * workload ) executeTest (ctx context.Context ) {
216216 tc := w .newTestContext (ctx )
217217 // Panics will be recovered without being rethrown, ensuring that test failures are not fatal.
218- defer tc .Recover (false /* rethrow */ )
218+ defer tc .Recover ()
219219 require := require .New (tc )
220220
221221 val , err := rand .Int (rand .Reader , big .NewInt (5 ))
Original file line number Diff line number Diff line change @@ -151,7 +151,7 @@ func (w *workload) run(ctx context.Context) {
151151 )
152152 // Any assertion failure from this test context will result in process exit due to the
153153 // panic being rethrown. This ensures that failures in test setup are fatal.
154- defer tc .Recover ( true /* rethrow */ )
154+ defer tc .RecoverAndRethrow ( )
155155 require := require .New (tc )
156156
157157 uri := w .uris [w .id % len (w .uris )]
Original file line number Diff line number Diff line change @@ -102,11 +102,25 @@ func (tc *SimpleTestContext) RecoverAndExit() {
102102 }
103103}
104104
105+ // Recover is intended to be deferred in a function executing a test whose
106+ // assertions may result in panics. Such a panic is intended to be recovered to
107+ // allow cleanup functions to be called before execution continues.
108+ func (tc * SimpleTestContext ) Recover () {
109+ tc .recover (false /* rethrow */ )
110+ }
111+
112+ // RecoverAndRethrow is intended to be deferred in a function executing a test
113+ // whose assertions may result in panics. Such a panic is intended to be recovered
114+ // to allow cleanup functions to be called before the panic is rethrown.
115+ func (tc * SimpleTestContext ) RecoverAndRethrow () {
116+ tc .recover (true /* rethrow */ )
117+ }
118+
105119// Recover is intended to be deferred in a function executing a test
106120// whose assertions may result in panics. Such a panic is intended to
107121// be recovered to allow cleanup functions to be called. A panic can
108122// be optionally rethrown by setting `rethrow` to true.
109- func (tc * SimpleTestContext ) Recover (rethrow bool ) {
123+ func (tc * SimpleTestContext ) recover (rethrow bool ) {
110124 // Recover from test failure
111125 var panicData any
112126 if panicData = recover (); panicData != nil {
You can’t perform that action at this time.
0 commit comments