Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix integration_test/test/live_connection/eval_and_inspect_test.dart flake #8123

Merged
merged 4 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ class EvalTester {
await tester.pump(safePumpDuration);
await _pressEnter();

expect(expectedResponse, findsOneWidget);
final responseFinder = await retryUntilFound(
expectedResponse,
tester: tester,
);
expect(responseFinder, findsOneWidget);
}

Future<void> _pressEnter() async {
Expand Down
16 changes: 16 additions & 0 deletions packages/devtools_test/lib/src/helpers/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,22 @@ void verifyIsSearchMatchForTreeData<T extends TreeDataSearchStateMixin<T>>(
}
}

/// Given a [finder], repeatedly pumps until found, or until there are no more
/// retries.
Future<Finder> retryUntilFound(
Finder finder, {
required WidgetTester tester,
int retries = 3,
}) async {
if (retries == 0) return finder;

final found = tester.any(finder);
if (found) return finder;

await tester.pump(safePumpDuration);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How long is safePumpDuration?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 seconds:

const shortPumpDuration = Duration(seconds: 1);
const safePumpDuration = Duration(seconds: 3);
const longPumpDuration = Duration(seconds: 6);
const veryLongPumpDuration = Duration(seconds: 9);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! That seems reasonable, I think.

return retryUntilFound(finder, tester: tester, retries: retries - 1);
}

void logStatus(String log) {
// ignore: avoid_print, intentional print for test output
print('TEST STATUS: $log');
Expand Down
Loading