Remove our extra timeout logic. (#89952)

This commit is contained in:
Ian Hickson
2021-09-15 09:42:05 -07:00
committed by GitHub
parent 5d9afaa0f7
commit 2420718389
12 changed files with 136 additions and 276 deletions

View File

@@ -1,13 +0,0 @@
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('flutter_test timeout logic - addTime - negative', (WidgetTester tester) async {
await tester.runAsync(() async {
await Future<void>.delayed(const Duration(milliseconds: 3500)); // must be more than 1000ms more than the initial timeout
}, additionalTime: const Duration(milliseconds: 200));
}, initialTimeout: const Duration(milliseconds: 2000));
}

View File

@@ -1,13 +0,0 @@
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('flutter_test timeout logic - addTime - positive', (WidgetTester tester) async {
await tester.runAsync(() async {
await Future<void>.delayed(const Duration(milliseconds: 2500)); // must be longer than initial timeout below.
}, additionalTime: const Duration(milliseconds: 2000)); // initial timeout is 2s, so this makes it 4s.
}, initialTimeout: const Duration(milliseconds: 2000));
}

View File

@@ -568,9 +568,9 @@ Future<void> verifyIntegrationTestTimeouts(String workingDirectory) async {
if (errors.isNotEmpty) {
exitWithError(<String>[
if (errors.length == 1)
'${bold}An error was detected when looking at import dependencies within the flutter_tools package:$reset'
'${bold}An error was detected when looking at integration test timeouts:$reset'
else
'${bold}Multiple errors were detected when looking at import dependencies within the flutter_tools package:$reset',
'${bold}Multiple errors were detected when looking at integration test timeouts:$reset',
...errors.map((String paragraph) => '$paragraph\n'),
]);
}

View File

@@ -190,83 +190,65 @@ Future<void> _runSmokeTests() async {
// Verify that the tests actually return failure on failure and success on
// success.
final String automatedTests = path.join(flutterRoot, 'dev', 'automated_tests');
// We run the "pass" and "fail" smoke tests first, and alone, because those
// are particularly critical and sensitive. If one of these fails, there's no
// point even trying the others.
// We want to run the smoketests in parallel, because they each take some time
// to run (e.g. compiling), so we don't want to run them in series, especially
// on 20-core machines. However, we have a race condition, so for now...
// Race condition issue: https://github.com/flutter/flutter/issues/90026
final List<ShardRunner> tests = <ShardRunner>[
() => _runFlutterTest(
automatedTests,
script: path.join('test_smoke_test', 'pass_test.dart'),
printOutput: false,
),
automatedTests,
script: path.join('test_smoke_test', 'pass_test.dart'),
printOutput: false,
),
() => _runFlutterTest(
automatedTests,
script: path.join('test_smoke_test', 'fail_test.dart'),
expectFailure: true,
printOutput: false,
),
// We run the timeout tests individually because they are timing-sensitive.
automatedTests,
script: path.join('test_smoke_test', 'fail_test.dart'),
expectFailure: true,
printOutput: false,
),
() => _runFlutterTest(
automatedTests,
script: path.join('test_smoke_test', 'timeout_pass_test.dart'),
expectFailure: false,
printOutput: false,
),
automatedTests,
script: path.join('test_smoke_test', 'pending_timer_fail_test.dart'),
expectFailure: true,
printOutput: false,
outputChecker: (CommandResult result) {
return result.flattenedStdout!.contains('failingPendingTimerTest')
? null
: 'Failed to find the stack trace for the pending Timer.\n\n'
'stdout:\n${result.flattenedStdout}\n\n'
'stderr:\n${result.flattenedStderr}';
}),
() => _runFlutterTest(
automatedTests,
script: path.join('test_smoke_test', 'timeout_fail_test.dart'),
expectFailure: true,
printOutput: false,
),
() => _runFlutterTest(automatedTests,
script:
path.join('test_smoke_test', 'pending_timer_fail_test.dart'),
expectFailure: true,
printOutput: false, outputChecker: (CommandResult result) {
return result.flattenedStdout!.contains('failingPendingTimerTest')
? null
: 'Failed to find the stack trace for the pending Timer.';
}),
// We run the remaining smoketests in parallel, because they each take some
// time to run (e.g. compiling), so we don't want to run them in series,
// especially on 20-core machines...
() => Future.wait<void>(
<Future<void>>[
_runFlutterTest(
automatedTests,
script: path.join('test_smoke_test', 'crash1_test.dart'),
expectFailure: true,
printOutput: false,
),
_runFlutterTest(
automatedTests,
script: path.join('test_smoke_test', 'crash2_test.dart'),
expectFailure: true,
printOutput: false,
),
_runFlutterTest(
automatedTests,
script:
path.join('test_smoke_test', 'syntax_error_test.broken_dart'),
expectFailure: true,
printOutput: false,
),
_runFlutterTest(
automatedTests,
script: path.join(
'test_smoke_test', 'missing_import_test.broken_dart'),
expectFailure: true,
printOutput: false,
),
_runFlutterTest(
automatedTests,
script: path.join('test_smoke_test',
'disallow_error_reporter_modification_test.dart'),
expectFailure: true,
printOutput: false,
),
],
),
automatedTests,
script: path.join('test_smoke_test', 'crash1_test.dart'),
expectFailure: true,
printOutput: false,
),
() => _runFlutterTest(
automatedTests,
script: path.join('test_smoke_test', 'crash2_test.dart'),
expectFailure: true,
printOutput: false,
),
() => _runFlutterTest(
automatedTests,
script: path.join('test_smoke_test', 'syntax_error_test.broken_dart'),
expectFailure: true,
printOutput: false,
),
() => _runFlutterTest(
automatedTests,
script: path.join('test_smoke_test', 'missing_import_test.broken_dart'),
expectFailure: true,
printOutput: false,
),
() => _runFlutterTest(
automatedTests,
script: path.join('test_smoke_test', 'disallow_error_reporter_modification_test.dart'),
expectFailure: true,
printOutput: false,
),
];
List<ShardRunner> testsToRun;
@@ -785,8 +767,9 @@ Future<void> _runFrameworkTests() async {
outputChecker: (CommandResult result) {
final Iterable<Match> matches = httpClientWarning.allMatches(result.flattenedStdout!);
if (matches == null || matches.isEmpty || matches.length > 1) {
return 'Failed to print warning about HttpClientUsage, or printed it too many times.\n'
'stdout:\n${result.flattenedStdout}';
return 'Failed to print warning about HttpClientUsage, or printed it too many times.\n\n'
'stdout:\n${result.flattenedStdout}\n\n'
'stderr:\n${result.flattenedStderr}';
}
return null;
},
@@ -1773,9 +1756,9 @@ List<T> _selectIndexOfTotalSubshard<T>(List<T> tests, {String subshardKey = kSub
exit(1);
}
final int testsPerShard = tests.length ~/ total;
final int testsPerShard = (tests.length / total).ceil();
final int start = (index - 1) * testsPerShard;
final int end = index * testsPerShard;
final int end = math.min(index * testsPerShard, tests.length);
print('Selecting subshard $index of $total (range ${start + 1}-$end of ${tests.length})');
return tests.sublist(start, end);

View File

@@ -109,19 +109,19 @@ void main() {
}
test('subshards tests correctly', () async {
// When updating this test, try to pick shard numbers that ensure we're checking
// that unequal test distributions don't miss tests.
ProcessResult result = await runScript(
<String, String>{'SHARD': 'smoke_tests', 'SUBSHARD': '1_3'},
);
expectExitCode(result, 0);
// There are currently 6 smoke tests. This shard should contain test 1 and 2.
expect(result.stdout, contains('Selecting subshard 1 of 3 (range 1-2 of 6)'));
expect(result.stdout, contains('Selecting subshard 1 of 3 (range 1-3 of 8)'));
result = await runScript(
<String, String>{'SHARD': 'smoke_tests', 'SUBSHARD': '5_6'},
<String, String>{'SHARD': 'smoke_tests', 'SUBSHARD': '3_3'},
);
expectExitCode(result, 0);
// This shard should contain only test 5.
expect(result.stdout, contains('Selecting subshard 5 of 6 (range 5-5 of 6)'));
expect(result.stdout, contains('Selecting subshard 3 of 3 (range 7-8 of 8)'));
});
test('exits with code 1 when SUBSHARD index greater than total', () async {

View File

@@ -491,7 +491,6 @@ void main() {
final String themeName = themeNames[themeIndex];
testWidgets('backdrop_demo $themeName', (WidgetTester tester) async {
tester.binding.addTime(const Duration(seconds: 3));
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(theme: theme, home: const BackdropDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline));
@@ -499,7 +498,6 @@ void main() {
});
testWidgets('bottom_app_bar_demo $themeName', (WidgetTester tester) async {
tester.binding.addTime(const Duration(seconds: 3));
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(theme: theme, home: const BottomAppBarDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline));
@@ -507,7 +505,6 @@ void main() {
});
testWidgets('bottom_navigation_demo $themeName', (WidgetTester tester) async {
tester.binding.addTime(const Duration(seconds: 3));
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(theme: theme, home: const BottomNavigationDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline));
@@ -515,7 +512,6 @@ void main() {
});
testWidgets('buttons_demo $themeName', (WidgetTester tester) async {
tester.binding.addTime(const Duration(seconds: 3));
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(theme: theme, home: const ButtonsDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline));
@@ -523,7 +519,6 @@ void main() {
});
testWidgets('cards_demo $themeName', (WidgetTester tester) async {
tester.binding.addTime(const Duration(seconds: 3));
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(theme: theme, home: const CardsDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline));
@@ -531,7 +526,6 @@ void main() {
});
testWidgets('chip_demo $themeName', (WidgetTester tester) async {
tester.binding.addTime(const Duration(seconds: 3));
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(theme: theme, home: const ChipDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline));
@@ -539,7 +533,6 @@ void main() {
});
testWidgets('data_table_demo $themeName', (WidgetTester tester) async {
tester.binding.addTime(const Duration(seconds: 3));
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(theme: theme, home: const DataTableDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline));
@@ -547,7 +540,6 @@ void main() {
});
testWidgets('date_and_time_picker_demo $themeName', (WidgetTester tester) async {
tester.binding.addTime(const Duration(seconds: 3));
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(theme: theme, home: const DateAndTimePickerDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline));
@@ -555,7 +547,6 @@ void main() {
});
testWidgets('dialog_demo $themeName', (WidgetTester tester) async {
tester.binding.addTime(const Duration(seconds: 3));
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(theme: theme, home: const DialogDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline));
@@ -563,7 +554,6 @@ void main() {
});
testWidgets('drawer_demo $themeName', (WidgetTester tester) async {
tester.binding.addTime(const Duration(seconds: 3));
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(theme: theme, home: const DrawerDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline));
@@ -571,7 +561,6 @@ void main() {
});
testWidgets('elevation_demo $themeName', (WidgetTester tester) async {
tester.binding.addTime(const Duration(seconds: 3));
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(theme: theme, home: const ElevationDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline));
@@ -579,7 +568,6 @@ void main() {
});
testWidgets('expansion_panels_demo $themeName', (WidgetTester tester) async {
tester.binding.addTime(const Duration(seconds: 3));
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(theme: theme, home: const ExpansionPanelsDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline));
@@ -587,7 +575,6 @@ void main() {
});
testWidgets('grid_list_demo $themeName', (WidgetTester tester) async {
tester.binding.addTime(const Duration(seconds: 3));
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(theme: theme, home: const GridListDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline));
@@ -595,7 +582,6 @@ void main() {
});
testWidgets('icons_demo $themeName', (WidgetTester tester) async {
tester.binding.addTime(const Duration(seconds: 3));
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(theme: theme, home: const IconsDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline));
@@ -603,7 +589,6 @@ void main() {
});
testWidgets('leave_behind_demo $themeName', (WidgetTester tester) async {
tester.binding.addTime(const Duration(seconds: 3));
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(theme: theme, home: const LeaveBehindDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline));
@@ -611,7 +596,6 @@ void main() {
});
testWidgets('list_demo $themeName', (WidgetTester tester) async {
tester.binding.addTime(const Duration(seconds: 3));
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(theme: theme, home: const ListDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline));
@@ -619,7 +603,6 @@ void main() {
});
testWidgets('menu_demo $themeName', (WidgetTester tester) async {
tester.binding.addTime(const Duration(seconds: 3));
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(theme: theme, home: const MenuDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline));
@@ -627,7 +610,6 @@ void main() {
});
testWidgets('modal_bottom_sheet_demo $themeName', (WidgetTester tester) async {
tester.binding.addTime(const Duration(seconds: 3));
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(
MaterialApp(theme: theme, home: const ModalBottomSheetDemo())
@@ -637,7 +619,6 @@ void main() {
});
testWidgets('overscroll_demo', (WidgetTester tester) async {
tester.binding.addTime(const Duration(seconds: 3));
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(const MaterialApp(home: OverscrollDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline));
@@ -645,7 +626,6 @@ void main() {
});
testWidgets('page_selector_demo $themeName', (WidgetTester tester) async {
tester.binding.addTime(const Duration(seconds: 3));
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(theme: theme, home: const PageSelectorDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline));
@@ -653,7 +633,6 @@ void main() {
});
testWidgets('persistent_bottom_sheet_demo $themeName', (WidgetTester tester) async {
tester.binding.addTime(const Duration(seconds: 3));
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(
MaterialApp(theme: theme, home: const PersistentBottomSheetDemo())
@@ -663,7 +642,6 @@ void main() {
});
testWidgets('progress_indicator_demo $themeName', (WidgetTester tester) async {
tester.binding.addTime(const Duration(seconds: 3));
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(theme: theme, home: const ProgressIndicatorDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline));
@@ -671,7 +649,6 @@ void main() {
});
testWidgets('reorderable_list_demo $themeName', (WidgetTester tester) async {
tester.binding.addTime(const Duration(seconds: 3));
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(theme: theme, home: const ReorderableListDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline));
@@ -679,7 +656,6 @@ void main() {
});
testWidgets('scrollable_tabs_demo $themeName', (WidgetTester tester) async {
tester.binding.addTime(const Duration(seconds: 3));
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(theme: theme, home: const ScrollableTabsDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline));
@@ -687,7 +663,6 @@ void main() {
});
testWidgets('search_demo $themeName', (WidgetTester tester) async {
tester.binding.addTime(const Duration(seconds: 3));
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(theme: theme, home: const SearchDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline));
@@ -695,7 +670,6 @@ void main() {
});
testWidgets('selection_controls_demo $themeName', (WidgetTester tester) async {
tester.binding.addTime(const Duration(seconds: 3));
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(theme: theme, home: const SelectionControlsDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline));
@@ -703,7 +677,6 @@ void main() {
});
testWidgets('slider_demo $themeName', (WidgetTester tester) async {
tester.binding.addTime(const Duration(seconds: 3));
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(theme: theme, home: const SliderDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline));
@@ -711,7 +684,6 @@ void main() {
});
testWidgets('snack_bar_demo $themeName', (WidgetTester tester) async {
tester.binding.addTime(const Duration(seconds: 3));
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(
MaterialApp(theme: theme, home: const SnackBarDemo())
@@ -721,7 +693,6 @@ void main() {
});
testWidgets('tabs_demo $themeName', (WidgetTester tester) async {
tester.binding.addTime(const Duration(seconds: 3));
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(theme: theme, home: const TabsDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline));
@@ -729,7 +700,6 @@ void main() {
});
testWidgets('tabs_fab_demo $themeName', (WidgetTester tester) async {
tester.binding.addTime(const Duration(seconds: 3));
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(theme: theme, home: const TabsFabDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline));
@@ -737,7 +707,6 @@ void main() {
});
testWidgets('text_form_field_demo $themeName', (WidgetTester tester) async {
tester.binding.addTime(const Duration(seconds: 3));
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(theme: theme, home: const TextFormFieldDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline));
@@ -745,7 +714,6 @@ void main() {
});
testWidgets('tooltip_demo $themeName', (WidgetTester tester) async {
tester.binding.addTime(const Duration(seconds: 3));
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(theme: theme, home: const TooltipDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline));
@@ -753,7 +721,6 @@ void main() {
});
testWidgets('expansion_tile_list_demo $themeName', (WidgetTester tester) async {
tester.binding.addTime(const Duration(seconds: 3));
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(theme: theme, home: const ExpansionTileListDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline));

View File

@@ -6,9 +6,9 @@
#include "generated_plugin_registrant.h"
#include <url_launcher_windows/url_launcher_plugin.h>
#include <url_launcher_windows/url_launcher_windows.h>
void RegisterPlugins(flutter::PluginRegistry* registry) {
UrlLauncherPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("UrlLauncherPlugin"));
UrlLauncherWindowsRegisterWithRegistrar(
registry->GetRegistrarForPlugin("UrlLauncherWindows"));
}