MCPcopy Create free account
hub / github.com/buke/quickjs-go / TestRuntimeTimeoutOpaqueNotFreedInHandler

Function TestRuntimeTimeoutOpaqueNotFreedInHandler

runtime_test.go:1012–1036  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1010}
1011
1012func TestRuntimeTimeoutOpaqueNotFreedInHandler(t *testing.T) {
1013 base := timeoutOpaqueCount()
1014
1015 rt := NewRuntime()
1016 defer rt.Close()
1017 ctx := rt.NewContext()
1018 defer ctx.Close()
1019
1020 rt.SetExecuteTimeout(1)
1021 require.Equal(t, base+1, timeoutOpaqueCount())
1022
1023 result := ctx.Eval(`while(true){}`)
1024 defer result.Free()
1025 require.True(t, result.IsException())
1026
1027 err := ctx.Exception()
1028 require.Error(t, err)
1029 require.Contains(t, err.Error(), "interrupted")
1030
1031 // timeoutHandler should not free opaque state; cleanup happens on clear/replace.
1032 require.Equal(t, base+1, timeoutOpaqueCount())
1033
1034 rt.ClearInterruptHandler()
1035 require.Equal(t, base, timeoutOpaqueCount())
1036}
1037
1038func TestRuntimeTimeoutOpaqueConcurrentLifecycle(t *testing.T) {
1039 base := timeoutOpaqueCount()

Callers

nothing calls this directly

Calls 13

CloseMethod · 0.95
NewContextMethod · 0.95
CloseMethod · 0.95
SetExecuteTimeoutMethod · 0.95
EvalMethod · 0.95
ExceptionMethod · 0.95
ClearInterruptHandlerMethod · 0.95
timeoutOpaqueCountFunction · 0.85
NewRuntimeFunction · 0.85
EqualMethod · 0.80
IsExceptionMethod · 0.80
FreeMethod · 0.45

Tested by

no test coverage detected