mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Make DAP tests more tolerant of output that didn't come from the app being tested (#97291)
Fixes #97238.
This commit is contained in:
parent
daf6465cd1
commit
4fa0e0d449
@ -40,8 +40,8 @@ void main() {
|
||||
|
||||
// Once the "topLevelFunction" output arrives, we can terminate the app.
|
||||
unawaited(
|
||||
dap.client.outputEvents
|
||||
.firstWhere((OutputEventBody output) => output.output.startsWith('topLevelFunction'))
|
||||
dap.client.output
|
||||
.firstWhere((String output) => output.startsWith('topLevelFunction'))
|
||||
.whenComplete(() => dap.client.terminate()),
|
||||
);
|
||||
|
||||
@ -70,8 +70,8 @@ void main() {
|
||||
|
||||
// Once the "topLevelFunction" output arrives, we can terminate the app.
|
||||
unawaited(
|
||||
dap.client.outputEvents
|
||||
.firstWhere((OutputEventBody output) => output.output.startsWith('topLevelFunction'))
|
||||
dap.client.stdoutOutput
|
||||
.firstWhere((String output) => output.startsWith('topLevelFunction'))
|
||||
.whenComplete(() => dap.client.terminate()),
|
||||
);
|
||||
|
||||
@ -118,7 +118,7 @@ void main() {
|
||||
|
||||
// Launch the app and wait for it to print "topLevelFunction".
|
||||
await Future.wait(<Future<void>>[
|
||||
dap.client.outputEvents.firstWhere((OutputEventBody output) => output.output.startsWith('topLevelFunction')),
|
||||
dap.client.stdoutOutput.firstWhere((String output) => output.startsWith('topLevelFunction')),
|
||||
dap.client.start(
|
||||
launch: () => dap.client.launch(
|
||||
cwd: project.dir.path,
|
||||
@ -130,7 +130,7 @@ void main() {
|
||||
|
||||
// Capture the next two output events that we expect to be the Reload
|
||||
// notification and then topLevelFunction being printed again.
|
||||
final Future<List<String>> outputEventsFuture = dap.client.output
|
||||
final Future<List<String>> outputEventsFuture = dap.client.stdoutOutput
|
||||
// But skip any topLevelFunctions that come before the reload.
|
||||
.skipWhile((String output) => output.startsWith('topLevelFunction'))
|
||||
.take(2)
|
||||
@ -155,7 +155,7 @@ void main() {
|
||||
|
||||
// Launch the app and wait for it to print "topLevelFunction".
|
||||
await Future.wait(<Future<void>>[
|
||||
dap.client.outputEvents.firstWhere((OutputEventBody output) => output.output.startsWith('topLevelFunction')),
|
||||
dap.client.stdoutOutput.firstWhere((String output) => output.startsWith('topLevelFunction')),
|
||||
dap.client.start(
|
||||
launch: () => dap.client.launch(
|
||||
cwd: project.dir.path,
|
||||
@ -167,7 +167,7 @@ void main() {
|
||||
|
||||
// Capture the next two output events that we expect to be the Restart
|
||||
// notification and then topLevelFunction being printed again.
|
||||
final Future<List<String>> outputEventsFuture = dap.client.output
|
||||
final Future<List<String>> outputEventsFuture = dap.client.stdoutOutput
|
||||
// But skip any topLevelFunctions that come before the restart.
|
||||
.skipWhile((String output) => output.startsWith('topLevelFunction'))
|
||||
.take(2)
|
||||
@ -233,8 +233,7 @@ void main() {
|
||||
// Launch the app and wait for it to print "topLevelFunction" so we know
|
||||
// it's up and running.
|
||||
await Future.wait(<Future<void>>[
|
||||
dap.client.outputEvents.firstWhere((OutputEventBody output) =>
|
||||
output.output.startsWith('topLevelFunction')),
|
||||
dap.client.stdoutOutput.firstWhere((String output) => output.startsWith('topLevelFunction')),
|
||||
dap.client.start(
|
||||
launch: () => dap.client.launch(
|
||||
cwd: project.dir.path,
|
||||
|
||||
@ -63,6 +63,11 @@ class DapTestClient {
|
||||
/// Returns a stream of the string output from [OutputEventBody] events.
|
||||
Stream<String> get output => outputEvents.map((OutputEventBody output) => output.output);
|
||||
|
||||
/// Returns a stream of the string output from [OutputEventBody] events with the category 'stdout'.
|
||||
Stream<String> get stdoutOutput => outputEvents
|
||||
.where((OutputEventBody output) => output.category == 'stdout')
|
||||
.map((OutputEventBody output) => output.output);
|
||||
|
||||
/// Sends a custom request to the server and waits for a response.
|
||||
Future<Response> custom(String name, [Object? args]) async {
|
||||
return sendRequest(args, overrideCommand: name);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user