Skip to content

Commit d2196a6

Browse files
authored
[flutter_tools, flutter_test] Deprecate --experimental-faster-testing (flutter#196123)
Deprecates the unused `--experimental-faster-testing` flag (emitting a deprecation warning when passed) and removes `FlutterTestRunner.runTestsBySpawningLightweightEngines` from `flutter_tools` (along with its unused direct `package:ffi` dependency), while keeping the native FFI hooks in `tester_main.cc` intact. Also removes the `defaultRouteNameTestValue = '/'` initialization workaround from `TestWidgetsFlutterBinding()` and clears `defaultRouteNameTestValue` in `TestWidgetsFlutterBinding.reset()`. Closes flutter#146603 Closes flutter#161083 Closes flutter#168657
1 parent 215858f commit d2196a6

7 files changed

Lines changed: 55 additions & 932 deletions

File tree

‎packages/flutter_test/lib/src/binding.dart‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,7 +1169,6 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
11691169
/// This constructor overrides the [debugPrint] global hook to point to
11701170
/// [debugPrintOverride], which can be overridden by subclasses.
11711171
TestWidgetsFlutterBinding() {
1172-
platformDispatcher.defaultRouteNameTestValue = '/';
11731172
debugPrint = debugPrintOverride;
11741173
debugDisableShadows = disableShadows;
11751174
}
@@ -1227,7 +1226,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
12271226
void reset() {
12281227
_restorationManager?.dispose();
12291228
_restorationManager = null;
1230-
platformDispatcher.defaultRouteNameTestValue = '/';
1229+
platformDispatcher.clearDefaultRouteNameTestValue();
12311230
resetGestureBinding();
12321231
testTextInput.reset();
12331232
if (registerTestTextInput) {

‎packages/flutter_test/test/platform_dispatcher_test.dart‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,21 @@ void main() {
148148
);
149149
});
150150

151+
testWidgets('TestWidgetsFlutterBinding.reset clears defaultRouteNameTestValue', (
152+
WidgetTester tester,
153+
) async {
154+
final TestWidgetsFlutterBinding binding = retrieveTestBinding(tester);
155+
binding.platformDispatcher.defaultRouteNameTestValue = 'fake_route';
156+
expect(binding.platformDispatcher.defaultRouteName, 'fake_route');
157+
158+
binding.reset();
159+
160+
expect(
161+
binding.platformDispatcher.defaultRouteName,
162+
PlatformDispatcher.instance.defaultRouteName,
163+
);
164+
});
165+
151166
testWidgets('TestPlatformDispatcher can fake accessibility features', (
152167
WidgetTester tester,
153168
) async {

‎packages/flutter_tools/lib/src/commands/test.dart‎

Lines changed: 13 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,9 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
135135
name: 'experimental-faster-testing',
136136
negatable: false,
137137
verboseOnly: true,
138-
help: 'Run each test in a separate lightweight Flutter Engine to speed up testing.',
138+
help:
139+
'(deprecated) This option is deprecated and no longer has any effect. '
140+
'This flag will be removed in a future version of Flutter.',
139141
);
140142

141143
static const _name = MultiOptionDescriptor(
@@ -524,21 +526,11 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
524526
);
525527
}
526528

527-
bool experimentalFasterTesting = getValue(_experimentalFasterTesting);
528-
if (experimentalFasterTesting) {
529-
if (_isIntegrationTest || isWeb) {
530-
experimentalFasterTesting = false;
531-
logger.printStatus(
532-
'--experimental-faster-testing was parsed but will be ignored. This '
533-
'option is not supported when running integration tests or web tests.',
534-
);
535-
} else if (_testFileUris.length == 1) {
536-
experimentalFasterTesting = false;
537-
logger.printStatus(
538-
'--experimental-faster-testing was parsed but will be ignored. This '
539-
'option should not be used when running a single test file.',
540-
);
541-
}
529+
if (getValue(_experimentalFasterTesting)) {
530+
logger.printWarning(
531+
'The "--experimental-faster-testing" flag is deprecated and no longer '
532+
'has any effect. This flag will be removed in a future version of Flutter.',
533+
);
542534
}
543535

544536
final bool startPaused = getValue(_startPaused);
@@ -619,13 +611,6 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
619611
// Running with concurrency will result in deploying multiple test apps
620612
// on the connected device concurrently, which is not supported.
621613
jobs = 1;
622-
} else if (experimentalFasterTesting) {
623-
if (wasParsed(_concurrency)) {
624-
logger.printStatus(
625-
'-j/--concurrency was parsed but will be ignored. This option is not '
626-
'compatible with --experimental-faster-testing.',
627-
);
628-
}
629614
}
630615

631616
final int? shardIndex = getValue(_shardIndex);
@@ -650,23 +635,6 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
650635
}
651636

652637
final bool enableVmService = getValue(_enableVmService);
653-
if (experimentalFasterTesting && enableVmService) {
654-
logger.printStatus(
655-
'--enable-vmservice was parsed but will be ignored. This option is not '
656-
'compatible with --experimental-faster-testing.',
657-
);
658-
}
659-
660-
final bool ipv6 = getValue(_ipv6);
661-
if (experimentalFasterTesting && ipv6) {
662-
// [ipv6] is set when the user desires for the test harness server to use
663-
// IPv6, but a test harness server will not be started at all when
664-
// [experimentalFasterTesting] is set.
665-
logger.printStatus(
666-
'--ipv6 was parsed but will be ignored. This option is not compatible '
667-
'with --experimental-faster-testing.',
668-
);
669-
}
670638

671639
CoverageCollector? collector;
672640
if (getValue(_coverage) || getValue(_mergeCoverage) || getValue(_branchCoverage)) {
@@ -774,16 +742,11 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
774742
final Stopwatch? testRunnerTimeRecorderStopwatch = testTimeRecorder?.start(
775743
TestTimePhases.TestRunner,
776744
);
777-
final int result;
778-
if (experimentalFasterTesting) {
779-
assert(!isWeb && !_isIntegrationTest && _testFileUris.length > 1);
780-
result = await _testRunner.runTestsBySpawningLightweightEngines(
781-
_testFileUris.toList(),
782-
executionSpec,
783-
);
784-
} else {
785-
result = await _testRunner.runTests(testWrapper, _testFileUris.toList(), executionSpec);
786-
}
745+
final int result = await _testRunner.runTests(
746+
testWrapper,
747+
_testFileUris.toList(),
748+
executionSpec,
749+
);
787750
testTimeRecorder?.stop(TestTimePhases.TestRunner, testRunnerTimeRecorderStopwatch!);
788751

789752
if (collector != null) {

0 commit comments

Comments
 (0)