Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/ConsoleKit/Activity/ActivityIndicator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public final class ActivityIndicator<A>: Sendable where A: ActivityIndicatorType
let timer = AsyncTimerSequence(
interval: .milliseconds(refreshRate),
tolerance: .milliseconds(10),
clock: .continuous
clock: .suspending
)

var tick: UInt = 0
Expand Down
17 changes: 17 additions & 0 deletions Tests/ConsoleKitTests/ActivityTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,23 @@ struct ActivityTests {
}
}

@Test("Task Cancellation")
func taskCancellation() async throws {
let console = Terminal()
let indicator = console.loadingBar(title: "Loading")

let task = Task {
try await indicator.withActivityIndicator {
try await Task.sleep(for: .seconds(5))
}
}

try await Task.sleep(for: .seconds(1))
task.cancel()

await #expect(throws: CancellationError.self) { try await task.value }
}

@Test("Activity Width Key")
func activityWidthKey() {
var dict = [AnySendableHashable: String]()
Expand Down