diff --git a/test/sftp_explorer_test.dart b/test/sftp_explorer_test.dart index 7bf9115..82a6dee 100644 --- a/test/sftp_explorer_test.dart +++ b/test/sftp_explorer_test.dart @@ -32,8 +32,10 @@ void main() { } }); - Future settle(WidgetTester tester, bool Function() done, {int rounds = 300}) async { - for (var i = 0; i < rounds; i++) { + // 횟수가 아니라 실제 시간으로 기다린다 (전체 시험이 함께 돌아 무거우면 paramiko 서버의 키 교환이 몇십 초 걸린다 - 관리자 지적 10/18) + Future settle(WidgetTester tester, bool Function() done, {Duration limit = const Duration(seconds: 90)}) async { + final end = DateTime.now().add(limit); + while (DateTime.now().isBefore(end)) { await tester.runAsync(() => Future.delayed(const Duration(milliseconds: 30))); await tester.pump(); if (done()) break; diff --git a/test/support/sftp_server.dart b/test/support/sftp_server.dart index bacde6d..c852208 100644 --- a/test/support/sftp_server.dart +++ b/test/support/sftp_server.dart @@ -41,8 +41,19 @@ class SftpTestServer { ]); final lines = pr.stdout.transform(utf8.decoder).transform(const LineSplitter()).asBroadcastStream(); pr.stderr.drain(); - final port = int.parse((await lines.firstWhere((l) => l.startsWith('PORT '))).split(' ')[1]); - final fp = (await lines.firstWhere((l) => l.startsWith('FINGERPRINT '))).split(' ')[1]; + final port = int.parse((await lines.firstWhere((l) => l.startsWith('PORT ')).timeout(const Duration(seconds: 60))).split(' ')[1]); + final fp = (await lines.firstWhere((l) => l.startsWith('FINGERPRINT ')).timeout(const Duration(seconds: 30))).split(' ')[1]; + // 무거울 때도 포트가 연결을 받는 것을 본 뒤에 시작한다 (관리자 지적 10/18) + final end = DateTime.now().add(const Duration(seconds: 30)); + while (true) { + try { + (await Socket.connect('127.0.0.1', port, timeout: const Duration(seconds: 2))).destroy(); + break; + } on SocketException { + if (DateTime.now().isAfter(end)) rethrow; + await Future.delayed(const Duration(milliseconds: 200)); + } + } return SftpTestServer._(pr, port, fp); }