mirror of
https://github.com/austinried/subtracks.git
synced 2026-11-10 23:21:59 +01:00
tools/integration-test.nu is now just the entrypoint. The server lifecycle and fixture preparation live in tools/integration/servers.nu, the Subsonic request helpers in subsonic.nu, and shared waiting/port helpers in util.nu. No behaviour change; the assertions still live in the Kotlin tests.
16 lines
592 B
Nu
16 lines
592 B
Nu
# Shared helpers for the integration harness: waiting and port checks.
|
|
|
|
export def poll [label: string, check: closure, --attempts (-n): int = 120] {
|
|
for attempt in 0..<$attempts {
|
|
let value = (try { do $check } catch { null })
|
|
if $value != null { return $value }
|
|
if $attempt > 0 and ($attempt mod 5) == 0 { print $"waiting for ($label)..." }
|
|
sleep 1sec
|
|
}
|
|
error make { msg: $"timed out waiting for ($label)" }
|
|
}
|
|
|
|
export def port-in-use [port: int] {
|
|
(^curl -s -o /dev/null --max-time 1 $"http://127.0.0.1:($port)/" | complete).exit_code != 7
|
|
}
|