Revert "Enable avoid_print lint. (#91332)" (#91438)

This reverts commit cb378edc9e.
This commit is contained in:
Mouad Debbar
2021-10-07 16:16:17 -04:00
committed by GitHub
parent d68f95676c
commit c2ea78d231
85 changed files with 246 additions and 359 deletions

View File

@@ -1,11 +1,12 @@
include: ../analysis_options.yaml
# Use the analysis options settings from the top level of the repo (not
# the ones from above, which include the `public_member_api_docs` rule).
include: ../../analysis_options.yaml
linter:
rules:
avoid_catches_without_on_clauses: true
curly_braces_in_flow_control_structures: true
library_private_types_in_public_api: false # Tool does not have any public API.
no_runtimeType_toString: false # We use runtimeType for debugging in the tool.
library_private_types_in_public_api: false # Tool does not have any public API
prefer_relative_imports: true
public_member_api_docs: false # Tool does not have any public API.
unawaited_futures: true

View File

@@ -1,5 +0,0 @@
include: ../analysis_options.yaml
linter:
rules:
avoid_print: false # These are CLI tools which print as a matter of course.

View File

@@ -25,12 +25,6 @@
/// about any additional exports that you add to this file, as doing so will
/// increase the API surface that we have to test in Flutter tools, and the APIs
/// in `dart:io` can sometimes be hard to use in tests.
// We allow `print()` in this file as a fallback for writing to the terminal via
// regular stdout/stderr/stdio paths. Everything else in the flutter_tools
// library should route terminal I/O through the [Stdio] class defined below.
// ignore_for_file: avoid_print
import 'dart:async';
import 'dart:io' as io
show

View File

@@ -247,7 +247,6 @@ class Cache {
}
} on Exception catch (error) {
// There is currently no logger attached since this is computed at startup.
// ignore: avoid_print
print(userMessages.runnerNoRoot('$error'));
}
return normalize('.');

View File

@@ -307,7 +307,6 @@ class DaemonDomain extends Domain {
if (message.level == 'status') {
// We use `print()` here instead of `stdout.writeln()` in order to
// capture the print output for testing.
// ignore: avoid_print
print(message.message);
} else if (message.level == 'error') {
globals.stdio.stderrWrite('${message.message}\n');

View File

@@ -96,7 +96,7 @@ class MacOSDevice extends DesktopDevice {
'open', package.applicationBundle(buildMode),
]).then((ProcessResult result) {
if (result.exitCode != 0) {
_logger.printError('Failed to foreground app; open returned ${result.exitCode}');
print('Failed to foreground app; open returned ${result.exitCode}');
}
});
}

View File

@@ -2723,9 +2723,10 @@ Future<void> _ensureFlutterToolsSnapshot() async {
'../../bin/cache/dart-sdk/bin/dart',
snapshotArgs,
);
printOnFailure('Results of generating snapshot:');
printOnFailure(snapshotResult.stdout.toString());
printOnFailure(snapshotResult.stderr.toString());
if (snapshotResult.exitCode != 0) {
print(snapshotResult.stdout);
print(snapshotResult.stderr);
}
expect(snapshotResult.exitCode, 0);
}
@@ -2767,9 +2768,10 @@ Future<void> _analyzeProject(String workingDir, { List<String> expectedFailures
workingDirectory: workingDir,
);
if (expectedFailures.isEmpty) {
printOnFailure('Results of running analyzer:');
printOnFailure(exec.stdout.toString());
printOnFailure(exec.stderr.toString());
if (exec.exitCode != 0) {
print(exec.stdout);
print(exec.stderr);
}
expect(exec.exitCode, 0);
return;
}
@@ -2823,9 +2825,10 @@ Future<void> _runFlutterTest(Directory workingDir, { String target }) async {
args,
workingDirectory: workingDir.path,
);
printOnFailure('Output of running flutter test:');
printOnFailure(exec.stdout.toString());
printOnFailure(exec.stderr.toString());
if (exec.exitCode != 0) {
print(exec.stdout);
print(exec.stderr);
}
expect(exec.exitCode, 0);
}

View File

@@ -179,6 +179,7 @@ void main() {
expect(logContents, contains('String: an exception % --'));
expect(logContents, contains('CrashingFlutterCommand.runCommand'));
expect(logContents, contains('[✓] Flutter'));
print(globals.crashReporter.runtimeType);
final CrashDetails sentDetails = (globals.crashReporter as WaitingCrashReporter)._details;
expect(sentDetails.command, 'flutter crash');

View File

@@ -28,9 +28,8 @@ void main() {
'--no-color',
...arguments,
], workingDirectory: projectPath);
printOnFailure('Output of flutter ${arguments.join(" ")}');
printOnFailure(result.stdout.toString());
printOnFailure(result.stderr.toString());
print(result.stdout);
print(result.stderr);
expect(result.exitCode, exitCode, reason: 'Expected to exit with non-zero exit code.');
assertContains(result.stdout.toString(), statusTextContains);
assertContains(result.stdout.toString(), errorTextContains);

View File

@@ -31,9 +31,8 @@ void main() {
'--target-platform=android-arm64'
], workingDirectory: workingDirectory);
printOnFailure('Output of flutter build apk:');
printOnFailure(result.stdout.toString());
printOnFailure(result.stderr.toString());
print(result.stdout);
print(result.stderr);
expect(result.stdout.toString(), contains('app-release.apk (total compressed)'));
final String line = result.stdout.toString()
@@ -68,9 +67,8 @@ void main() {
'--no-codesign',
], workingDirectory: workingDirectory);
printOnFailure('Output of flutter build ios:');
printOnFailure(result.stdout.toString());
printOnFailure(result.stderr.toString());
print(result.stdout);
print(result.stderr);
expect(result.stdout.toString(), contains('Dart AOT symbols accounted decompressed size'));
final String line = result.stdout.toString()
@@ -104,9 +102,8 @@ void main() {
'--enable-macos-desktop',
], workingDirectory: workingDirectory);
printOnFailure('Output of flutter config:');
printOnFailure(configResult.stdout.toString());
printOnFailure(configResult.stderr.toString());
print(configResult.stdout);
print(configResult.stderr);
final ProcessResult result = await processManager.run(<String>[
flutterBin,
@@ -116,9 +113,8 @@ void main() {
'--code-size-directory=${codeSizeDir.path}',
], workingDirectory: workingDirectory);
printOnFailure('Output of flutter build macos:');
printOnFailure(result.stdout.toString());
printOnFailure(result.stderr.toString());
print(result.stdout);
print(result.stderr);
expect(result.stdout.toString(), contains('Dart AOT symbols accounted decompressed size'));
final String line = result.stdout.toString()
@@ -151,9 +147,8 @@ void main() {
'--debug',
], workingDirectory: fileSystem.path.join(getFlutterRoot(), 'examples', 'hello_world'));
printOnFailure('Output of flutter build apk:');
printOnFailure(result.stdout.toString());
printOnFailure(result.stderr.toString());
print(result.stdout);
print(result.stderr);
expect(result.stderr.toString(), contains('"--analyze-size" can only be used on release builds'));
expect(result.exitCode, 1);

View File

@@ -34,7 +34,7 @@ void main() {
final Completer<void> sawBackgroundMessage = Completer<void>.sync();
final Completer<void> sawNewBackgroundMessage = Completer<void>.sync();
final StreamSubscription<String> subscription = flutter.stdout.listen((String line) {
printOnFailure('[LOG]:"$line"');
print('[LOG]:"$line"');
if (line.contains('Main thread') && !sawForegroundMessage.isCompleted) {
sawForegroundMessage.complete();
}
@@ -68,7 +68,7 @@ void main() {
final Completer<void> sawBackgroundMessage = Completer<void>.sync();
final Completer<void> sawNewBackgroundMessage = Completer<void>.sync();
final StreamSubscription<String> subscription = flutter.stdout.listen((String line) {
printOnFailure('[LOG]:"$line"');
print('[LOG]:"$line"');
if (line.contains('Isolate thread') && !sawBackgroundMessage.isCompleted) {
sawBackgroundMessage.complete();
}

View File

@@ -33,9 +33,8 @@ void main() {
'--no-codesign',
], workingDirectory: workingDirectory);
printOnFailure('Output of flutter build ios:');
printOnFailure(result.stdout.toString());
printOnFailure(result.stderr.toString());
print(result.stdout);
print(result.stderr);
expect(result.exitCode, 0);

View File

@@ -64,7 +64,11 @@ Future<void> main(List<String> args) async {
await cache.lock();
process.kill(io.ProcessSignal.sigkill);
} finally {
tryToDelete(tempDir);
try {
tempDir.deleteSync(recursive: true);
} on FileSystemException {
// Ignore filesystem exceptions when trying to delete tempdir.
}
Cache.flutterRoot = oldRoot;
}
expect(logger.statusText, isEmpty);

View File

@@ -26,10 +26,8 @@ void main() {
'--target-platform', 'android-arm',
'--verbose',
], workingDirectory: woringDirectory);
printOnFailure('Output of flutter build apk:');
printOnFailure(result.stdout.toString());
printOnFailure(result.stderr.toString());
print(result.stdout);
print(result.stderr);
expect(result.exitCode, 0);

View File

@@ -38,7 +38,11 @@ void main() {
});
tearDown(() {
tryToDelete(parentDirectory);
try {
parentDirectory.deleteSync(recursive: true);
} on FileSystemException {
print('Failed to delete test directory');
}
});
testWithoutContext('Can upgrade and downgrade a Flutter checkout', () async {
@@ -52,7 +56,7 @@ void main() {
'git', 'config', '--system', 'core.longpaths', 'true',
]);
printOnFailure('Step 1 - clone the $_kBranch of flutter into the test directory');
print('Step 1 - clone the $_kBranch of flutter into the test directory');
exitCode = await processUtils.stream(<String>[
'git',
'clone',
@@ -60,7 +64,7 @@ void main() {
], workingDirectory: parentDirectory.path, trace: true);
expect(exitCode, 0);
printOnFailure('Step 2 - switch to the $_kBranch');
print('Step 2 - switch to the $_kBranch');
exitCode = await processUtils.stream(<String>[
'git',
'checkout',
@@ -71,7 +75,7 @@ void main() {
], workingDirectory: testDirectory.path, trace: true);
expect(exitCode, 0);
printOnFailure('Step 3 - revert back to $_kInitialVersion');
print('Step 3 - revert back to $_kInitialVersion');
exitCode = await processUtils.stream(<String>[
'git',
'reset',
@@ -80,7 +84,7 @@ void main() {
], workingDirectory: testDirectory.path, trace: true);
expect(exitCode, 0);
printOnFailure('Step 4 - upgrade to the newest $_kBranch');
print('Step 4 - upgrade to the newest $_kBranch');
// This should update the persistent tool state with the sha for HEAD
exitCode = await processUtils.stream(<String>[
flutterBin,
@@ -90,7 +94,7 @@ void main() {
], workingDirectory: testDirectory.path, trace: true);
expect(exitCode, 0);
printOnFailure('Step 5 - verify that the version is different');
print('Step 5 - verify that the version is different');
final RunResult versionResult = await processUtils.run(<String>[
'git',
'describe',
@@ -100,9 +104,10 @@ void main() {
'--tags',
], workingDirectory: testDirectory.path);
expect(versionResult.stdout, isNot(contains(_kInitialVersion)));
printOnFailure('current version is ${versionResult.stdout.trim()}\ninitial was $_kInitialVersion');
print('current version is ${versionResult.stdout.trim()}\ninitial was $_kInitialVersion');
printOnFailure('Step 6 - downgrade back to the initial version');
print('Step 6 - downgrade back to the initial version');
// Step 6. Downgrade back to initial version.
exitCode = await processUtils.stream(<String>[
flutterBin,
'downgrade',
@@ -111,7 +116,8 @@ void main() {
], workingDirectory: testDirectory.path, trace: true);
expect(exitCode, 0);
printOnFailure('Step 7 - verify downgraded version matches original version');
print('Step 7 - verify downgraded version matches original version');
// Step 7. Verify downgraded version matches original version.
final RunResult oldVersionResult = await processUtils.run(<String>[
'git',
'describe',
@@ -121,6 +127,6 @@ void main() {
'--tags',
], workingDirectory: testDirectory.path);
expect(oldVersionResult.stdout, contains(_kInitialVersion));
printOnFailure('current version is ${oldVersionResult.stdout.trim()}\ninitial was $_kInitialVersion');
print('current version is ${oldVersionResult.stdout.trim()}\ninitial was $_kInitialVersion');
});
}

View File

@@ -36,9 +36,8 @@ void main() {
fileSystem.path.join(tempDir.path, 'main.dart'),
]);
printOnFailure('Output of dart main.dart:');
printOnFailure(result.stdout.toString());
printOnFailure(result.stderr.toString());
print(result.stdout);
print(result.stderr);
expect(result.exitCode, 0);
});
@@ -56,9 +55,8 @@ void main() {
fileSystem.path.join(tempDir.path, 'main.dart'),
]);
printOnFailure('Output of dart main.dart:');
printOnFailure(result.stdout.toString());
printOnFailure(result.stderr.toString());
print(result.stdout);
print(result.stderr);
expect(result.exitCode, 1);
});
}

View File

@@ -67,6 +67,7 @@ String unsafeString = null;
for (final String targetPlatform in targetPlatforms) {
testWithoutContext('flutter build $targetPlatform --no-sound-null-safety', () {
print(tempDir);
final ProcessResult result = processManager.runSync(<String>[
flutterBin,
...getLocalEngineArguments(),

View File

@@ -138,9 +138,10 @@ Future<void> _ensureFlutterToolsSnapshot() async {
'../../bin/cache/dart-sdk/bin/dart',
snapshotArgs,
);
printOnFailure('Output of dart ${snapshotArgs.join(" ")}:');
printOnFailure(snapshotResult.stdout.toString());
printOnFailure(snapshotResult.stderr.toString());
if (snapshotResult.exitCode != 0) {
print(snapshotResult.stdout);
print(snapshotResult.stderr);
}
expect(snapshotResult.exitCode, 0);
}
@@ -236,8 +237,9 @@ Future<void> _analyzeProject(Directory workingDir) async {
args,
workingDirectory: workingDir.path,
);
printOnFailure('Output of flutter analyze:');
printOnFailure(exec.stdout.toString());
printOnFailure(exec.stderr.toString());
if (exec.exitCode != 0) {
print(exec.stdout);
print(exec.stderr);
}
expect(exec.exitCode, 0);
}

View File

@@ -108,14 +108,8 @@ void main() {
await flutter.resume(); // we start paused so we can set up our TICK 1 listener before the app starts
unawaited(sawTick1.future.timeout(
const Duration(seconds: 5),
onTimeout: () {
// This print is useful for people debugging this test. Normally we would avoid printing in
// a test but this is an exception because it's useful ambient information.
// ignore: avoid_print
print('The test app is taking longer than expected to print its synchronization line...');
},
onTimeout: () { print('The test app is taking longer than expected to print its synchronization line...'); },
));
printOnFailure('waiting for synchronization line...');
await sawTick1.future; // after this, app is in steady state
await flutter.addBreakpoint(
project.scheduledBreakpointUri,
@@ -132,19 +126,19 @@ void main() {
);
bool reloaded = false;
final Future<void> reloadFuture = flutter.hotReload().then((void value) { reloaded = true; });
printOnFailure('waiting for pause...');
print('waiting for pause...');
isolate = await flutter.waitForPause();
expect(isolate.pauseEvent.kind, equals(EventKind.kPauseBreakpoint));
printOnFailure('waiting for debugger message...');
print('waiting for debugger message...');
await sawDebuggerPausedMessage.future;
expect(reloaded, isFalse);
printOnFailure('waiting for resume...');
print('waiting for resume...');
await flutter.resume();
printOnFailure('waiting for reload future...');
print('waiting for reload future...');
await reloadFuture;
expect(reloaded, isTrue);
reloaded = false;
printOnFailure('subscription cancel...');
print('subscription cancel...');
await subscription.cancel();
});
@@ -154,7 +148,7 @@ void main() {
final Completer<void> sawDebuggerPausedMessage2 = Completer<void>();
final StreamSubscription<String> subscription = flutter.stdout.listen(
(String line) {
printOnFailure('[LOG]:"$line"');
print('[LOG]:"$line"');
if (line.contains('(((TICK 1)))')) {
expect(sawTick1.isCompleted, isFalse);
sawTick1.complete();

View File

@@ -47,7 +47,7 @@ void main() {
onSecondLoad.complete();
}
});
flutter.stdout.listen(printOnFailure);
flutter.stdout.listen(print);
await flutter.run();
await onFirstLoad.future;
@@ -74,7 +74,7 @@ void main() {
onSecondLoad.complete();
}
});
flutter.stdout.listen(printOnFailure);
flutter.stdout.listen(print);
await flutter.run();
await onFirstLoad.future;

View File

@@ -29,7 +29,7 @@ void main() {
'flutter',
);
processManager.runSync(<String>[
final ProcessResult createResult = processManager.runSync(<String>[
flutterBin,
...getLocalEngineArguments(),
'create',
@@ -39,6 +39,7 @@ void main() {
'objc',
'hello',
], workingDirectory: tempDir.path);
print(createResult.stdout);
projectRoot = tempDir.childDirectory('hello').path;
});
@@ -58,7 +59,7 @@ void main() {
File outputAppFrameworkBinary;
setUpAll(() {
processManager.runSync(<String>[
final ProcessResult buildResult = processManager.runSync(<String>[
flutterBin,
...getLocalEngineArguments(),
'build',
@@ -69,6 +70,7 @@ void main() {
'--obfuscate',
'--split-debug-info=foo debug info/',
], workingDirectory: projectRoot);
print(buildResult.stdout);
buildPath = fileSystem.directory(fileSystem.path.join(
projectRoot,
@@ -123,6 +125,7 @@ void main() {
infoPlistPath,
],
);
print(bonjourServices.stdout);
final bool bonjourServicesFound = (bonjourServices.stdout as String).contains('_dartobservatory._tcp');
expect(bonjourServicesFound, buildMode == BuildMode.debug);
@@ -137,6 +140,7 @@ void main() {
infoPlistPath,
],
);
print(localNetworkUsage.stdout);
final bool localNetworkUsageFound = localNetworkUsage.exitCode == 0;
expect(localNetworkUsageFound, buildMode == BuildMode.debug);
});
@@ -151,6 +155,7 @@ void main() {
'arm64',
],
);
print(symbols.stdout);
final bool aotSymbolsFound = (symbols.stdout as String).contains('_kDartVmSnapshot');
expect(aotSymbolsFound, buildMode != BuildMode.debug);
});
@@ -192,9 +197,7 @@ void main() {
// Skip bitcode stripping since we just checked that above.
},
);
printOnFailure('Output of xcode_backend.sh:');
printOnFailure(xcodeBackendResult.stdout.toString());
printOnFailure(xcodeBackendResult.stderr.toString());
print(xcodeBackendResult.stdout);
expect(xcodeBackendResult.exitCode, 0);
expect(outputFlutterFrameworkBinary.existsSync(), isTrue);
@@ -208,6 +211,7 @@ void main() {
'hello',
outputAppFrameworkBinary.path,
]);
print(grepResult.stdout);
expect(grepResult.stdout, isNot(contains('matches')));
});
});
@@ -229,6 +233,7 @@ void main() {
'FLUTTER_XCODE_ONLY_ACTIVE_ARCH': 'NO',
},
);
print(buildSimulator.stdout);
// This test case would fail if arm64 or x86_64 simulators could not build.
expect(buildSimulator.exitCode, 0);
@@ -246,6 +251,7 @@ void main() {
final ProcessResult archs = processManager.runSync(
<String>['file', simulatorAppFrameworkBinary.path],
);
print(archs.stdout);
expect(archs.stdout, contains('Mach-O 64-bit dynamically linked shared library x86_64'));
expect(archs.stdout, contains('Mach-O 64-bit dynamically linked shared library arm64'));
});

View File

@@ -53,9 +53,8 @@ void main() {
];
final ProcessResult result = processManager.runSync(buildCommand, workingDirectory: workingDirectory);
printOnFailure('Output of flutter build macos:');
printOnFailure(result.stdout.toString());
printOnFailure(result.stderr.toString());
print(result.stdout);
print(result.stderr);
expect(result.exitCode, 0);
expect(result.stdout, contains('Running pod install'));
@@ -135,9 +134,8 @@ void main() {
// Build again without cleaning.
final ProcessResult secondBuild = processManager.runSync(buildCommand, workingDirectory: workingDirectory);
printOnFailure('Output of second build:');
printOnFailure(secondBuild.stdout.toString());
printOnFailure(secondBuild.stderr.toString());
print(secondBuild.stdout);
print(secondBuild.stderr);
expect(secondBuild.exitCode, 0);
expect(secondBuild.stdout, isNot(contains('Running pod install')));

View File

@@ -27,7 +27,7 @@ Future<void> waitForObservatoryMessage(Process process, int port) async {
process.stdout
.transform(utf8.decoder)
.listen((String line) {
printOnFailure(line);
print(line);
if (line.contains('An Observatory debugger and profiler on Flutter test device is available at')) {
if (line.contains('http://127.0.0.1:$port')) {
completer.complete();
@@ -38,7 +38,7 @@ Future<void> waitForObservatoryMessage(Process process, int port) async {
});
process.stderr
.transform(utf8.decoder)
.listen(printOnFailure);
.listen(print);
return completer.future;
}

View File

@@ -43,13 +43,6 @@ const ProcessManager processManager = LocalProcessManager();
final String flutterRoot = getFlutterRoot();
final String flutterBin = fileSystem.path.join(flutterRoot, 'bin', 'flutter');
void debugPrint(String message) {
// This is called to intentionally print debugging output when a test is
// either taking too long or has failed.
// ignore: avoid_print
print(message);
}
typedef LineHandler = String/*?*/ Function(String line);
abstract class Transition {
@@ -143,7 +136,7 @@ class LogLine {
String toString() => '$stamp $channel: $message';
void printClearly() {
debugPrint('$stamp $channel: ${clarify(message)}');
print('$stamp $channel: ${clarify(message)}');
}
static String clarify(String line) {
@@ -204,9 +197,9 @@ Future<ProcessTestResult> runFlutter(
int nextTransition = 0;
void describeStatus() {
if (transitions.isNotEmpty) {
debugPrint('Expected state transitions:');
print('Expected state transitions:');
for (int index = 0; index < transitions.length; index += 1) {
debugPrint(
print(
'${index.toString().padLeft(5)} '
'${index < nextTransition ? 'ALREADY MATCHED ' :
index == nextTransition ? 'NOW WAITING FOR>' :
@@ -214,9 +207,9 @@ Future<ProcessTestResult> runFlutter(
}
}
if (logs.isEmpty) {
debugPrint('So far nothing has been logged${ debug ? "" : "; use debug:true to print all output" }.');
print('So far nothing has been logged${ debug ? "" : "; use debug:true to print all output" }.');
} else {
debugPrint('Log${ debug ? "" : " (only contains logged lines; use debug:true to print all output)" }:');
print('Log${ debug ? "" : " (only contains logged lines; use debug:true to print all output)" }:');
for (final LogLine log in logs) {
log.printClearly();
}
@@ -228,12 +221,12 @@ Future<ProcessTestResult> runFlutter(
if (!streamingLogs) {
streamingLogs = true;
if (!debug) {
debugPrint('Test is taking a long time (${clock.elapsed.inSeconds} seconds so far).');
print('Test is taking a long time (${clock.elapsed.inSeconds} seconds so far).');
}
describeStatus();
debugPrint('(streaming all logs from this point on...)');
print('(streaming all logs from this point on...)');
} else {
debugPrint('(taking a long time...)');
print('(taking a long time...)');
}
}
String stamp() => '[${(clock.elapsed.inMilliseconds / 1000.0).toStringAsFixed(1).padLeft(5, " ")}s]';
@@ -247,7 +240,7 @@ Future<ProcessTestResult> runFlutter(
}
if (nextTransition < transitions.length && transitions[nextTransition].matches(line)) {
if (streamingLogs) {
debugPrint('(matched ${transitions[nextTransition]})');
print('(matched ${transitions[nextTransition]})');
}
if (transitions[nextTransition].logging != null) {
if (!logging && transitions[nextTransition].logging/*!*/) {
@@ -256,9 +249,9 @@ Future<ProcessTestResult> runFlutter(
logging = transitions[nextTransition].logging/*!*/;
if (streamingLogs) {
if (logging) {
debugPrint('(enabled logging)');
print('(enabled logging)');
} else {
debugPrint('(disabled logging)');
print('(disabled logging)');
}
}
}
@@ -293,8 +286,8 @@ Future<ProcessTestResult> runFlutter(
process.stdout.transform<String>(utf8.decoder).transform<String>(const LineSplitter()).listen(processStdout);
process.stderr.transform<String>(utf8.decoder).transform<String>(const LineSplitter()).listen(processStderr);
unawaited(process.exitCode.timeout(expectedMaxDuration, onTimeout: () { // This is a failure timeout, must not be short.
debugPrint('${stamp()} (process is not quitting, trying to send a "q" just in case that helps)');
debugPrint('(a functional test should never reach this point)');
print('${stamp()} (process is not quitting, trying to send a "q" just in case that helps)');
print('(a functional test should never reach this point)');
final LogLine inLog = LogLine('stdin', stamp(), 'q');
logs.add(inLog);
if (streamingLogs) {
@@ -305,24 +298,24 @@ Future<ProcessTestResult> runFlutter(
}).catchError((Object error) { /* ignore errors here, they will be reported on the next line */ }));
final int exitCode = await process.exitCode;
if (streamingLogs) {
debugPrint('${stamp()} (process terminated with exit code $exitCode)');
print('${stamp()} (process terminated with exit code $exitCode)');
}
timeout?.cancel();
if (nextTransition < transitions.length) {
debugPrint('The subprocess terminated before all the expected transitions had been matched.');
print('The subprocess terminated before all the expected transitions had been matched.');
if (logs.any((LogLine line) => line.couldBeCrash)) {
debugPrint('The subprocess may in fact have crashed. Check the stderr logs below.');
print('The subprocess may in fact have crashed. Check the stderr logs below.');
}
debugPrint('The transition that we were hoping to see next but that we never saw was:');
debugPrint('${nextTransition.toString().padLeft(5)} NOW WAITING FOR> ${transitions[nextTransition]}');
print('The transition that we were hoping to see next but that we never saw was:');
print('${nextTransition.toString().padLeft(5)} NOW WAITING FOR> ${transitions[nextTransition]}');
if (!streamingLogs) {
describeStatus();
debugPrint('(process terminated with exit code $exitCode)');
print('(process terminated with exit code $exitCode)');
}
throw TestFailure('Missed some expected transitions.');
}
if (streamingLogs) {
debugPrint('${stamp()} (completed execution successfully!)');
print('${stamp()} (completed execution successfully!)');
}
return ProcessTestResult(exitCode, logs);
}

View File

@@ -79,10 +79,6 @@ abstract class FlutterTestDriver {
lastTime = time;
}
if (_printDebugOutputToStdOut) {
// This is the one place in this file that can call print. It is gated by
// _printDebugOutputToStdOut which should not be set to true in CI; it is
// intended only for use in local debugging.
// ignore: avoid_print
print('$time$_logPrefix$line');
}
}

View File

@@ -215,10 +215,6 @@ void main() {
}
expect(result.exitCode, 0);
});
testWithoutContext('flutter gold skips tests where the expectations are missing', () async {
return _testFile('flutter_gold', automatedTestsDirectory, flutterTestDirectory, exitCode: isZero);
});
}
Future<void> _testFile(

View File

@@ -40,8 +40,6 @@ void main() {
// Regression test for https://github.com/flutter/flutter/issues/79498
testWithoutContext('Can connect to the timeline without getting ANR from the application', () async {
final Timer timer = Timer(const Duration(minutes: 5), () {
// This message is intended to show up in CI logs.
// ignore: avoid_print
print(
'Warning: test isolate is still active after 5 minutes. This is likely an '
'app-not-responding error and not a flake. See https://github.com/flutter/flutter/issues/79498 '

View File

@@ -4,6 +4,5 @@
// Not a test file, invoked by `variable_expansion_windows_test.dart`.
void main(List<String> args) {
// This print is used for communicating with the test host.
print('args: $args'); // ignore: avoid_print
print('args: $args');
}

View File

@@ -27,9 +27,6 @@ void tryToDelete(Directory directory) {
directory.deleteSync(recursive: true);
}
} on FileSystemException catch (error) {
// We print this so that it's visible in the logs, to get an idea of how
// common this problem is, and if any patterns are ever noticed by anyone.
// ignore: avoid_print
print('Failed to delete ${directory.path}: $error');
}
}

View File

@@ -127,7 +127,7 @@ void testUsingContext(
},
body: () {
final String flutterRoot = getFlutterRoot();
return runZonedGuarded<Future<dynamic>>(() {
return runZoned<Future<dynamic>>(() {
try {
return context.run<dynamic>(
// Apply the overrides to the test context in the zone since their
@@ -148,10 +148,9 @@ void testUsingContext(
_printBufferedErrors(context);
rethrow;
}
}, (Object error, StackTrace stackTrace) {
// When things fail, it's ok to print to the console!
print(error); // ignore: avoid_print
print(stackTrace); // ignore: avoid_print
}, onError: (Object error, StackTrace stackTrace) { // ignore: deprecated_member_use
print(error);
print(stackTrace);
_printBufferedErrors(context);
throw error;
});
@@ -177,9 +176,7 @@ void _printBufferedErrors(AppContext testContext) {
if (testContext.get<Logger>() is BufferLogger) {
final BufferLogger bufferLogger = testContext.get<Logger>() as BufferLogger;
if (bufferLogger.errorText.isNotEmpty) {
// This is where the logger outputting errors is implemented, so it has
// to use `print`.
print(bufferLogger.errorText); // ignore: avoid_print
print(bufferLogger.errorText);
}
bufferLogger.clear();
}

View File

@@ -38,6 +38,7 @@ void main() {
testWithoutContext('newly added code executes during hot restart', () async {
final Completer<void> completer = Completer<void>();
final StreamSubscription<String> subscription = flutter.stdout.listen((String line) {
print(line);
if (line.contains('(((((RELOAD WORKED)))))')) {
completer.complete();
}
@@ -55,6 +56,7 @@ void main() {
testWithoutContext('newly added code executes during hot restart - canvaskit', () async {
final Completer<void> completer = Completer<void>();
final StreamSubscription<String> subscription = flutter.stdout.listen((String line) {
print(line);
if (line.contains('(((((RELOAD WORKED)))))')) {
completer.complete();
}

View File

@@ -1,5 +0,0 @@
include: ../analysis_options.yaml
linter:
rules:
avoid_print: false # These are CLI tools which print as a matter of course.