[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
+15 -21
@@ -5,29 +5,23 @@ import "pkg:/source/utils/Logging.bs"
function ExecuteJob() as void function ExecuteJob() as void
input = JobGetInput() input = JobGetInput()
if JobIsCancelled() ' Register before reading: a cancel between the read and the registration would reach no observer
JobCancel() cancellation = JobGetCancellation()
LogInfo("Job cancelled before execution") messagePort = CreateObject("roMessagePort")
return CancellationUtils.ObserveCancellationScoped(cancellation, messagePort)
end if
cancelled = CancellationUtils.IsCancelled(cancellation)
sleepTimeMs = ValidInt(input.sleep) sleepTimeMs = ValidInt(input.sleep)
if sleepTimeMs > 0 if not cancelled and sleepTimeMs > 0
callback = JobGetCallbackNode() message = wait(sleepTimeMs, messagePort)
if callback <> invalid cancelled = CancellationUtils.IsCancellationEvent(cancellation, message)
messagePort = CreateObject("roMessagePort") end if
cancellation = CancellationUtils.CreateCancellation(callback, "cancel", true) CancellationUtils.UnobserveCancellationScoped(cancellation)
CancellationUtils.ObserveCancellationScoped(cancellation, messagePort)
message = wait(sleepTimeMs, messagePort) if cancelled
CancellationUtils.UnobserveCancellationScoped(cancellation) LogInfo("Simulated job cancellation for testing purposes")
if CancellationUtils.IsCancellationEvent(cancellation, message) JobCancel()
LogInfo("Job cancelled during execution") return
JobCancel()
return
end if
else
sleep(sleepTimeMs)
end if
end if end if
if not input.success if not input.success