Unverified Commit 36c5e321 authored by xster's avatar xster Committed by GitHub

Print 50000$ monopoly money (#27531)

parent 9abe4c6d
......@@ -294,7 +294,7 @@ class AndroidLicenseValidator extends DoctorValidator {
// The real stdin will never finish streaming. Pipe until the child process
// finishes.
process.stdin.addStream(stdin); // ignore: unawaited_futures
unawaited(process.stdin.addStream(stdin));
// Wait for stdout and stderr to be fully processed, because process.exitCode
// may complete first.
await waitGroup<void>(<Future<void>>[
......
......@@ -39,3 +39,14 @@ class ToolExit implements Exception {
@override
String toString() => 'Exception: $message';
}
/// Indicates to the linter that the given future is intentionally not `await`-ed.
///
/// Has the same functionality as `unawaited` from `package:pedantic`.
///
/// In an async context, it is normally expected than all Futures are awaited,
/// and that is the basis of the lint unawaited_futures which is turned on for
/// the flutter_tools package. However, there are times where one or more
/// futures are intentionally not awaited. This function may be used to ignore a
/// particular future. It silences the unawaited_futures lint.
void unawaited(Future<void> future) { }
......@@ -6,6 +6,7 @@ import 'dart:async';
import '../convert.dart';
import '../globals.dart';
import 'common.dart';
import 'file_system.dart';
import 'io.dart';
import 'process_manager.dart';
......@@ -193,7 +194,7 @@ Future<int> runInteractively(List<String> command, {
);
// The real stdin will never finish streaming. Pipe until the child process
// finishes.
process.stdin.addStream(stdin); // ignore: unawaited_futures
unawaited(process.stdin.addStream(stdin));
// Wait for stdout and stderr to be fully processed, because process.exitCode
// may complete first.
await Future.wait<dynamic>(<Future<dynamic>>[
......
......@@ -93,11 +93,11 @@ class AnalyzeOnce extends AnalyzeBase {
await server.start();
// Completing the future in the callback can't fail.
server.onExit.then<void>((int exitCode) { // ignore: unawaited_futures
unawaited(server.onExit.then<void>((int exitCode) {
if (!analysisCompleter.isCompleted) {
analysisCompleter.completeError('analysis server exited: $exitCode');
}
});
}));
Cache.releaseLockEarly();
......
......@@ -421,7 +421,8 @@ class AppDomain extends Domain {
connectionInfoCompleter = Completer<DebugConnectionInfo>();
// We don't want to wait for this future to complete and callbacks won't fail.
// As it just writes to stdout.
connectionInfoCompleter.future.then<void>((DebugConnectionInfo info) { // ignore: unawaited_futures
unawaited(connectionInfoCompleter.future.then<void>(
(DebugConnectionInfo info) {
final Map<String, dynamic> params = <String, dynamic>{
'port': info.httpUri.port,
'wsUri': info.wsUri.toString(),
......@@ -429,15 +430,15 @@ class AppDomain extends Domain {
if (info.baseUri != null)
params['baseUri'] = info.baseUri;
_sendAppEvent(app, 'debugPort', params);
});
},
));
}
final Completer<void> appStartedCompleter = Completer<void>();
// We don't want to wait for this future to complete, and callbacks won't fail,
// as it just writes to stdout.
appStartedCompleter.future // ignore: unawaited_futures
.then<void>((void value) {
unawaited(appStartedCompleter.future.then<void>((void value) {
_sendAppEvent(app, 'started');
});
}));
await app._runInZone<void>(this, () async {
try {
......
......@@ -398,9 +398,9 @@ class RunCommand extends RunCommandBase {
// Do not add more operations to the future.
final Completer<void> appStartedTimeRecorder = Completer<void>.sync();
// This callback can't throw.
appStartedTimeRecorder.future.then<void>( // ignore: unawaited_futures
unawaited(appStartedTimeRecorder.future.then<void>(
(_) { appStartedTime = systemClock.now(); }
);
));
final int result = await runner.run(
appStartedCompleter: appStartedTimeRecorder,
......
......@@ -5,6 +5,7 @@
import 'dart:async';
import 'dart:math' as math;
import '../base/common.dart';
import '../base/file_system.dart' hide IOSink;
import '../base/file_system.dart';
import '../base/io.dart';
......@@ -42,7 +43,7 @@ class AnalysisServer {
printTrace('dart ${command.skip(1).join(' ')}');
_process = await processManager.start(command);
// This callback hookup can't throw.
_process.exitCode.whenComplete(() => _process = null); // ignore: unawaited_futures
unawaited(_process.exitCode.whenComplete(() => _process = null));
final Stream<String> errorStream =
_process.stderr.transform<String>(utf8.decoder).transform<String>(const LineSplitter());
......
......@@ -7,6 +7,7 @@ import 'package:json_rpc_2/json_rpc_2.dart' as rpc;
import 'package:meta/meta.dart';
import 'asset.dart';
import 'base/common.dart';
import 'base/context.dart';
import 'base/file_system.dart';
import 'base/io.dart';
......@@ -336,7 +337,7 @@ class _DevFSHttpWriter {
if (retry < kMaxRetries) {
printTrace('Retrying writing "$deviceUri" to DevFS due to error: $e');
// Synchronization is handled by the _completer below.
_scheduleWrite(deviceUri, content, retry + 1); // ignore: unawaited_futures
unawaited(_scheduleWrite(deviceUri, content, retry + 1));
return;
} else {
printError('Error writing "$deviceUri" to DevFS: $e');
......
......@@ -403,11 +403,11 @@ class _FuchsiaPortForwarder extends DevicePortForwarder {
'-L', '$hostPort:$_ipv4Loopback:$devicePort', device.id, 'true'
];
final Process process = await processManager.start(command);
process.exitCode.then((int exitCode) { // ignore: unawaited_futures
unawaited(process.exitCode.then((int exitCode) {
if (exitCode != 0) {
throwToolExit('Failed to forward port:$devicePort');
}
});
}));
_processes[hostPort] = process;
_forwardedPorts.add(ForwardedPort(hostPort, devicePort));
return hostPort;
......
......@@ -158,7 +158,7 @@ Future<Map<String, String>> getCodeSigningIdentityDevelopmentTeam({
final String opensslOutput = await utf8.decodeStream(opensslProcess.stdout);
// Fire and forget discard of the stderr stream so we don't hold onto resources.
// Don't care about the result.
opensslProcess.stderr.drain<String>(); // ignore: unawaited_futures
unawaited(opensslProcess.stderr.drain<String>());
if (await opensslProcess.exitCode != 0)
return null;
......
......@@ -480,7 +480,7 @@ Future<XcodeBuildResult> buildXcodeProject({
}
// Trigger the start of the pipe -> stdout loop. Ignore exceptions.
listenToScriptOutputLine(); // ignore: unawaited_futures
unawaited(listenToScriptOutputLine());
buildCommands.add('SCRIPT_OUTPUT_STREAM_FILE=${scriptOutputPipeFile.absolute.path}');
}
......
......@@ -538,10 +538,10 @@ class _IOSSimulatorLogReader extends DeviceLogReader {
// We don't want to wait for the process or its callback. Best effort
// cleanup in the callback.
_deviceProcess.exitCode.whenComplete(() { // ignore: unawaited_futures
unawaited(_deviceProcess.exitCode.whenComplete(() {
if (_linesController.hasListener)
_linesController.close();
});
}));
}
// Match the log prefix (in order to shorten it):
......
......@@ -9,6 +9,7 @@ import 'package:meta/meta.dart';
import 'application_package.dart';
import 'artifacts.dart';
import 'asset.dart';
import 'base/common.dart';
import 'base/file_system.dart';
import 'base/io.dart';
import 'base/logger.dart';
......@@ -739,10 +740,10 @@ abstract class ResidentRunner {
// This hooks up callbacks for when the connection stops in the future.
// We don't want to wait for them. We don't handle errors in those callbacks'
// futures either because they just print to logger and is not critical.
service.done.then<void>( // ignore: unawaited_futures
unawaited(service.done.then<void>(
_serviceProtocolDone,
onError: _serviceProtocolError
).whenComplete(_serviceDisconnected);
).whenComplete(_serviceDisconnected));
}
}
}
......
......@@ -502,13 +502,17 @@ class HotRunner extends ResidentRunner {
// Reload the isolate.
final Completer<void> completer = Completer<void>();
futures.add(completer.future);
view.uiIsolate.reload().then((ServiceObject _) { // ignore: unawaited_futures
unawaited(view.uiIsolate.reload().then(
(ServiceObject _) {
final ServiceEvent pauseEvent = view.uiIsolate.pauseEvent;
if ((pauseEvent != null) && pauseEvent.isPauseEvent) {
// Resume the isolate so that it can be killed by the embedder.
return view.uiIsolate.resume();
}
}).whenComplete(() { completer.complete(null); });
},
).whenComplete(
() { completer.complete(null); },
));
}
}
}
......@@ -681,15 +685,19 @@ class HotRunner extends ResidentRunner {
final List<Future<Map<String, dynamic>>> reportFutures = device.reloadSources(
entryPath, pause: pause
);
Future.wait(reportFutures).then((List<Map<String, dynamic>> reports) async { // ignore: unawaited_futures
unawaited(Future.wait(reportFutures).then(
(List<Map<String, dynamic>> reports) async {
// TODO(aam): Investigate why we are validating only first reload report,
// which seems to be current behavior
final Map<String, dynamic> firstReport = reports.first;
// Don't print errors because they will be printed further down when
// `validateReloadReport` is called again.
await device.updateReloadStatus(validateReloadReport(firstReport, printErrors: false));
await device.updateReloadStatus(
validateReloadReport(firstReport, printErrors: false),
);
completer.complete(DeviceReloadReport(device, reports));
});
},
));
}
final List<DeviceReloadReport> reports = await Future.wait(allReportsFutures);
for (DeviceReloadReport report in reports) {
......@@ -749,9 +757,9 @@ class HotRunner extends ResidentRunner {
futuresViews.add(view.uiIsolate.reload());
}
final Completer<void> deviceCompleter = Completer<void>();
Future.wait(futuresViews).whenComplete(() { // ignore: unawaited_futures
unawaited(Future.wait(futuresViews).whenComplete(() {
deviceCompleter.complete(device.refreshViews());
});
}));
allDevices.add(deviceCompleter.future);
}
await Future.wait(allDevices);
......
......@@ -495,9 +495,9 @@ class _FlutterPlatform extends PlatformPlugin {
bool controllerSinkClosed = false;
try {
// Callback can't throw since it's just setting a variable.
controller.sink.done.whenComplete(() { // ignore: unawaited_futures
unawaited(controller.sink.done.whenComplete(() {
controllerSinkClosed = true;
});
}));
// Prepare our WebSocket server to talk to the engine subproces.
final HttpServer server = await HttpServer.bind(host, port);
......@@ -653,7 +653,7 @@ class _FlutterPlatform extends PlatformPlugin {
shellPath);
controller.sink.addError(message);
// Awaited for with 'sink.done' below.
controller.sink.close(); // ignore: unawaited_futures
unawaited(controller.sink.close());
printTrace('test $ourTestCount: waiting for controller sink to close');
await controller.sink.done;
await watcher?.handleTestCrashed(ProcessEvent(ourTestCount, process));
......@@ -666,7 +666,7 @@ class _FlutterPlatform extends PlatformPlugin {
final String message = _getErrorMessage('Test never connected to test harness.', testPath, shellPath);
controller.sink.addError(message);
// Awaited for with 'sink.done' below.
controller.sink.close(); // ignore: unawaited_futures
unawaited(controller.sink.close());
printTrace('test $ourTestCount: waiting for controller sink to close');
await controller.sink.done;
await watcher
......@@ -748,7 +748,7 @@ class _FlutterPlatform extends PlatformPlugin {
shellPath);
controller.sink.addError(message);
// Awaited for with 'sink.done' below.
controller.sink.close(); // ignore: unawaited_futures
unawaited(controller.sink.close());
printTrace('test $ourTestCount: waiting for controller sink to close');
await controller.sink.done;
break;
......@@ -792,7 +792,7 @@ class _FlutterPlatform extends PlatformPlugin {
}
if (!controllerSinkClosed) {
// Waiting below with await.
controller.sink.close(); // ignore: unawaited_futures
unawaited(controller.sink.close());
printTrace('test $ourTestCount: waiting for controller sink to close');
await controller.sink.done;
}
......
......@@ -152,7 +152,7 @@ class FlutterTesterDevice extends Device {
},
);
// Setting a bool can't fail in the callback.
_process.exitCode.then<void>((_) => _isRunning = false); // ignore: unawaited_futures
unawaited(_process.exitCode.then<void>((_) => _isRunning = false));
_process.stdout
.transform<String>(utf8.decoder)
.transform<String>(const LineSplitter())
......
......@@ -5,6 +5,7 @@
import 'dart:async';
import 'dart:convert';
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/context.dart';
......@@ -445,7 +446,8 @@ example:org-dartlang-app:///lib/
]));
// The test manages timing via completers.
generator.recompile( // ignore: unawaited_futures
unawaited(
generator.recompile(
'/path/to/main.dart',
null, /* invalidatedFiles */
outputPath: '/build/',
......@@ -457,11 +459,13 @@ example:org-dartlang-app:///lib/
compileExpressionResponseCompleter1.complete(Future<List<int>>.value(utf8.encode(
'result def\nline1\nline2\ndef /path/to/main.dart.dill.incremental 0\n'
)));
});
}),
);
// The test manages timing via completers.
final Completer<bool> lastExpressionCompleted = Completer<bool>();
generator.compileExpression('0+1', null, null, null, null, false).then( // ignore: unawaited_futures
unawaited(
generator.compileExpression('0+1', null, null, null, null, false).then(
(CompilerOutput outputExpression) {
expect(outputExpression, isNotNull);
expect(outputExpression.outputFilename,
......@@ -470,17 +474,22 @@ example:org-dartlang-app:///lib/
compileExpressionResponseCompleter2.complete(Future<List<int>>.value(utf8.encode(
'result def\nline1\nline2\ndef /path/to/main.dart.dill.incremental 0\n'
)));
});
},
),
);
// The test manages timing via completers.
generator.compileExpression('1+1', null, null, null, null, false).then( // ignore: unawaited_futures
unawaited(
generator.compileExpression('1+1', null, null, null, null, false).then(
(CompilerOutput outputExpression) {
expect(outputExpression, isNotNull);
expect(outputExpression.outputFilename,
equals('/path/to/main.dart.dill.incremental'));
expect(outputExpression.errorCount, 0);
lastExpressionCompleted.complete(true);
});
},
)
);
compileResponseCompleter.complete(Future<List<int>>.value(utf8.encode(
'result abc\nline1\nline2\nabc /path/to/main.dart.dill 0\n'
......
......@@ -5,6 +5,7 @@
import 'dart:async';
import 'package:file/file.dart';
import 'package:flutter_tools/src/base/common.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:vm_service_lib/vm_service_lib.dart';
......@@ -76,10 +77,10 @@ void main() {
},
);
await _flutter.resume(); // we start paused so we can set up our TICK 1 listener before the app starts
sawTick1.future.timeout( // ignore: unawaited_futures
unawaited(sawTick1.future.timeout(
const Duration(seconds: 5),
onTimeout: () { print('The test app is taking longer than expected to print its synchronization line...'); },
);
));
await sawTick1.future; // after this, app is in steady state
await _flutter.addBreakpoint(
_project.scheduledBreakpointUri,
......
......@@ -6,6 +6,7 @@ import 'dart:async';
import 'dart:convert';
import 'package:file/file.dart';
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:meta/meta.dart';
......@@ -104,10 +105,10 @@ abstract class FlutterTestDriver {
// This class doesn't use the result of the future. It's made available
// via a getter for external uses.
_process.exitCode.then((int code) { // ignore: unawaited_futures
unawaited(_process.exitCode.then((int code) {
_debugPrint('Process exited ($code)');
_hasExited = true;
});
}));
transformToLines(_process.stdout).listen((String line) => _stdout.add(line));
transformToLines(_process.stderr).listen((String line) => _stderr.add(line));
......
......@@ -4,9 +4,10 @@
import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'package:flutter_tools/src/base/common.dart';
Process daemon;
// To use, start from the console and enter:
......@@ -82,10 +83,10 @@ Future<void> main() async {
});
// Print in the callback can't fail.
daemon.exitCode.then<void>((int code) { // ignore: unawaited_futures
unawaited(daemon.exitCode.then<void>((int code) {
print('daemon exiting ($code)');
exit(code);
});
}));
}
int id = 0;
......
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