From c3a47b3449b02274225498f8725d8aa7346a2c95 Mon Sep 17 00:00:00 2001 From: Ian Hickson Date: Thu, 20 Aug 2020 14:56:05 -0700 Subject: [PATCH] Remove more timeouts (#63433) --- .../lib/src/test/flutter_platform.dart | 55 +------------------ 1 file changed, 2 insertions(+), 53 deletions(-) diff --git a/packages/flutter_tools/lib/src/test/flutter_platform.dart b/packages/flutter_tools/lib/src/test/flutter_platform.dart index 686ccaa88a..8fd501c4ba 100644 --- a/packages/flutter_tools/lib/src/test/flutter_platform.dart +++ b/packages/flutter_tools/lib/src/test/flutter_platform.dart @@ -30,30 +30,6 @@ import 'test_compiler.dart'; import 'test_config.dart'; import 'watcher.dart'; -/// The timeout we give the test process to connect to the test harness -/// once the process has entered its main method. -/// -/// We time out test execution because we expect some tests to hang and we want -/// to know which test hung, rather than have the entire test harness just do -/// nothing for a few hours until the user (or CI environment) gets bored. -const Duration _kTestStartupTimeout = Duration(minutes: 5); - -/// The timeout we give the test process to start executing Dart code. When the -/// CPU is under severe load, this can take a while, but it's not indicative of -/// any problem with Flutter, so we give it a large timeout. -/// -/// See comment under [_kTestStartupTimeout] regarding timeouts. -const Duration _kTestProcessTimeout = Duration(minutes: 5); - -/// Message logged by the test process to signal that its main method has begun -/// execution. -/// -/// The test harness responds by starting the [_kTestStartupTimeout] countdown. -/// The CPU may be throttled, which can cause a long delay in between when the -/// process is spawned and when dart code execution begins; we don't want to -/// hold that against the test. -const String _kStartTimeoutTimerMessage = 'sky_shell test process has entered main method'; - /// The address at which our WebSocket server resides and at which the sky_shell /// processes will host the Observatory server. final Map _kHosts = { @@ -213,7 +189,6 @@ void catchIsolateErrors() { void main() { - print('$_kStartTimeoutTimerMessage'); String serverPort = Platform.environment['SERVER_PORT'] ?? ''; String server = Uri.decodeComponent('$encodedWebsocketUrl:\$serverPort'); StreamChannel channel = serializeSuite(() { @@ -243,7 +218,7 @@ void main() { return buffer.toString(); } -enum InitialResult { crashed, timedOut, connected } +enum InitialResult { crashed, connected } enum TestResult { crashed, harnessBailed, testBailed } @@ -507,7 +482,6 @@ class FlutterPlatform extends PlatformPlugin { } }); - final Completer timeout = Completer(); final Completer gotProcessObservatoryUri = Completer(); if (!enableObservatory) { gotProcessObservatoryUri.complete(); @@ -543,10 +517,6 @@ class FlutterPlatform extends PlatformPlugin { watcher?.handleStartedProcess( ProcessEvent(ourTestCount, process, processObservatoryUri)); }, - startTimeoutTimer: () { - Future.delayed(_kTestStartupTimeout) - .then((_) => timeout.complete()); - }, ); // At this point, three things can happen next: @@ -556,8 +526,6 @@ class FlutterPlatform extends PlatformPlugin { globals.printTrace('test $ourTestCount: awaiting initial result for pid ${process.pid}'); final InitialResult initialResult = await Future.any(>[ process.exitCode.then((int exitCode) => InitialResult.crashed), - timeout.future.then((void value) => InitialResult.timedOut), - Future.delayed(_kTestProcessTimeout, () => InitialResult.timedOut), gotProcessObservatoryUri.future.then((void value) { return webSocket.future.then( (WebSocket webSocket) => InitialResult.connected, @@ -582,20 +550,6 @@ class FlutterPlatform extends PlatformPlugin { await controller.sink.done; await watcher?.handleTestCrashed(ProcessEvent(ourTestCount, process)); break; - case InitialResult.timedOut: - // Could happen either if the process takes a long time starting - // (_kTestProcessTimeout), or if once Dart code starts running, it takes a - // long time to open the WebSocket connection (_kTestStartupTimeout). - globals.printTrace('test $ourTestCount: timed out waiting for process with pid ${process.pid} to connect to test harness'); - final String message = _getErrorMessage('Test never connected to test harness.', testPath, shellPath); - controller.sink.addError(message); - // Awaited for with 'sink.done' below. - unawaited(controller.sink.close()); - globals.printTrace('test $ourTestCount: waiting for controller sink to close'); - await controller.sink.done; - await watcher - ?.handleTestTimedOut(ProcessEvent(ourTestCount, process)); - break; case InitialResult.connected: globals.printTrace('test $ourTestCount: process with pid ${process.pid} connected to test harness'); final WebSocket testSocket = await webSocket.future; @@ -875,7 +829,6 @@ class FlutterPlatform extends PlatformPlugin { void _pipeStandardStreamsToConsole( Process process, { - void startTimeoutTimer(), Future reportObservatoryUri(Uri uri), }) { @@ -889,11 +842,7 @@ class FlutterPlatform extends PlatformPlugin { .transform(const LineSplitter()) .listen( (String line) async { - if (line == _kStartTimeoutTimerMessage) { - if (startTimeoutTimer != null) { - startTimeoutTimer(); - } - } else if (line.startsWith("error: Unable to read Dart source 'package:test/")) { + if (line.startsWith("error: Unable to read Dart source 'package:test/")) { globals.printTrace('Shell: $line'); globals.printError('\n\nFailed to load test harness. Are you missing a dependency on flutter_test?\n'); } else if (line.startsWith(observatoryString)) {