waitUntilReady method
Runs test -f <filePath> inside the container on each poll cycle.
On timeout, a diagnostic ls of the parent directory is run inside the
container and included in the TimeoutException message.
Implementation
@override
Future<void> waitUntilReady(WaitStrategyTarget target) async {
final ready = await poll(() async {
final (exitCode, _) = await target.exec(['test', '-f', filePath]);
return exitCode == 0;
});
if (!ready) {
// Best-effort: list the parent directory inside the container for diagnostics.
String listing = '(unavailable)';
try {
// p.dirname handles edge cases such as '/ready' → '/' correctly.
final parent = p.dirname(filePath);
final (_, output) = await target.exec(['ls', '-la', parent]);
listing = String.fromCharCodes(output);
} catch (_) {
// Diagnostic only — ignore errors.
}
throw TimeoutException(
'File $filePath not found in container within $startupTimeout. '
'Parent directory contents: $listing',
);
}
}