Skip to content

Commit

Permalink
Fix throw-close-test
Browse files Browse the repository at this point in the history
  • Loading branch information
kasperl committed Jan 14, 2025
1 parent 14ee61a commit 5c541cc
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions tests/throw-close-test.toit
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,40 @@
import expect show *
import watchdog show WatchdogServiceClient
import system.services show ServiceProvider ServiceHandler
import system.api.trace show TraceService

import .util

main:
service := TraceServiceProvider
service.install
run-test: | client/WatchdogServiceClient ms/int system-dog/FakeSystemWatchdog |
dog := client.create "toit.io/test/throw-close"
dog.start --s=1
expect-throw "WATCHDOG_NOT_STOPPED":
dog.close
expect-equals 0 service.traces.size
dog.close
expect-equals 1 service.traces.size
service.uninstall

class TraceServiceProvider extends ServiceProvider
implements TraceService ServiceHandler:
traces_/List := []

constructor:
super "system/trace/test" --major=1 --minor=2
provides TraceService.SELECTOR --handler=this

handle index/int arguments/any --gid/int --client/int -> any:
if index == TraceService.HANDLE-TRACE-INDEX:
return handle-trace arguments
unreachable

traces -> List:
result := traces_
traces_ = []
return result

handle-trace message/ByteArray -> ByteArray?:
traces_.add message
return null

0 comments on commit 5c541cc

Please sign in to comment.