From 5c541cc3f8e2ad4ae0d1860fac1597a5e5895b6d Mon Sep 17 00:00:00 2001 From: Kasper Lund Date: Tue, 14 Jan 2025 11:30:34 +0100 Subject: [PATCH] Fix throw-close-test --- tests/throw-close-test.toit | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/tests/throw-close-test.toit b/tests/throw-close-test.toit index bf4fc7a..6436543 100644 --- a/tests/throw-close-test.toit +++ b/tests/throw-close-test.toit @@ -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