Unverified Commit cb518c42 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

Fix progress indicators for release/profile builds of web. (#42857)

parent 01f779e9
......@@ -183,12 +183,14 @@ class ResidentWebRunner extends ResidentRunner {
);
// When connecting to a browser, update the message with a seemsSlow notification
// to handle the case where we fail to connect.
if (debuggingOptions.browserLaunch) {
buildStatus.stop();
buildStatus.stop();
statusActive = false;
if (debuggingOptions.browserLaunch && supportsServiceProtocol) {
buildStatus = logger.startProgress(
'Attempting to connect to browser instance..',
timeout: const Duration(seconds: 30),
);
statusActive = true;
}
await device.startApp(package,
mainPath: target,
......@@ -201,8 +203,10 @@ class ResidentWebRunner extends ResidentRunner {
_connectionResult = await _webFs.connect(debuggingOptions);
unawaited(_connectionResult.debugConnection.onDone.whenComplete(() => exit(0)));
}
buildStatus.stop();
statusActive = false;
if (statusActive) {
buildStatus.stop();
statusActive = false;
}
appStartedCompleter?.complete();
return attach(
connectionInfoCompleter: connectionInfoCompleter,
......
......@@ -112,7 +112,6 @@ class Dart2JSTarget extends Target {
Source.artifact(Artifact.flutterWebSdk),
Source.artifact(Artifact.dart2jsSnapshot),
Source.artifact(Artifact.engineDartBinary),
Source.artifact(Artifact.engineDartSdkPath),
Source.pattern('{BUILD_DIR}/main.dart'),
Source.pattern('{PROJECT_DIR}/.packages'),
Source.function(listDartSources), // <- every dart file under {PROJECT_DIR}/lib and in .packages
......
......@@ -7,8 +7,10 @@ import 'dart:async';
import 'package:dwds/dwds.dart';
import 'package:flutter_tools/src/base/common.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/device.dart';
import 'package:flutter_tools/src/globals.dart';
import 'package:flutter_tools/src/project.dart';
import 'package:flutter_tools/src/resident_runner.dart';
import 'package:flutter_tools/src/build_runner/resident_web_runner.dart';
......@@ -62,6 +64,9 @@ void main() {
test('Can successfully run and connect without vmservice', () => testbed.run(() async {
_setupMocks();
final DelegateLogger delegateLogger = logger;
final MockStatus mockStatus = MockStatus();
delegateLogger.status = mockStatus;
final Completer<DebugConnectionInfo> connectionInfoCompleter = Completer<DebugConnectionInfo>();
unawaited(residentWebRunner.run(
connectionInfoCompleter: connectionInfoCompleter,
......@@ -69,6 +74,9 @@ void main() {
final DebugConnectionInfo debugConnectionInfo = await connectionInfoCompleter.future;
expect(debugConnectionInfo.wsUri, null);
verify(mockStatus.stop()).called(1);
}, overrides: <Type, Generator>{
Logger: () => DelegateLogger(BufferLogger()),
}));
test('Can full restart after attaching', () => testbed.run(() async {
......@@ -109,3 +117,5 @@ class MockBuildDaemonCreator extends Mock implements BuildDaemonCreator {}
class MockFlutterWebFs extends Mock implements WebFs {}
class MockDebugConnection extends Mock implements DebugConnection {}
class MockVmService extends Mock implements VmService {}
class MockStatus extends Mock implements Status {}
......@@ -10,7 +10,6 @@ import 'package:flutter_tools/src/base/common.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/terminal.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/device.dart';
import 'package:flutter_tools/src/globals.dart';
......@@ -563,63 +562,3 @@ class MockDebugConnection extends Mock implements DebugConnection {}
class MockAppConnection extends Mock implements AppConnection {}
class MockVmService extends Mock implements VmService {}
class MockStatus extends Mock implements Status {}
class DelegateLogger implements Logger {
DelegateLogger(this.delegate);
final Logger delegate;
Status status;
@override
bool get quiet => delegate.quiet;
@override
set quiet(bool value) => delegate.quiet;
@override
bool get hasTerminal => delegate.hasTerminal;
@override
bool get isVerbose => delegate.isVerbose;
@override
void printError(String message, {StackTrace stackTrace, bool emphasis, TerminalColor color, int indent, int hangingIndent, bool wrap}) {
delegate.printError(
message,
stackTrace: stackTrace,
emphasis: emphasis,
color: color,
indent: indent,
hangingIndent: hangingIndent,
wrap: wrap,
);
}
@override
void printStatus(String message, {bool emphasis, TerminalColor color, bool newline, int indent, int hangingIndent, bool wrap}) {
delegate.printStatus(message,
emphasis: emphasis,
color: color,
indent: indent,
hangingIndent: hangingIndent,
wrap: wrap,
);
}
@override
void printTrace(String message) {
delegate.printTrace(message);
}
@override
void sendNotification(String message, {String progressId}) {
delegate.sendNotification(message, progressId: progressId);
}
@override
Status startProgress(String message, {Duration timeout, String progressId, bool multilineOutput = false, int progressIndicatorPadding = kDefaultStatusPadding}) {
return status;
}
@override
bool get supportsColor => delegate.supportsColor;
}
......@@ -734,3 +734,64 @@ class TestFeatureFlags implements FeatureFlags {
return false;
}
}
class DelegateLogger implements Logger {
DelegateLogger(this.delegate);
final Logger delegate;
Status status;
@override
bool get quiet => delegate.quiet;
@override
set quiet(bool value) => delegate.quiet;
@override
bool get hasTerminal => delegate.hasTerminal;
@override
bool get isVerbose => delegate.isVerbose;
@override
void printError(String message, {StackTrace stackTrace, bool emphasis, TerminalColor color, int indent, int hangingIndent, bool wrap}) {
delegate.printError(
message,
stackTrace: stackTrace,
emphasis: emphasis,
color: color,
indent: indent,
hangingIndent: hangingIndent,
wrap: wrap,
);
}
@override
void printStatus(String message, {bool emphasis, TerminalColor color, bool newline, int indent, int hangingIndent, bool wrap}) {
delegate.printStatus(message,
emphasis: emphasis,
color: color,
indent: indent,
hangingIndent: hangingIndent,
wrap: wrap,
);
}
@override
void printTrace(String message) {
delegate.printTrace(message);
}
@override
void sendNotification(String message, {String progressId}) {
delegate.sendNotification(message, progressId: progressId);
}
@override
Status startProgress(String message, {Duration timeout, String progressId, bool multilineOutput = false, int progressIndicatorPadding = kDefaultStatusPadding}) {
return status;
}
@override
bool get supportsColor => delegate.supportsColor;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment