diff --git a/test/folder_size_test.dart b/test/folder_size_test.dart index e192279..ac42e46 100644 --- a/test/folder_size_test.dart +++ b/test/folder_size_test.dart @@ -24,12 +24,16 @@ void main() { }); tearDown(() => tmp.deleteSync(recursive: true)); - Future idle(FolderSizes s, String path) async { - for (var i = 0; i < 300 && s.of(path) == null; i++) { + // 관리자 지적 (10/18): 전체 시험 중 PC 가 바쁘면 정해진 횟수 (300 × 10ms) 안에 끝나지 않아 흔들렸다 - 실제 시간으로 (최대 30초) 기다린다 + Future until(bool Function() ok, {Duration max = const Duration(seconds: 30)}) async { + final end = DateTime.now().add(max); + while (!ok() && DateTime.now().isBefore(end)) { await Future.delayed(const Duration(milliseconds: 10)); } } + Future idle(FolderSizes s, String path) => until(() => s.of(path) != null); + test('안쪽 폴더까지 합 · 기억 · 바뀌면 그 폴더 · 안쪽 · 위 폴더를 잊음', () async { var reads = 0; final s = FolderSizes(list: (d) { @@ -115,13 +119,14 @@ void main() { final a = p.join(tmp.path, 'a'), b = p.join(tmp.path, 'b'); s.request(a, forDir: tmp.path); // 세는 중 (gate 에서 기다림) s.request(b, forDir: tmp.path); // 기다리는 중 - await Future.delayed(const Duration(milliseconds: 20)); + await until(() => read.contains('a')); expect(s.busy(a) && s.busy(b), isTrue); // 다른 폴더로 감 s.retainAuto([p.join(tmp.path, 'elsewhere')]); expect(s.busy(b), isFalse, reason: '기다리던 것은 빠진다'); gate.complete(); - await Future.delayed(const Duration(milliseconds: 100)); + await until(() => !s.busy(a)); + expect(s.busy(a), isFalse); expect(s.of(a), isNull, reason: '세던 것은 멈추고 남기지 않는다'); expect(read, isNot(contains('b'))); @@ -134,11 +139,11 @@ void main() { // [cancel] s.request(a); s.cancel(a); - await Future.delayed(const Duration(milliseconds: 100)); + await until(() => !s.busy(a)); expect(s.of(a), isNull); expect(s.busy(a), isFalse); s.dispose(); - }); + }, timeout: const Timeout(Duration(minutes: 2))); test('크기순 정렬: 아는 폴더는 그 크기로, 모르는 폴더는 가장 작게 (폴더는 늘 위)', () { final now = DateTime(2026);