diff --git a/Vault/Tests/FoundationExtensionsTests/Task+RaceTests.swift b/Vault/Tests/FoundationExtensionsTests/Task+RaceTests.swift index 1a5dbfeb3..c123e1f00 100644 --- a/Vault/Tests/FoundationExtensionsTests/Task+RaceTests.swift +++ b/Vault/Tests/FoundationExtensionsTests/Task+RaceTests.swift @@ -14,8 +14,11 @@ enum TaskRaceTests { @Test("Cancellation is always checked before returning") func noScheduledTasksCancelledThrowsCancellation() async throws { + let cancellationWaiter = TaskCancellationWaiter() let parent = Task { - try await Task.race(firstResolved: [TaskRace]()) + // Only race once cancelled, as the task might otherwise run to completion before `cancel()`. + await cancellationWaiter.waitForTaskCancellation() + return try await Task.race(firstResolved: [TaskRace]()) } parent.cancel() @@ -143,8 +146,11 @@ enum TaskRaceTests { @Test("Cancellation is always checked before returning") func noScheduledTasksCancelledThrowsCancellation() async throws { + let cancellationWaiter = TaskCancellationWaiter() let parent = Task { - try await Task.race(firstValue: [TaskRace]()) + // Only race once cancelled, as the task might otherwise run to completion before `cancel()`. + await cancellationWaiter.waitForTaskCancellation() + return try await Task.race(firstValue: [TaskRace]()) } parent.cancel() diff --git a/scripts/validate.sh b/scripts/validate.sh index de92a2b89..4e1099939 100755 --- a/scripts/validate.sh +++ b/scripts/validate.sh @@ -171,6 +171,11 @@ destination="id=$udid" step "Lint" make -C Vault lint fastlane_note="" +# Shells that haven't run `rbenv init` (non-interactive ones, like an agent's) +# would otherwise find the system Ruby and skip this check. +if command -v rbenv >/dev/null; then + PATH="$(rbenv root)/shims:$PATH" +fi ruby_version=$(cat "$worktree/.ruby-version") if [ "$(cd "$worktree" && ruby -e 'print RUBY_VERSION' 2>/dev/null)" = "$ruby_version" ]; then step "Fastlane config" /bin/bash -c \