[skip ci] test fix

This commit is contained in:
Brahim Hadriche committed 2026-10-08 08:45:03 -04:00
1 parent fb85ab94f0
commit f6af555573
1 file changed
+11 -17
@@ -5,30 +5,24 @@ import "pkg:/source/utils/Logging.bs"
function ExecuteJob() as void
input = JobGetInput()
if JobIsCancelled()
JobCancel()
LogInfo("Job cancelled before execution")
return
end if
sleepTimeMs = ValidInt(input.sleep)
if sleepTimeMs > 0
callback = JobGetCallbackNode()
if callback <> invalid
' Register before reading: a cancel between the read and the registration would reach no observer
cancellation = JobGetCancellation()
messagePort = CreateObject("roMessagePort")
cancellation = CancellationUtils.CreateCancellation(callback, "cancel", true)
CancellationUtils.ObserveCancellationScoped(cancellation, messagePort)
cancelled = CancellationUtils.IsCancelled(cancellation)
sleepTimeMs = ValidInt(input.sleep)
if not cancelled and sleepTimeMs > 0
message = wait(sleepTimeMs, messagePort)
cancelled = CancellationUtils.IsCancellationEvent(cancellation, message)
end if
CancellationUtils.UnobserveCancellationScoped(cancellation)
if CancellationUtils.IsCancellationEvent(cancellation, message)
LogInfo("Job cancelled during execution")
if cancelled
LogInfo("Simulated job cancellation for testing purposes")
JobCancel()
return
end if
else
sleep(sleepTimeMs)
end if
end if
if not input.success
JobError("Simulated job error for testing purposes")