[dds/dap] Fix flaky detach test
This test is to check the output contains "Detached" but didn't account for "Hello" appearing based on timing (during detach, we resume the isolate and depending on timing, we may or may not get the OutputEvent for the `print` in the test application).
This change switches from `emits` to `emitsThrough` so that the "Hello" event is ignored rather than a failure.
Fixes https://github.com/dart-lang/sdk/issues/53721
Change-Id: Ie624ba06e9f70dcbc887b2c280a3d2eb19dee29c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/348162
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Helin Shiah <helinx@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
diff --git a/pkg/dds/test/dap/integration/debug_attach_test.dart b/pkg/dds/test/dap/integration/debug_attach_test.dart
index e197523..2e12e28 100644
--- a/pkg/dds/test/dap/integration/debug_attach_test.dart
+++ b/pkg/dds/test/dap/integration/debug_attach_test.dart
@@ -148,8 +148,12 @@
// Expect that termination is reported as 'Detached' when we explicitly
// requested a detach.
- expect(client.outputEvents.map((output) => output.output.trim()),
- emits('Detached.'));
+ expect(
+ client.outputEvents.map((output) => output.output.trim()),
+ // emitsThrough because we might still get "Hello" in the output
+ // because we resume as part of detach.
+ emitsThrough('Detached.'),
+ );
// Detach using terminateRequest. Despite the name, terminateRequest is
// the request for a graceful detach (and disconnectRequest is the