test: deflake the suite — pumpEventQueue instead of Future.delayed(Duration.zero)
~173 `await Future<void>.delayed(Duration.zero)` async-settle waits across 25 test files yield the microtask queue exactly once; when an event→handler chain needs more than one hop they lose the race under CI's parallel load, so the failing set varied run to run. Replace with `await pumpEventQueue()` (the deterministic drain already used elsewhere in the suite); rewired the shared settle()/tick() helpers in one shot. menu_bar's toggle-close test gets a bounded extra pump. Verified green under CI=true. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -12,7 +12,7 @@ void main() {
|
||||
final events = <ClideEventEnvelope>[];
|
||||
final sub = bus.stream.listen(events.add);
|
||||
bus.emit(const ThemeChanged(themeName: 'summer-night'));
|
||||
await Future<void>.delayed(Duration.zero);
|
||||
await pumpEventQueue();
|
||||
expect(events, hasLength(1));
|
||||
expect(events.first.event, isA<ThemeChanged>());
|
||||
await sub.cancel();
|
||||
@@ -26,7 +26,7 @@ void main() {
|
||||
bus.emit(const ThemeChanged(themeName: 'a'));
|
||||
bus.emit(const ExtensionActivated(id: 'builtin.git'));
|
||||
bus.emit(const ThemeChanged(themeName: 'b'));
|
||||
await Future<void>.delayed(Duration.zero);
|
||||
await pumpEventQueue();
|
||||
expect(themes.map((e) => e.themeName), ['a', 'b']);
|
||||
expect(extensions.map((e) => e.id), ['builtin.git']);
|
||||
await s1.cancel();
|
||||
@@ -39,7 +39,7 @@ void main() {
|
||||
final s1 = bus.stream.listen((e) => a.add(e.event));
|
||||
final s2 = bus.stream.listen((e) => b.add(e.event));
|
||||
bus.emit(const ThemeChanged(themeName: 'x'));
|
||||
await Future<void>.delayed(Duration.zero);
|
||||
await pumpEventQueue();
|
||||
expect(a, hasLength(1));
|
||||
expect(b, hasLength(1));
|
||||
await s1.cancel();
|
||||
@@ -57,7 +57,7 @@ void main() {
|
||||
final sub = bus.stream.listen(capture.add);
|
||||
final before = DateTime.now().toUtc();
|
||||
bus.emit(const ThemeChanged(themeName: 'n'));
|
||||
await Future<void>.delayed(Duration.zero);
|
||||
await pumpEventQueue();
|
||||
final after = DateTime.now().toUtc();
|
||||
expect(capture, hasLength(1));
|
||||
final ts = capture.first.timestamp;
|
||||
|
||||
@@ -30,7 +30,7 @@ void main() {
|
||||
final received = <Message>[];
|
||||
final sub = bus.subscribe().listen(received.add);
|
||||
bus.publish('git', 'status-changed', {'dirty': true});
|
||||
await Future<void>.delayed(Duration.zero);
|
||||
await pumpEventQueue();
|
||||
expect(received, hasLength(1));
|
||||
expect(received.first.publisher, 'git');
|
||||
expect(received.first.channel, 'status-changed');
|
||||
@@ -44,7 +44,7 @@ void main() {
|
||||
bus.publish('git', 'a', const {});
|
||||
bus.publish('pty', 'a', const {});
|
||||
bus.publish('git', 'b', const {});
|
||||
await Future<void>.delayed(Duration.zero);
|
||||
await pumpEventQueue();
|
||||
expect(got.map((m) => m.channel), ['a', 'b']);
|
||||
await sub.cancel();
|
||||
});
|
||||
@@ -55,7 +55,7 @@ void main() {
|
||||
bus.publish('pty', 'output', const {});
|
||||
bus.publish('pty', 'exit', const {});
|
||||
bus.publish('git', 'output', const {});
|
||||
await Future<void>.delayed(Duration.zero);
|
||||
await pumpEventQueue();
|
||||
expect(got.map((m) => m.publisher), ['pty', 'git']);
|
||||
await sub.cancel();
|
||||
});
|
||||
@@ -66,7 +66,7 @@ void main() {
|
||||
bus.publish('git', 'status', const {});
|
||||
bus.publish('git', 'other', const {});
|
||||
bus.publish('pty', 'status', const {});
|
||||
await Future<void>.delayed(Duration.zero);
|
||||
await pumpEventQueue();
|
||||
expect(got, hasLength(1));
|
||||
await sub.cancel();
|
||||
});
|
||||
|
||||
@@ -175,9 +175,9 @@ void main() {
|
||||
final s2 = f.services.events.on<ExtensionDeactivated>().listen((e) => deactivated.add(e.id));
|
||||
f.services.extensions.register(_Ext(id: 'e'));
|
||||
await f.services.extensions.activateAll();
|
||||
await Future<void>.delayed(Duration.zero);
|
||||
await pumpEventQueue();
|
||||
await f.services.extensions.deactivate('e');
|
||||
await Future<void>.delayed(Duration.zero);
|
||||
await pumpEventQueue();
|
||||
expect(activated, ['e']);
|
||||
expect(deactivated, ['e']);
|
||||
await s1.cancel();
|
||||
|
||||
@@ -46,7 +46,7 @@ void main() {
|
||||
final sub = log.records.listen(out.add);
|
||||
log.info('s', 'm1');
|
||||
log.info('s', 'm2');
|
||||
await Future<void>.delayed(Duration.zero);
|
||||
await pumpEventQueue();
|
||||
expect(out.map((r) => r.message), ['m1', 'm2']);
|
||||
await sub.cancel();
|
||||
await log.dispose();
|
||||
|
||||
@@ -283,7 +283,7 @@ void main() {
|
||||
addTearDown(n.dispose);
|
||||
|
||||
n.warn('clide CLI not on PATH', title: 'dogfood');
|
||||
await Future<void>.delayed(Duration.zero);
|
||||
await pumpEventQueue();
|
||||
|
||||
expect(toasts.entries, hasLength(1));
|
||||
expect(toasts.entries.single.message, 'dogfood — clide CLI not on PATH');
|
||||
@@ -299,7 +299,7 @@ void main() {
|
||||
|
||||
n.error('boom');
|
||||
n.success('done');
|
||||
await Future<void>.delayed(Duration.zero);
|
||||
await pumpEventQueue();
|
||||
|
||||
expect(toasts.entries.map((e) => e.severity), [ToastSeverity.error, ToastSeverity.success]);
|
||||
});
|
||||
|
||||
@@ -24,7 +24,7 @@ void main() {
|
||||
test('shows a toast for each message published to the toast channel', () async {
|
||||
final (t, bus) = make();
|
||||
publishToast(bus, 'builtin.git', 'Pushed to origin/main', severity: ToastSeverity.success, duration: Duration.zero);
|
||||
await Future<void>.delayed(Duration.zero); // let the broadcast stream deliver
|
||||
await pumpEventQueue(); // let the broadcast stream deliver
|
||||
expect(t.entries.single.message, 'Pushed to origin/main');
|
||||
expect(t.entries.single.severity, ToastSeverity.success);
|
||||
});
|
||||
@@ -33,7 +33,7 @@ void main() {
|
||||
final (t, bus) = make();
|
||||
bus.publish('x', toastChannel, {'severity': 'error'}); // no message
|
||||
bus.publish('x', 'other-channel', {'message': 'nope'}); // wrong channel
|
||||
await Future<void>.delayed(Duration.zero);
|
||||
await pumpEventQueue();
|
||||
expect(t.entries, isEmpty);
|
||||
});
|
||||
|
||||
@@ -41,7 +41,7 @@ void main() {
|
||||
final (t, bus) = make();
|
||||
bus.publish('x', toastChannel, {'message': 'a', 'severity': 'warning', 'durationMs': 0});
|
||||
bus.publish('x', toastChannel, {'message': 'b', 'severity': 'bogus', 'durationMs': 0});
|
||||
await Future<void>.delayed(Duration.zero);
|
||||
await pumpEventQueue();
|
||||
expect(t.entries.map((e) => e.severity), [ToastSeverity.warning, ToastSeverity.info]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user