Commit 016b5ab0 authored by Todd Volkert's avatar Todd Volkert Committed by GitHub

Force all dart:io usage to go through 'base/io.dart' (#7390)

This ensures that accidental usages of dart:io's
file API don't creep in over time.
parent 8bb27034
...@@ -6,7 +6,7 @@ trap detect_error_on_exit EXIT HUP INT QUIT TERM ...@@ -6,7 +6,7 @@ trap detect_error_on_exit EXIT HUP INT QUIT TERM
detect_error_on_exit() { detect_error_on_exit() {
exit_code=$? exit_code=$?
set +x { set +x; } 2>/dev/null
if [[ $exit_code -ne 0 ]]; then if [[ $exit_code -ne 0 ]]; then
echo -e "\x1B[31m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\x1B[0m" echo -e "\x1B[31m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\x1B[0m"
echo -e "\x1B[1mError:\x1B[31m script exited early due to error ($exit_code)\x1B[0m" echo -e "\x1B[1mError:\x1B[31m script exited early due to error ($exit_code)\x1B[0m"
...@@ -14,6 +14,27 @@ detect_error_on_exit() { ...@@ -14,6 +14,27 @@ detect_error_on_exit() {
fi fi
} }
check_for_dart_io() {
{ set +x; } 2>/dev/null
(
cd packages/flutter_tools
for f in $(grep -Erl '^import.*dart:io' lib bin test); do
if [[ "$f" == "lib/src/base/io.dart" ]]; then
continue
fi
IFS=$'\n' matches=( $(grep -E '^import.*dart:io' $f) )
for match in "${matches[@]}"; do
if [[ "$match" != *"ignore: dart_io_import"* ]]; then
echo -e "\x1B[31mError: $f imports 'dart:io'; import 'lib/src/base/io.dart' instead\x1B[0m"
exit 1
fi
done
done
)
set -ex
}
set -ex set -ex
# analyze all the Dart code in the repo # analyze all the Dart code in the repo
...@@ -40,6 +61,7 @@ SRC_ROOT=$PWD ...@@ -40,6 +61,7 @@ SRC_ROOT=$PWD
(cd packages/flutter_driver; dart -c test/all.dart) (cd packages/flutter_driver; dart -c test/all.dart)
(cd packages/flutter_test; flutter test) (cd packages/flutter_test; flutter test)
(cd packages/flutter_tools; FLUTTER_ROOT=$SRC_ROOT dart -c test/all.dart) (cd packages/flutter_tools; FLUTTER_ROOT=$SRC_ROOT dart -c test/all.dart)
check_for_dart_io
(cd dev/devicelab; dart -c test/all.dart) (cd dev/devicelab; dart -c test/all.dart)
(cd dev/manual_tests; flutter test) (cd dev/manual_tests; flutter test)
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:async'; import 'dart:async';
import 'dart:io' as io;
import 'package:args/args.dart'; import 'package:args/args.dart';
...@@ -11,6 +10,7 @@ import '../lib/src/base/common.dart'; ...@@ -11,6 +10,7 @@ import '../lib/src/base/common.dart';
import '../lib/src/base/config.dart'; import '../lib/src/base/config.dart';
import '../lib/src/base/context.dart'; import '../lib/src/base/context.dart';
import '../lib/src/base/file_system.dart'; import '../lib/src/base/file_system.dart';
import '../lib/src/base/io.dart';
import '../lib/src/base/logger.dart'; import '../lib/src/base/logger.dart';
import '../lib/src/base/os.dart'; import '../lib/src/base/os.dart';
import '../lib/src/base/process_manager.dart'; import '../lib/src/base/process_manager.dart';
...@@ -63,7 +63,7 @@ Future<Null> run(List<String> args) async { ...@@ -63,7 +63,7 @@ Future<Null> run(List<String> args) async {
printError('Missing option! All options must be specified.'); printError('Missing option! All options must be specified.');
exit(1); exit(1);
} }
Cache.flutterRoot = io.Platform.environment['FLUTTER_ROOT']; Cache.flutterRoot = Platform.environment['FLUTTER_ROOT'];
String outputPath = argResults[_kOptionOutput]; String outputPath = argResults[_kOptionOutput];
try { try {
await assemble( await assemble(
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:async'; import 'dart:async';
import 'dart:io' as io;
import 'package:args/command_runner.dart'; import 'package:args/command_runner.dart';
import 'package:stack_trace/stack_trace.dart'; import 'package:stack_trace/stack_trace.dart';
...@@ -12,6 +11,7 @@ import 'src/base/common.dart'; ...@@ -12,6 +11,7 @@ import 'src/base/common.dart';
import 'src/base/config.dart'; import 'src/base/config.dart';
import 'src/base/context.dart'; import 'src/base/context.dart';
import 'src/base/file_system.dart'; import 'src/base/file_system.dart';
import 'src/base/io.dart';
import 'src/base/logger.dart'; import 'src/base/logger.dart';
import 'src/base/os.dart'; import 'src/base/os.dart';
import 'src/base/process.dart'; import 'src/base/process.dart';
...@@ -125,9 +125,9 @@ Future<Null> main(List<String> args) async { ...@@ -125,9 +125,9 @@ Future<Null> main(List<String> args) async {
_exit(0); _exit(0);
}, onError: (dynamic error, Chain chain) { }, onError: (dynamic error, Chain chain) {
if (error is UsageException) { if (error is UsageException) {
io.stderr.writeln(error.message); stderr.writeln(error.message);
io.stderr.writeln(); stderr.writeln();
io.stderr.writeln( stderr.writeln(
"Run 'flutter -h' (or 'flutter <command> -h') for available " "Run 'flutter -h' (or 'flutter <command> -h') for available "
"flutter commands and options." "flutter commands and options."
); );
...@@ -135,11 +135,11 @@ Future<Null> main(List<String> args) async { ...@@ -135,11 +135,11 @@ Future<Null> main(List<String> args) async {
_exit(64); _exit(64);
} else if (error is ToolExit) { } else if (error is ToolExit) {
if (error.message != null) if (error.message != null)
io.stderr.writeln(error.message); stderr.writeln(error.message);
if (verbose) { if (verbose) {
io.stderr.writeln(); stderr.writeln();
io.stderr.writeln(chain.terse.toString()); stderr.writeln(chain.terse.toString());
io.stderr.writeln(); stderr.writeln();
} }
_exit(error.exitCode ?? 1); _exit(error.exitCode ?? 1);
} else if (error is ProcessExit) { } else if (error is ProcessExit) {
...@@ -147,23 +147,23 @@ Future<Null> main(List<String> args) async { ...@@ -147,23 +147,23 @@ Future<Null> main(List<String> args) async {
_exit(error.exitCode); _exit(error.exitCode);
} else { } else {
// We've crashed; emit a log report. // We've crashed; emit a log report.
io.stderr.writeln(); stderr.writeln();
flutterUsage.sendException(error, chain); flutterUsage.sendException(error, chain);
if (isRunningOnBot) { if (isRunningOnBot) {
// Print the stack trace on the bots - don't write a crash report. // Print the stack trace on the bots - don't write a crash report.
io.stderr.writeln('$error'); stderr.writeln('$error');
io.stderr.writeln(chain.terse.toString()); stderr.writeln(chain.terse.toString());
_exit(1); _exit(1);
} else { } else {
if (error is String) if (error is String)
io.stderr.writeln('Oops; flutter has exited unexpectedly: "$error".'); stderr.writeln('Oops; flutter has exited unexpectedly: "$error".');
else else
io.stderr.writeln('Oops; flutter has exited unexpectedly.'); stderr.writeln('Oops; flutter has exited unexpectedly.');
_createCrashReport(args, error, chain).then((File file) { _createCrashReport(args, error, chain).then((File file) {
io.stderr.writeln( stderr.writeln(
'Crash report written to ${file.path};\n' 'Crash report written to ${file.path};\n'
'please let us know at https://github.com/flutter/flutter/issues.' 'please let us know at https://github.com/flutter/flutter/issues.'
); );
......
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:async'; import 'dart:async';
import 'dart:io';
import '../base/io.dart';
import '../base/process.dart'; import '../base/process.dart';
import '../globals.dart'; import '../globals.dart';
......
...@@ -4,11 +4,11 @@ ...@@ -4,11 +4,11 @@
import 'dart:async'; import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'dart:io' as io;
import '../android/android_sdk.dart'; import '../android/android_sdk.dart';
import '../application_package.dart'; import '../application_package.dart';
import '../base/file_system.dart'; import '../base/file_system.dart';
import '../base/io.dart';
import '../base/logger.dart'; import '../base/logger.dart';
import '../base/os.dart'; import '../base/os.dart';
import '../base/process.dart'; import '../base/process.dart';
...@@ -61,7 +61,7 @@ class AndroidDevice extends Device { ...@@ -61,7 +61,7 @@ class AndroidDevice extends Device {
try { try {
// We pass an encoding of LATIN1 so that we don't try and interpret the // We pass an encoding of LATIN1 so that we don't try and interpret the
// `adb shell getprop` result as UTF8. // `adb shell getprop` result as UTF8.
io.ProcessResult result = processManager.runSync( ProcessResult result = processManager.runSync(
propCommand.first, propCommand.first,
propCommand.sublist(1), propCommand.sublist(1),
stdoutEncoding: LATIN1 stdoutEncoding: LATIN1
...@@ -559,7 +559,7 @@ class _AdbLogReader extends DeviceLogReader { ...@@ -559,7 +559,7 @@ class _AdbLogReader extends DeviceLogReader {
final AndroidDevice device; final AndroidDevice device;
StreamController<String> _linesController; StreamController<String> _linesController;
io.Process _process; Process _process;
@override @override
Stream<String> get logLines => _linesController.stream; Stream<String> get logLines => _linesController.stream;
...@@ -585,7 +585,7 @@ class _AdbLogReader extends DeviceLogReader { ...@@ -585,7 +585,7 @@ class _AdbLogReader extends DeviceLogReader {
_timeOrigin = _adbTimestampToDateTime(lastTimestamp); _timeOrigin = _adbTimestampToDateTime(lastTimestamp);
else else
_timeOrigin = null; _timeOrigin = null;
runCommand(device.adbCommandForDevice(args)).then((io.Process process) { runCommand(device.adbCommandForDevice(args)).then((Process process) {
_process = process; _process = process;
_process.stdout.transform(UTF8.decoder).transform(const LineSplitter()).listen(_onLine); _process.stdout.transform(UTF8.decoder).transform(const LineSplitter()).listen(_onLine);
_process.stderr.transform(UTF8.decoder).transform(const LineSplitter()).listen(_onLine); _process.stderr.transform(UTF8.decoder).transform(const LineSplitter()).listen(_onLine);
......
...@@ -2,14 +2,13 @@ ...@@ -2,14 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:io' as io;
import 'package:path/path.dart' as path; import 'package:path/path.dart' as path;
import 'package:pub_semver/pub_semver.dart'; import 'package:pub_semver/pub_semver.dart';
import '../base/common.dart'; import '../base/common.dart';
import '../base/context.dart'; import '../base/context.dart';
import '../base/file_system.dart'; import '../base/file_system.dart';
import '../base/io.dart';
import '../base/os.dart'; import '../base/os.dart';
import '../globals.dart'; import '../globals.dart';
...@@ -65,12 +64,12 @@ class AndroidSdk { ...@@ -65,12 +64,12 @@ class AndroidSdk {
static AndroidSdk locateAndroidSdk() { static AndroidSdk locateAndroidSdk() {
String androidHomeDir; String androidHomeDir;
if (io.Platform.environment.containsKey(kAndroidHome)) { if (Platform.environment.containsKey(kAndroidHome)) {
androidHomeDir = io.Platform.environment[kAndroidHome]; androidHomeDir = Platform.environment[kAndroidHome];
} else if (io.Platform.isLinux) { } else if (Platform.isLinux) {
if (homeDirPath != null) if (homeDirPath != null)
androidHomeDir = '$homeDirPath/Android/Sdk'; androidHomeDir = '$homeDirPath/Android/Sdk';
} else if (io.Platform.isMacOS) { } else if (Platform.isMacOS) {
if (homeDirPath != null) if (homeDirPath != null)
androidHomeDir = '$homeDirPath/Library/Android/sdk'; androidHomeDir = '$homeDirPath/Library/Android/sdk';
} }
......
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:async'; import 'dart:async';
import 'dart:io';
import '../base/io.dart';
import '../base/os.dart'; import '../base/os.dart';
import '../base/process_manager.dart'; import '../base/process_manager.dart';
import '../doctor.dart'; import '../doctor.dart';
......
...@@ -4,13 +4,13 @@ ...@@ -4,13 +4,13 @@
import 'dart:async'; import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'dart:io' as io;
import 'package:json_schema/json_schema.dart'; import 'package:json_schema/json_schema.dart';
import 'package:path/path.dart' as path; import 'package:path/path.dart' as path;
import 'package:yaml/yaml.dart'; import 'package:yaml/yaml.dart';
import 'base/file_system.dart'; import 'base/file_system.dart';
import 'base/io.dart';
import 'build_info.dart'; import 'build_info.dart';
import 'cache.dart'; import 'cache.dart';
import 'dart/package_map.dart'; import 'dart/package_map.dart';
...@@ -378,7 +378,7 @@ Map<_Asset, List<_Asset>> _parseAssets( ...@@ -378,7 +378,7 @@ Map<_Asset, List<_Asset>> _parseAssets(
return result; return result;
excludeDirs = excludeDirs.map( excludeDirs = excludeDirs.map(
(String exclude) => path.absolute(exclude) + io.Platform.pathSeparator).toList(); (String exclude) => path.absolute(exclude) + Platform.pathSeparator).toList();
if (manifestDescriptor.containsKey('assets')) { if (manifestDescriptor.containsKey('assets')) {
for (String asset in manifestDescriptor['assets']) { for (String asset in manifestDescriptor['assets']) {
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:io';
import 'package:path/path.dart' as path; import 'package:path/path.dart' as path;
import 'io.dart';
const int kDefaultObservatoryPort = 8100; const int kDefaultObservatoryPort = 8100;
const int kDefaultDiagnosticPort = 8101; const int kDefaultDiagnosticPort = 8101;
const int kDefaultDrivePort = 8183; const int kDefaultDrivePort = 8183;
......
...@@ -3,12 +3,12 @@ ...@@ -3,12 +3,12 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:convert'; import 'dart:convert';
import 'dart:io' as io;
import 'package:path/path.dart' as path; import 'package:path/path.dart' as path;
import 'context.dart'; import 'context.dart';
import 'file_system.dart'; import 'file_system.dart';
import 'io.dart';
class Config { class Config {
Config([File configFile]) { Config([File configFile]) {
...@@ -46,7 +46,7 @@ class Config { ...@@ -46,7 +46,7 @@ class Config {
} }
String _userHomeDir() { String _userHomeDir() {
String envKey = io.Platform.operatingSystem == 'windows' ? 'APPDATA' : 'HOME'; String envKey = Platform.operatingSystem == 'windows' ? 'APPDATA' : 'HOME';
String value = io.Platform.environment[envKey]; String value = Platform.environment[envKey];
return value == null ? '.' : value; return value == null ? '.' : value;
} }
...@@ -2,12 +2,9 @@ ...@@ -2,12 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:io' as io;
import 'package:file/file.dart'; import 'package:file/file.dart';
import 'package:file/local.dart'; import 'package:file/local.dart';
import 'package:file/memory.dart'; import 'package:file/memory.dart';
import 'package:meta/meta.dart';
import 'package:path/path.dart' as path; import 'package:path/path.dart' as path;
import 'context.dart'; import 'context.dart';
...@@ -23,41 +20,11 @@ const FileSystem _kLocalFs = const LocalFileSystem(); ...@@ -23,41 +20,11 @@ const FileSystem _kLocalFs = const LocalFileSystem();
/// with [MemoryFileSystem]. /// with [MemoryFileSystem].
FileSystem get fs => context == null ? _kLocalFs : context[FileSystem]; FileSystem get fs => context == null ? _kLocalFs : context[FileSystem];
/// Exits the process with the given [exitCode].
typedef void ExitFunction([int exitCode]);
final ExitFunction _defaultExitFunction = ([int exitCode]) {
io.exit(exitCode);
};
ExitFunction _exitFunction = _defaultExitFunction;
/// Exits the process.
///
/// During tests, this may be set to a testing-friendly value by calling
/// [setExitFunctionForTests] (and then restored with [restoreExitFunction]).
ExitFunction get exit => _exitFunction;
/// Sets the [exit] function to a function that throws an exception rather
/// than exiting the process; intended for testing purposes.
@visibleForTesting
void setExitFunctionForTests([ExitFunction exitFunction]) {
_exitFunction = exitFunction ?? ([int exitCode]) {
throw new Exception('Exited with code $exitCode');
};
}
/// Restores the [exit] function to the `dart:io` implementation.
@visibleForTesting
void restoreExitFunction() {
_exitFunction = _defaultExitFunction;
}
/// Create the ancestor directories of a file path if they do not already exist. /// Create the ancestor directories of a file path if they do not already exist.
void ensureDirectoryExists(String filePath) { void ensureDirectoryExists(String filePath) {
String dirPath = path.dirname(filePath); String dirPath = path.dirname(filePath);
if (fs.typeSync(dirPath) == FileSystemEntityType.DIRECTORY) if (fs.isDirectorySync(dirPath))
return; return;
fs.directory(dirPath).createSync(recursive: true); fs.directory(dirPath).createSync(recursive: true);
} }
......
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/// This file serves as the single point of entry into the `dart:io` APIs
/// within Flutter tools.
///
/// In order to make Flutter tools more testable, we use the `FileSystem` APIs
/// in `package:file` rather than using the `dart:io` file APIs directly (see
/// `file_system.dart`). Doing so allows us to swap out local file system
/// access with mockable (or in-memory) file systems, making our tests hermetic
/// vis-a-vis file system access.
///
/// To ensure that all file system access within Flutter tools goes through the
/// proper APIs, we forbid direct imports of `dart:io` (via a test), forcing
/// all callers to instead import this file, which exports the blessed subset
/// of `dart:io` that is legal to use in Flutter tools.
///
/// Because of the nature of this file, it is important that **no file APIs
/// be exported from `dart:io` in this file**! Moreover, be careful 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.
import 'dart:io' as io show exit, exitCode;
import 'package:meta/meta.dart';
export 'dart:io'
show
BytesBuilder,
exitCode,
GZIP,
InternetAddress,
IOException,
IOSink,
HttpClient,
HttpClientRequest,
HttpClientResponse,
HttpHeaders,
HttpRequest,
HttpServer,
HttpStatus,
pid,
Platform,
Process,
ProcessException,
ProcessResult,
ProcessSignal,
ProcessStartMode,
ServerSocket,
stderr,
stdin,
stdout,
Socket,
SocketException,
SYSTEM_ENCODING,
WebSocket,
WebSocketTransformer;
/// Exits the process with the given [exitCode].
typedef void ExitFunction(int exitCode);
final ExitFunction _defaultExitFunction = (int exitCode) => io.exit(exitCode);
ExitFunction _exitFunction = _defaultExitFunction;
/// Exits the process.
///
/// This is analogous to the `exit` function in `dart:io`, except that this
/// function may be set to a testing-friendly value by calling
/// [setExitFunctionForTests] (and then restored to its default implementation
/// with [restoreExitFunction]). The default implementation delegates to
/// `dart:io`.
ExitFunction get exit => _exitFunction;
/// Sets the [exit] function to a function that throws an exception rather
/// than exiting the process; this is intended for testing purposes.
@visibleForTesting
void setExitFunctionForTests([ExitFunction exitFunction]) {
_exitFunction = exitFunction ?? (int exitCode) {
throw new Exception('Exited with code ${io.exitCode}');
};
}
/// Restores the [exit] function to the `dart:io` implementation.
@visibleForTesting
void restoreExitFunction() {
_exitFunction = _defaultExitFunction;
}
...@@ -4,10 +4,11 @@ ...@@ -4,10 +4,11 @@
import 'dart:async'; import 'dart:async';
import 'dart:convert' show ASCII; import 'dart:convert' show ASCII;
import 'dart:io';
import 'package:stack_trace/stack_trace.dart'; import 'package:stack_trace/stack_trace.dart';
import 'io.dart';
final AnsiTerminal terminal = new AnsiTerminal(); final AnsiTerminal terminal = new AnsiTerminal();
abstract class Logger { abstract class Logger {
......
...@@ -3,10 +3,10 @@ ...@@ -3,10 +3,10 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:async'; import 'dart:async';
import 'dart:io';
import '../globals.dart'; import '../globals.dart';
import 'common.dart'; import 'common.dart';
import 'io.dart';
const int kNetworkProblemExitCode = 50; const int kNetworkProblemExitCode = 50;
......
...@@ -3,13 +3,13 @@ ...@@ -3,13 +3,13 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:async'; import 'dart:async';
import 'dart:io' as io;
import 'package:archive/archive.dart'; import 'package:archive/archive.dart';
import 'package:path/path.dart' as path; import 'package:path/path.dart' as path;
import 'context.dart'; import 'context.dart';
import 'file_system.dart'; import 'file_system.dart';
import 'io.dart';
import 'process.dart'; import 'process.dart';
import 'process_manager.dart'; import 'process_manager.dart';
...@@ -18,7 +18,7 @@ OperatingSystemUtils get os => context[OperatingSystemUtils]; ...@@ -18,7 +18,7 @@ OperatingSystemUtils get os => context[OperatingSystemUtils];
abstract class OperatingSystemUtils { abstract class OperatingSystemUtils {
factory OperatingSystemUtils() { factory OperatingSystemUtils() {
if (io.Platform.isWindows) { if (Platform.isWindows) {
return new _WindowsUtils(); return new _WindowsUtils();
} else { } else {
return new _PosixUtils(); return new _PosixUtils();
...@@ -27,14 +27,14 @@ abstract class OperatingSystemUtils { ...@@ -27,14 +27,14 @@ abstract class OperatingSystemUtils {
OperatingSystemUtils._private(); OperatingSystemUtils._private();
String get operatingSystem => io.Platform.operatingSystem; String get operatingSystem => Platform.operatingSystem;
bool get isMacOS => operatingSystem == 'macos'; bool get isMacOS => operatingSystem == 'macos';
bool get isWindows => operatingSystem == 'windows'; bool get isWindows => operatingSystem == 'windows';
bool get isLinux => operatingSystem == 'linux'; bool get isLinux => operatingSystem == 'linux';
/// Make the given file executable. This may be a no-op on some platforms. /// Make the given file executable. This may be a no-op on some platforms.
io.ProcessResult makeExecutable(File file); ProcessResult makeExecutable(File file);
/// Return the path (with symlinks resolved) to the given executable, or `null` /// Return the path (with symlinks resolved) to the given executable, or `null`
/// if `which` was not able to locate the binary. /// if `which` was not able to locate the binary.
...@@ -50,7 +50,7 @@ class _PosixUtils extends OperatingSystemUtils { ...@@ -50,7 +50,7 @@ class _PosixUtils extends OperatingSystemUtils {
_PosixUtils() : super._private(); _PosixUtils() : super._private();
@override @override
io.ProcessResult makeExecutable(File file) { ProcessResult makeExecutable(File file) {
return processManager.runSync('chmod', <String>['a+x', file.path]); return processManager.runSync('chmod', <String>['a+x', file.path]);
} }
...@@ -58,7 +58,7 @@ class _PosixUtils extends OperatingSystemUtils { ...@@ -58,7 +58,7 @@ class _PosixUtils extends OperatingSystemUtils {
/// to locate the binary. /// to locate the binary.
@override @override
File which(String execName) { File which(String execName) {
io.ProcessResult result = processManager.runSync('which', <String>[execName]); ProcessResult result = processManager.runSync('which', <String>[execName]);
if (result.exitCode != 0) if (result.exitCode != 0)
return null; return null;
String path = result.stdout.trim().split('\n').first.trim(); String path = result.stdout.trim().split('\n').first.trim();
...@@ -83,13 +83,13 @@ class _WindowsUtils extends OperatingSystemUtils { ...@@ -83,13 +83,13 @@ class _WindowsUtils extends OperatingSystemUtils {
// This is a no-op. // This is a no-op.
@override @override
io.ProcessResult makeExecutable(File file) { ProcessResult makeExecutable(File file) {
return new io.ProcessResult(0, 0, null, null); return new ProcessResult(0, 0, null, null);
} }
@override @override
File which(String execName) { File which(String execName) {
io.ProcessResult result = processManager.runSync('where', <String>[execName]); ProcessResult result = processManager.runSync('where', <String>[execName]);
if (result.exitCode != 0) if (result.exitCode != 0)
return null; return null;
return fs.file(result.stdout.trim().split('\n').first.trim()); return fs.file(result.stdout.trim().split('\n').first.trim());
...@@ -118,7 +118,7 @@ class _WindowsUtils extends OperatingSystemUtils { ...@@ -118,7 +118,7 @@ class _WindowsUtils extends OperatingSystemUtils {
} }
Future<int> findAvailablePort() async { Future<int> findAvailablePort() async {
io.ServerSocket socket = await io.ServerSocket.bind(io.InternetAddress.LOOPBACK_IP_V4, 0); ServerSocket socket = await ServerSocket.bind(InternetAddress.LOOPBACK_IP_V4, 0);
int port = socket.port; int port = socket.port;
await socket.close(); await socket.close();
return port; return port;
...@@ -143,7 +143,7 @@ Future<int> findPreferredPort(int defaultPort, { int searchStep: 2 }) async { ...@@ -143,7 +143,7 @@ Future<int> findPreferredPort(int defaultPort, { int searchStep: 2 }) async {
Future<bool> _isPortAvailable(int port) async { Future<bool> _isPortAvailable(int port) async {
try { try {
io.ServerSocket socket = await io.ServerSocket.bind(io.InternetAddress.LOOPBACK_IP_V4, port); ServerSocket socket = await ServerSocket.bind(InternetAddress.LOOPBACK_IP_V4, port);
await socket.close(); await socket.close();
return true; return true;
} catch (error) { } catch (error) {
......
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
import 'dart:async'; import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'dart:io';
import 'io.dart';
import 'process_manager.dart'; import 'process_manager.dart';
import '../globals.dart'; import '../globals.dart';
......
...@@ -4,21 +4,21 @@ ...@@ -4,21 +4,21 @@
import 'dart:async'; import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'dart:io' as io;
import 'dart:math' show Random; import 'dart:math' show Random;
import 'package:crypto/crypto.dart'; import 'package:crypto/crypto.dart';
import 'package:path/path.dart' as path; import 'package:path/path.dart' as path;
import 'file_system.dart'; import 'file_system.dart';
import 'io.dart';
bool get isRunningOnBot { bool get isRunningOnBot {
// https://docs.travis-ci.com/user/environment-variables/#Default-Environment-Variables // https://docs.travis-ci.com/user/environment-variables/#Default-Environment-Variables
// CHROME_HEADLESS is one property set on Flutter's Chrome Infra bots. // CHROME_HEADLESS is one property set on Flutter's Chrome Infra bots.
return return
io.Platform.environment['TRAVIS'] == 'true' || Platform.environment['TRAVIS'] == 'true' ||
io.Platform.environment['CONTINUOUS_INTEGRATION'] == 'true' || Platform.environment['CONTINUOUS_INTEGRATION'] == 'true' ||
io.Platform.environment['CHROME_HEADLESS'] == '1'; Platform.environment['CHROME_HEADLESS'] == '1';
} }
String hex(List<int> bytes) { String hex(List<int> bytes) {
...@@ -93,7 +93,7 @@ String getElapsedAsMilliseconds(Duration duration) { ...@@ -93,7 +93,7 @@ String getElapsedAsMilliseconds(Duration duration) {
/// Return a relative path if [fullPath] is contained by the cwd, else return an /// Return a relative path if [fullPath] is contained by the cwd, else return an
/// absolute path. /// absolute path.
String getDisplayPath(String fullPath) { String getDisplayPath(String fullPath) {
String cwd = fs.currentDirectory.path + io.Platform.pathSeparator; String cwd = fs.currentDirectory.path + Platform.pathSeparator;
return fullPath.startsWith(cwd) ? fullPath.substring(cwd.length) : fullPath; return fullPath.startsWith(cwd) ? fullPath.substring(cwd.length) : fullPath;
} }
......
...@@ -2,11 +2,10 @@ ...@@ -2,11 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:io';
import 'package:path/path.dart' as path; import 'package:path/path.dart' as path;
import 'base/context.dart'; import 'base/context.dart';
import 'base/io.dart';
import 'base/utils.dart'; import 'base/utils.dart';
import 'globals.dart'; import 'globals.dart';
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:async'; import 'dart:async';
import 'dart:io' as io;
import 'package:flutter_tools/src/dart/pub.dart'; import 'package:flutter_tools/src/dart/pub.dart';
import 'package:flutter_tools/src/dart/summary.dart'; import 'package:flutter_tools/src/dart/summary.dart';
...@@ -11,6 +10,7 @@ import 'package:path/path.dart' as path; ...@@ -11,6 +10,7 @@ import 'package:path/path.dart' as path;
import 'base/context.dart'; import 'base/context.dart';
import 'base/file_system.dart'; import 'base/file_system.dart';
import 'base/io.dart';
import 'base/logger.dart'; import 'base/logger.dart';
import 'base/net.dart'; import 'base/net.dart';
import 'base/os.dart'; import 'base/os.dart';
...@@ -84,7 +84,7 @@ class Cache { ...@@ -84,7 +84,7 @@ class Cache {
static String get dartSdkVersion { static String get dartSdkVersion {
if (_dartSdkVersion == null) { if (_dartSdkVersion == null) {
_dartSdkVersion = io.Platform.version; _dartSdkVersion = Platform.version;
} }
return _dartSdkVersion; return _dartSdkVersion;
} }
...@@ -264,9 +264,9 @@ class FlutterEngine { ...@@ -264,9 +264,9 @@ class FlutterEngine {
if (cache.includeAllPlatforms) if (cache.includeAllPlatforms)
dirs.addAll(<String>['ios', 'ios-profile', 'ios-release', 'linux-x64']); dirs.addAll(<String>['ios', 'ios-profile', 'ios-release', 'linux-x64']);
else if (io.Platform.isMacOS) else if (Platform.isMacOS)
dirs.addAll(<String>['ios', 'ios-profile', 'ios-release']); dirs.addAll(<String>['ios', 'ios-profile', 'ios-release']);
else if (io.Platform.isLinux) else if (Platform.isLinux)
dirs.add('linux-x64'); dirs.add('linux-x64');
return dirs; return dirs;
...@@ -278,9 +278,9 @@ class FlutterEngine { ...@@ -278,9 +278,9 @@ class FlutterEngine {
return <List<String>>[] return <List<String>>[]
..addAll(_osxToolsDirs) ..addAll(_osxToolsDirs)
..addAll(_linuxToolsDirs); ..addAll(_linuxToolsDirs);
else if (io.Platform.isMacOS) else if (Platform.isMacOS)
return _osxToolsDirs; return _osxToolsDirs;
else if (io.Platform.isLinux) else if (Platform.isLinux)
return _linuxToolsDirs; return _linuxToolsDirs;
else else
return <List<String>>[]; return <List<String>>[];
......
...@@ -3,12 +3,12 @@ ...@@ -3,12 +3,12 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:async'; import 'dart:async';
import 'dart:io' as io;
import 'package:args/args.dart'; import 'package:args/args.dart';
import 'package:path/path.dart' as path; import 'package:path/path.dart' as path;
import '../base/file_system.dart'; import '../base/file_system.dart';
import '../base/io.dart';
import '../base/utils.dart'; import '../base/utils.dart';
import '../cache.dart'; import '../cache.dart';
import '../globals.dart'; import '../globals.dart';
...@@ -59,7 +59,7 @@ bool inRepo(List<String> fileList) { ...@@ -59,7 +59,7 @@ bool inRepo(List<String> fileList) {
if (fileList == null || fileList.isEmpty) if (fileList == null || fileList.isEmpty)
fileList = <String>[path.current]; fileList = <String>[path.current];
String root = path.normalize(path.absolute(Cache.flutterRoot)); String root = path.normalize(path.absolute(Cache.flutterRoot));
String prefix = root + io.Platform.pathSeparator; String prefix = root + Platform.pathSeparator;
for (String file in fileList) { for (String file in fileList) {
file = path.normalize(path.absolute(file)); file = path.normalize(path.absolute(file));
if (file == root || file.startsWith(prefix)) if (file == root || file.startsWith(prefix))
......
...@@ -4,13 +4,13 @@ ...@@ -4,13 +4,13 @@
import 'dart:async'; import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'dart:io' as io;
import 'package:args/args.dart'; import 'package:args/args.dart';
import 'package:path/path.dart' as path; import 'package:path/path.dart' as path;
import '../base/common.dart'; import '../base/common.dart';
import '../base/file_system.dart'; import '../base/file_system.dart';
import '../base/io.dart';
import '../base/logger.dart'; import '../base/logger.dart';
import '../base/process_manager.dart'; import '../base/process_manager.dart';
import '../base/utils.dart'; import '../base/utils.dart';
...@@ -150,7 +150,7 @@ class AnalysisServer { ...@@ -150,7 +150,7 @@ class AnalysisServer {
final String sdk; final String sdk;
final List<String> directories; final List<String> directories;
io.Process _process; Process _process;
StreamController<bool> _analyzingController = new StreamController<bool>.broadcast(); StreamController<bool> _analyzingController = new StreamController<bool>.broadcast();
StreamController<FileAnalysisErrors> _errorsController = new StreamController<FileAnalysisErrors>.broadcast(); StreamController<FileAnalysisErrors> _errorsController = new StreamController<FileAnalysisErrors>.broadcast();
......
...@@ -3,16 +3,16 @@ ...@@ -3,16 +3,16 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:async'; import 'dart:async';
import 'dart:io' as io;
import 'package:meta/meta.dart'; import 'package:meta/meta.dart';
import '../base/common.dart';
import '../base/file_system.dart'; import '../base/file_system.dart';
import '../base/io.dart';
import '../base/utils.dart';
import '../build_info.dart'; import '../build_info.dart';
import '../globals.dart'; import '../globals.dart';
import '../runner/flutter_command.dart'; import '../runner/flutter_command.dart';
import '../base/common.dart';
import '../base/utils.dart';
import 'build_apk.dart'; import 'build_apk.dart';
import 'build_aot.dart'; import 'build_aot.dart';
import 'build_flx.dart'; import 'build_flx.dart';
...@@ -88,7 +88,7 @@ class BuildCleanCommand extends FlutterCommand { ...@@ -88,7 +88,7 @@ class BuildCleanCommand extends FlutterCommand {
@override @override
Future<Null> runCommand() async { Future<Null> runCommand() async {
Directory buildDir = fs.directory(getBuildDirectory()); Directory buildDir = fs.directory(getBuildDirectory());
printStatus("Deleting '${buildDir.path}${io.Platform.pathSeparator}'."); printStatus("Deleting '${buildDir.path}${Platform.pathSeparator}'.");
if (!buildDir.existsSync()) if (!buildDir.existsSync())
return; return;
......
...@@ -3,12 +3,12 @@ ...@@ -3,12 +3,12 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:async'; import 'dart:async';
import 'dart:io' as io;
import 'package:path/path.dart' as path; import 'package:path/path.dart' as path;
import '../base/common.dart'; import '../base/common.dart';
import '../base/file_system.dart'; import '../base/file_system.dart';
import '../base/io.dart';
import '../base/logger.dart'; import '../base/logger.dart';
import '../base/process.dart'; import '../base/process.dart';
import '../base/utils.dart'; import '../base/utils.dart';
...@@ -65,7 +65,7 @@ class BuildAotCommand extends BuildSubCommand { ...@@ -65,7 +65,7 @@ class BuildAotCommand extends BuildSubCommand {
if (outputPath == null) if (outputPath == null)
throwToolExit(null); throwToolExit(null);
printStatus('Built to $outputPath${io.Platform.pathSeparator}.'); printStatus('Built to $outputPath${Platform.pathSeparator}.');
} }
} }
......
...@@ -4,12 +4,12 @@ ...@@ -4,12 +4,12 @@
import 'dart:async'; import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'dart:io' as io;
import '../android/android_device.dart'; import '../android/android_device.dart';
import '../base/common.dart'; import '../base/common.dart';
import '../base/context.dart'; import '../base/context.dart';
import '../base/file_system.dart'; import '../base/file_system.dart';
import '../base/io.dart';
import '../base/logger.dart'; import '../base/logger.dart';
import '../base/utils.dart'; import '../base/utils.dart';
import '../build_info.dart'; import '../build_info.dart';
...@@ -120,7 +120,7 @@ class Daemon { ...@@ -120,7 +120,7 @@ class Daemon {
dynamic id = request['id']; dynamic id = request['id'];
if (id == null) { if (id == null) {
io.stderr.writeln('no id for request: $request'); stderr.writeln('no id for request: $request');
return; return;
} }
...@@ -235,9 +235,9 @@ class DaemonDomain extends Domain { ...@@ -235,9 +235,9 @@ class DaemonDomain extends Domain {
// capture the print output for testing. // capture the print output for testing.
print(message.message); print(message.message);
} else if (message.level == 'error') { } else if (message.level == 'error') {
io.stderr.writeln(message.message); stderr.writeln(message.message);
if (message.stackTrace != null) if (message.stackTrace != null)
io.stderr.writeln(message.stackTrace.toString().trimRight()); stderr.writeln(message.stackTrace.toString().trimRight());
} }
} else { } else {
if (message.stackTrace != null) { if (message.stackTrace != null) {
...@@ -590,7 +590,7 @@ class DeviceDomain extends Domain { ...@@ -590,7 +590,7 @@ class DeviceDomain extends Domain {
} }
} }
Stream<Map<String, dynamic>> get stdinCommandStream => io.stdin Stream<Map<String, dynamic>> get stdinCommandStream => stdin
.transform(UTF8.decoder) .transform(UTF8.decoder)
.transform(const LineSplitter()) .transform(const LineSplitter())
.where((String line) => line.startsWith('[{') && line.endsWith('}]')) .where((String line) => line.startsWith('[{') && line.endsWith('}]'))
...@@ -600,7 +600,7 @@ Stream<Map<String, dynamic>> get stdinCommandStream => io.stdin ...@@ -600,7 +600,7 @@ Stream<Map<String, dynamic>> get stdinCommandStream => io.stdin
}); });
void stdoutCommandResponse(Map<String, dynamic> command) { void stdoutCommandResponse(Map<String, dynamic> command) {
io.stdout.writeln('[${JSON.encode(command, toEncodable: _jsonEncodeObject)}]'); stdout.writeln('[${JSON.encode(command, toEncodable: _jsonEncodeObject)}]');
} }
dynamic _jsonEncodeObject(dynamic object) { dynamic _jsonEncodeObject(dynamic object) {
...@@ -710,9 +710,9 @@ class _AppRunLogger extends Logger { ...@@ -710,9 +710,9 @@ class _AppRunLogger extends Logger {
@override @override
void printError(String message, [StackTrace stackTrace]) { void printError(String message, [StackTrace stackTrace]) {
if (logToStdout) { if (logToStdout) {
io.stderr.writeln(message); stderr.writeln(message);
if (stackTrace != null) if (stackTrace != null)
io.stderr.writeln(stackTrace.toString().trimRight()); stderr.writeln(stackTrace.toString().trimRight());
} else { } else {
if (stackTrace != null) { if (stackTrace != null) {
_sendLogEvent(<String, dynamic>{ _sendLogEvent(<String, dynamic>{
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:async'; import 'dart:async';
import 'dart:io';
import '../base/common.dart'; import '../base/common.dart';
import '../base/io.dart';
import '../cache.dart'; import '../cache.dart';
import '../device.dart'; import '../device.dart';
import '../globals.dart'; import '../globals.dart';
......
...@@ -3,10 +3,10 @@ ...@@ -3,10 +3,10 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:async'; import 'dart:async';
import 'dart:io' as io;
import '../base/common.dart'; import '../base/common.dart';
import '../base/file_system.dart'; import '../base/file_system.dart';
import '../base/io.dart';
import '../base/utils.dart'; import '../base/utils.dart';
import '../build_info.dart'; import '../build_info.dart';
import '../cache.dart'; import '../cache.dart';
...@@ -218,7 +218,7 @@ class RunCommand extends RunCommandBase { ...@@ -218,7 +218,7 @@ class RunCommand extends RunCommandBase {
String pidFile = argResults['pid-file']; String pidFile = argResults['pid-file'];
if (pidFile != null) { if (pidFile != null) {
// Write our pid to the file. // Write our pid to the file.
fs.file(pidFile).writeAsStringSync(io.pid.toString()); fs.file(pidFile).writeAsStringSync(pid.toString());
} }
ResidentRunner runner; ResidentRunner runner;
......
...@@ -3,13 +3,13 @@ ...@@ -3,13 +3,13 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:async'; import 'dart:async';
import 'dart:io' as io;
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import 'package:path/path.dart' as path; import 'package:path/path.dart' as path;
import '../base/common.dart'; import '../base/common.dart';
import '../base/file_system.dart'; import '../base/file_system.dart';
import '../base/io.dart' hide IOSink;
import '../base/utils.dart'; import '../base/utils.dart';
import '../device.dart'; import '../device.dart';
import '../globals.dart'; import '../globals.dart';
...@@ -106,10 +106,10 @@ class ScreenshotCommand extends FlutterCommand { ...@@ -106,10 +106,10 @@ class ScreenshotCommand extends FlutterCommand {
http.StreamedResponse skpResponse; http.StreamedResponse skpResponse;
try { try {
skpResponse = await new http.Request('GET', skpUri).send(); skpResponse = await new http.Request('GET', skpUri).send();
} on io.SocketException catch (e) { } on SocketException catch (e) {
throwToolExit('Skia screenshot failed: $skpUri\n$e\n\n$errorHelpText'); throwToolExit('Skia screenshot failed: $skpUri\n$e\n\n$errorHelpText');
} }
if (skpResponse.statusCode != io.HttpStatus.OK) { if (skpResponse.statusCode != HttpStatus.OK) {
String error = await skpResponse.stream.toStringStream().join(); String error = await skpResponse.stream.toStringStream().join();
throwToolExit('Error: $error\n\n$errorHelpText'); throwToolExit('Error: $error\n\n$errorHelpText');
} }
...@@ -122,7 +122,7 @@ class ScreenshotCommand extends FlutterCommand { ...@@ -122,7 +122,7 @@ class ScreenshotCommand extends FlutterCommand {
'file', skpResponse.stream, skpResponse.contentLength)); 'file', skpResponse.stream, skpResponse.contentLength));
http.StreamedResponse postResponse = await postRequest.send(); http.StreamedResponse postResponse = await postRequest.send();
if (postResponse.statusCode != io.HttpStatus.OK) if (postResponse.statusCode != HttpStatus.OK)
throwToolExit('Failed to post Skia picture to skiaserve.\n\n$errorHelpText'); throwToolExit('Failed to post Skia picture to skiaserve.\n\n$errorHelpText');
} else { } else {
outputFile ??= getUniqueFile(fs.currentDirectory, 'flutter', 'skp'); outputFile ??= getUniqueFile(fs.currentDirectory, 'flutter', 'skp');
......
...@@ -3,13 +3,13 @@ ...@@ -3,13 +3,13 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:async'; import 'dart:async';
import 'dart:io' as io;
import 'package:path/path.dart' as path; import 'package:path/path.dart' as path;
import 'package:test/src/executable.dart' as test; // ignore: implementation_imports import 'package:test/src/executable.dart' as test; // ignore: implementation_imports
import '../base/common.dart'; import '../base/common.dart';
import '../base/file_system.dart'; import '../base/file_system.dart';
import '../base/io.dart';
import '../base/logger.dart'; import '../base/logger.dart';
import '../base/process_manager.dart'; import '../base/process_manager.dart';
import '../base/os.dart'; import '../base/os.dart';
...@@ -80,8 +80,8 @@ class TestCommand extends FlutterCommand { ...@@ -80,8 +80,8 @@ class TestCommand extends FlutterCommand {
printTrace('running test package with arguments: $testArgs'); printTrace('running test package with arguments: $testArgs');
await test.main(testArgs); await test.main(testArgs);
// test.main() sets dart:io's exitCode global. // test.main() sets dart:io's exitCode global.
printTrace('test package returned with exit code ${io.exitCode}'); printTrace('test package returned with exit code $exitCode');
return io.exitCode; return exitCode;
} finally { } finally {
fs.currentDirectory = currentDirectory; fs.currentDirectory = currentDirectory;
} }
...@@ -128,7 +128,7 @@ class TestCommand extends FlutterCommand { ...@@ -128,7 +128,7 @@ class TestCommand extends FlutterCommand {
Directory tempDir = fs.systemTempDirectory.createTempSync('flutter_tools'); Directory tempDir = fs.systemTempDirectory.createTempSync('flutter_tools');
try { try {
File sourceFile = coverageFile.copySync(path.join(tempDir.path, 'lcov.source.info')); File sourceFile = coverageFile.copySync(path.join(tempDir.path, 'lcov.source.info'));
io.ProcessResult result = processManager.runSync('lcov', <String>[ ProcessResult result = processManager.runSync('lcov', <String>[
'--add-tracefile', baseCoverageData, '--add-tracefile', baseCoverageData,
'--add-tracefile', sourceFile.path, '--add-tracefile', sourceFile.path,
'--output-file', coverageFile.path, '--output-file', coverageFile.path,
...@@ -165,7 +165,7 @@ class TestCommand extends FlutterCommand { ...@@ -165,7 +165,7 @@ class TestCommand extends FlutterCommand {
if (argResults['coverage']) if (argResults['coverage'])
testArgs.insert(0, '--concurrency=1'); testArgs.insert(0, '--concurrency=1');
final String shellPath = tools.getHostToolPath(HostTool.SkyShell) ?? io.Platform.environment['SKY_SHELL']; final String shellPath = tools.getHostToolPath(HostTool.SkyShell) ?? Platform.environment['SKY_SHELL'];
if (!fs.isFileSync(shellPath)) if (!fs.isFileSync(shellPath))
throwToolExit('Cannot find Flutter shell at $shellPath'); throwToolExit('Cannot find Flutter shell at $shellPath');
loader.installHook(shellPath: shellPath); loader.installHook(shellPath: shellPath);
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:collection'; import 'dart:collection';
import 'dart:io' as io;
import 'package:analyzer/error/error.dart'; import 'package:analyzer/error/error.dart';
import 'package:analyzer/file_system/file_system.dart' as file_system; import 'package:analyzer/file_system/file_system.dart' as file_system;
...@@ -27,7 +26,8 @@ import 'package:path/path.dart' as path; ...@@ -27,7 +26,8 @@ import 'package:path/path.dart' as path;
import 'package:plugin/manager.dart'; import 'package:plugin/manager.dart';
import 'package:plugin/plugin.dart'; import 'package:plugin/plugin.dart';
import '../base/file_system.dart'; import '../base/file_system.dart' hide IOSink;
import '../base/io.dart';
class AnalysisDriver { class AnalysisDriver {
Set<Source> _analyzedSources = new HashSet<Source>(); Set<Source> _analyzedSources = new HashSet<Source>();
...@@ -240,10 +240,10 @@ class DriverOptions extends AnalysisOptionsImpl { ...@@ -240,10 +240,10 @@ class DriverOptions extends AnalysisOptionsImpl {
Map<Object, Object> analysisOptions; Map<Object, Object> analysisOptions;
/// Out sink for logging. /// Out sink for logging.
io.IOSink outSink = io.stdout; IOSink outSink = stdout;
/// Error sink for logging. /// Error sink for logging.
io.IOSink errorSink = io.stderr; IOSink errorSink = stderr;
} }
class PackageInfo { class PackageInfo {
...@@ -269,8 +269,8 @@ class PackageInfo { ...@@ -269,8 +269,8 @@ class PackageInfo {
} }
class _StdLogger extends Logger { class _StdLogger extends Logger {
final io.IOSink outSink; final IOSink outSink;
final io.IOSink errorSink; final IOSink errorSink;
_StdLogger({this.outSink, this.errorSink}); _StdLogger({this.outSink, this.errorSink});
@override @override
......
...@@ -2,10 +2,9 @@ ...@@ -2,10 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:io';
import 'package:path/path.dart' as path; import 'package:path/path.dart' as path;
import '../base/io.dart';
import '../cache.dart'; import '../cache.dart';
/// Locate the Dart SDK. /// Locate the Dart SDK.
......
import 'dart:async'; import 'dart:async';
import 'dart:io' as io;
import 'package:analyzer/file_system/file_system.dart'; import 'package:analyzer/file_system/file_system.dart';
import 'package:analyzer/file_system/physical_file_system.dart'; import 'package:analyzer/file_system/physical_file_system.dart';
...@@ -15,6 +14,9 @@ import 'package:flutter_tools/src/globals.dart'; ...@@ -15,6 +14,9 @@ import 'package:flutter_tools/src/globals.dart';
import 'package:path/path.dart' as pathos; import 'package:path/path.dart' as pathos;
import 'package:yaml/src/yaml_node.dart'; // ignore: implementation_imports import 'package:yaml/src/yaml_node.dart'; // ignore: implementation_imports
import '../base/file_system.dart' as file;
import '../base/io.dart';
/// Given the [skyEnginePath], locate corresponding `_embedder.yaml` and compose /// Given the [skyEnginePath], locate corresponding `_embedder.yaml` and compose
/// the full embedded Dart SDK, and build the [outBundleName] file with its /// the full embedded Dart SDK, and build the [outBundleName] file with its
/// linked summary. /// linked summary.
...@@ -46,13 +48,13 @@ void buildSkyEngineSdkSummary(String skyEnginePath, String outBundleName) { ...@@ -46,13 +48,13 @@ void buildSkyEngineSdkSummary(String skyEnginePath, String outBundleName) {
// Build. // Build.
List<int> bytes = new SummaryBuilder(sources, sdk.context, true).build(); List<int> bytes = new SummaryBuilder(sources, sdk.context, true).build();
String outputPath = pathos.join(skyEnginePath, outBundleName); String outputPath = pathos.join(skyEnginePath, outBundleName);
new io.File(outputPath).writeAsBytesSync(bytes); file.fs.file(outputPath).writeAsBytesSync(bytes);
} }
Future<Null> buildUnlinkedForPackages(String flutterPath) async { Future<Null> buildUnlinkedForPackages(String flutterPath) async {
PhysicalResourceProvider provider = PhysicalResourceProvider.INSTANCE; PhysicalResourceProvider provider = PhysicalResourceProvider.INSTANCE;
PubSummaryManager manager = PubSummaryManager manager =
new PubSummaryManager(provider, '__unlinked_${io.pid}.ds'); new PubSummaryManager(provider, '__unlinked_$pid.ds');
Folder flutterFolder = provider.getFolder(flutterPath); Folder flutterFolder = provider.getFolder(flutterPath);
......
...@@ -4,12 +4,12 @@ ...@@ -4,12 +4,12 @@
import 'dart:async'; import 'dart:async';
import 'dart:convert' show BASE64, UTF8; import 'dart:convert' show BASE64, UTF8;
import 'dart:io' as io;
import 'package:path/path.dart' as path; import 'package:path/path.dart' as path;
import 'base/context.dart'; import 'base/context.dart';
import 'base/file_system.dart'; import 'base/file_system.dart';
import 'base/io.dart';
import 'build_info.dart'; import 'build_info.dart';
import 'dart/package_map.dart'; import 'dart/package_map.dart';
import 'asset.dart'; import 'asset.dart';
...@@ -127,7 +127,7 @@ class DevFSEntry { ...@@ -127,7 +127,7 @@ class DevFSEntry {
} }
Stream<List<int>> contentsAsCompressedStream() { Stream<List<int>> contentsAsCompressedStream() {
return contentsAsStream().transform(io.GZIP.encoder); return contentsAsStream().transform(GZIP.encoder);
} }
} }
...@@ -214,13 +214,13 @@ class _DevFSHttpWriter { ...@@ -214,13 +214,13 @@ class _DevFSHttpWriter {
int _inFlight = 0; int _inFlight = 0;
List<DevFSEntry> _outstanding; List<DevFSEntry> _outstanding;
Completer<Null> _completer; Completer<Null> _completer;
io.HttpClient _client; HttpClient _client;
int _done; int _done;
int _max; int _max;
Future<Null> write(Set<DevFSEntry> entries, Future<Null> write(Set<DevFSEntry> entries,
{DevFSProgressReporter progressReporter}) async { {DevFSProgressReporter progressReporter}) async {
_client = new io.HttpClient(); _client = new HttpClient();
_client.maxConnectionsPerHost = kMaxInFlight; _client.maxConnectionsPerHost = kMaxInFlight;
_completer = new Completer<Null>(); _completer = new Completer<Null>();
_outstanding = entries.toList(); _outstanding = entries.toList();
...@@ -246,14 +246,14 @@ class _DevFSHttpWriter { ...@@ -246,14 +246,14 @@ class _DevFSHttpWriter {
Future<Null> _scheduleWrite(DevFSEntry entry, Future<Null> _scheduleWrite(DevFSEntry entry,
DevFSProgressReporter progressReporter) async { DevFSProgressReporter progressReporter) async {
try { try {
io.HttpClientRequest request = await _client.putUrl(httpAddress); HttpClientRequest request = await _client.putUrl(httpAddress);
request.headers.removeAll(io.HttpHeaders.ACCEPT_ENCODING); request.headers.removeAll(HttpHeaders.ACCEPT_ENCODING);
request.headers.add('dev_fs_name', fsName); request.headers.add('dev_fs_name', fsName);
request.headers.add('dev_fs_path_b64', request.headers.add('dev_fs_path_b64',
BASE64.encode(UTF8.encode(entry.devicePath))); BASE64.encode(UTF8.encode(entry.devicePath)));
Stream<List<int>> contents = entry.contentsAsCompressedStream(); Stream<List<int>> contents = entry.contentsAsCompressedStream();
await request.addStream(contents); await request.addStream(contents);
io.HttpClientResponse response = await request.close(); HttpClientResponse response = await request.close();
await response.drain(); await response.drain();
} catch (e, stackTrace) { } catch (e, stackTrace) {
printError('Error writing "${entry.devicePath}" to DevFS: $e\n$stackTrace'); printError('Error writing "${entry.devicePath}" to DevFS: $e\n$stackTrace');
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:async'; import 'dart:async';
import 'dart:io' as io;
import 'package:archive/archive.dart'; import 'package:archive/archive.dart';
import 'dart:convert' show UTF8; import 'dart:convert' show UTF8;
...@@ -13,6 +12,7 @@ import 'android/android_workflow.dart'; ...@@ -13,6 +12,7 @@ import 'android/android_workflow.dart';
import 'base/common.dart'; import 'base/common.dart';
import 'base/context.dart'; import 'base/context.dart';
import 'base/file_system.dart'; import 'base/file_system.dart';
import 'base/io.dart';
import 'device.dart'; import 'device.dart';
import 'globals.dart'; import 'globals.dart';
import 'ios/ios_workflow.dart'; import 'ios/ios_workflow.dart';
...@@ -27,7 +27,7 @@ const Map<String, String> _osNames = const <String, String>{ ...@@ -27,7 +27,7 @@ const Map<String, String> _osNames = const <String, String>{
}; };
String osName() { String osName() {
String os = io.Platform.operatingSystem; String os = Platform.operatingSystem;
return _osNames.containsKey(os) ? _osNames[os] : os; return _osNames.containsKey(os) ? _osNames[os] : os;
} }
...@@ -124,7 +124,7 @@ class Doctor { ...@@ -124,7 +124,7 @@ class Doctor {
else else
printStatus('${result.leadingBox} ${validator.title}'); printStatus('${result.leadingBox} ${validator.title}');
final String separator = io.Platform.isWindows ? ' ' : '•'; final String separator = Platform.isWindows ? ' ' : '•';
for (ValidationMessage message in result.messages) { for (ValidationMessage message in result.messages) {
String text = message.message.replaceAll('\n', '\n '); String text = message.message.replaceAll('\n', '\n ');
...@@ -182,7 +182,7 @@ class ValidationResult { ...@@ -182,7 +182,7 @@ class ValidationResult {
if (type == ValidationType.missing) if (type == ValidationType.missing)
return '[x]'; return '[x]';
else if (type == ValidationType.installed) else if (type == ValidationType.installed)
return io.Platform.isWindows ? '[+]' : '[✓]'; return Platform.isWindows ? '[+]' : '[✓]';
else else
return '[-]'; return '[-]';
} }
...@@ -217,7 +217,7 @@ class _FlutterValidator extends DoctorValidator { ...@@ -217,7 +217,7 @@ class _FlutterValidator extends DoctorValidator {
messages.add(new ValidationMessage('Engine revision ${version.engineRevisionShort}')); messages.add(new ValidationMessage('Engine revision ${version.engineRevisionShort}'));
messages.add(new ValidationMessage('Tools Dart version ${version.dartSdkVersion}')); messages.add(new ValidationMessage('Tools Dart version ${version.dartSdkVersion}'));
if (io.Platform.isWindows) { if (Platform.isWindows) {
valid = ValidationType.missing; valid = ValidationType.missing;
messages.add(new ValidationMessage.error( messages.add(new ValidationMessage.error(
...@@ -254,9 +254,9 @@ abstract class IntelliJValidator extends DoctorValidator { ...@@ -254,9 +254,9 @@ abstract class IntelliJValidator extends DoctorValidator {
}; };
static Iterable<DoctorValidator> get installedValidators { static Iterable<DoctorValidator> get installedValidators {
if (io.Platform.isLinux) if (Platform.isLinux)
return IntelliJValidatorOnLinux.installed; return IntelliJValidatorOnLinux.installed;
if (io.Platform.isMacOS) if (Platform.isMacOS)
return IntelliJValidatorOnMac.installed; return IntelliJValidatorOnMac.installed;
// TODO(danrubel): add support for Windows // TODO(danrubel): add support for Windows
return <DoctorValidator>[]; return <DoctorValidator>[];
......
...@@ -4,10 +4,10 @@ ...@@ -4,10 +4,10 @@
import 'dart:async'; import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'dart:io' as io;
import '../application_package.dart'; import '../application_package.dart';
import '../base/file_system.dart'; import '../base/file_system.dart';
import '../base/io.dart';
import '../base/os.dart'; import '../base/os.dart';
import '../base/process.dart'; import '../base/process.dart';
import '../base/process_manager.dart'; import '../base/process_manager.dart';
...@@ -28,7 +28,7 @@ class IOSDevices extends PollingDeviceDiscovery { ...@@ -28,7 +28,7 @@ class IOSDevices extends PollingDeviceDiscovery {
IOSDevices() : super('IOSDevices'); IOSDevices() : super('IOSDevices');
@override @override
bool get supportsPlatform => io.Platform.isMacOS; bool get supportsPlatform => Platform.isMacOS;
@override @override
List<Device> pollingGetDevices() => IOSDevice.getAttachedDevices(); List<Device> pollingGetDevices() => IOSDevice.getAttachedDevices();
...@@ -125,7 +125,7 @@ class IOSDevice extends Device { ...@@ -125,7 +125,7 @@ class IOSDevice extends Device {
try { try {
command = runCheckedSync(<String>['which', command]).trim(); command = runCheckedSync(<String>['which', command]).trim();
} catch (e) { } catch (e) {
if (io.Platform.isMacOS) { if (Platform.isMacOS) {
printError('$command not found. $macInstructions'); printError('$command not found. $macInstructions');
} else { } else {
printError('Cannot control iOS devices or simulators. $command is not available on your platform.'); printError('Cannot control iOS devices or simulators. $command is not available on your platform.');
...@@ -313,7 +313,7 @@ class IOSDevice extends Device { ...@@ -313,7 +313,7 @@ class IOSDevice extends Device {
} }
Future<bool> pushFile(ApplicationPackage app, String localFile, String targetFile) async { Future<bool> pushFile(ApplicationPackage app, String localFile, String targetFile) async {
if (io.Platform.isMacOS) { if (Platform.isMacOS) {
runSync(<String>[ runSync(<String>[
pusherPath, pusherPath,
'-t', '-t',
...@@ -392,7 +392,7 @@ class _IOSDeviceLogReader extends DeviceLogReader { ...@@ -392,7 +392,7 @@ class _IOSDeviceLogReader extends DeviceLogReader {
final IOSDevice device; final IOSDevice device;
StreamController<String> _linesController; StreamController<String> _linesController;
io.Process _process; Process _process;
@override @override
Stream<String> get logLines => _linesController.stream; Stream<String> get logLines => _linesController.stream;
...@@ -401,7 +401,7 @@ class _IOSDeviceLogReader extends DeviceLogReader { ...@@ -401,7 +401,7 @@ class _IOSDeviceLogReader extends DeviceLogReader {
String get name => device.name; String get name => device.name;
void _start() { void _start() {
runCommand(<String>[device.loggerPath]).then((io.Process process) { runCommand(<String>[device.loggerPath]).then((Process process) {
_process = process; _process = process;
_process.stdout.transform(UTF8.decoder).transform(const LineSplitter()).listen(_onLine); _process.stdout.transform(UTF8.decoder).transform(const LineSplitter()).listen(_onLine);
_process.stderr.transform(UTF8.decoder).transform(const LineSplitter()).listen(_onLine); _process.stderr.transform(UTF8.decoder).transform(const LineSplitter()).listen(_onLine);
...@@ -445,7 +445,7 @@ class _IOSDevicePortForwarder extends DevicePortForwarder { ...@@ -445,7 +445,7 @@ class _IOSDevicePortForwarder extends DevicePortForwarder {
} }
// Usage: iproxy LOCAL_TCP_PORT DEVICE_TCP_PORT UDID // Usage: iproxy LOCAL_TCP_PORT DEVICE_TCP_PORT UDID
io.Process process = await runCommand(<String>[ Process process = await runCommand(<String>[
device.iproxyPath, device.iproxyPath,
hostPort.toString(), hostPort.toString(),
devicePort.toString(), devicePort.toString(),
...@@ -471,7 +471,7 @@ class _IOSDevicePortForwarder extends DevicePortForwarder { ...@@ -471,7 +471,7 @@ class _IOSDevicePortForwarder extends DevicePortForwarder {
printTrace("Unforwarding port $forwardedPort"); printTrace("Unforwarding port $forwardedPort");
io.Process process = forwardedPort.context; Process process = forwardedPort.context;
if (process != null) { if (process != null) {
processManager.killPid(process.pid); processManager.killPid(process.pid);
......
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:async'; import 'dart:async';
import 'dart:io';
import '../base/io.dart';
import '../base/os.dart'; import '../base/os.dart';
import '../base/process.dart'; import '../base/process.dart';
import '../doctor.dart'; import '../doctor.dart';
......
...@@ -4,13 +4,13 @@ ...@@ -4,13 +4,13 @@
import 'dart:async'; import 'dart:async';
import 'dart:convert' show JSON; import 'dart:convert' show JSON;
import 'dart:io' as io;
import 'package:path/path.dart' as path; import 'package:path/path.dart' as path;
import '../application_package.dart'; import '../application_package.dart';
import '../base/context.dart'; import '../base/context.dart';
import '../base/file_system.dart'; import '../base/file_system.dart';
import '../base/io.dart';
import '../base/process.dart'; import '../base/process.dart';
import '../base/process_manager.dart'; import '../base/process_manager.dart';
import '../build_info.dart'; import '../build_info.dart';
...@@ -41,7 +41,7 @@ class XCode { ...@@ -41,7 +41,7 @@ class XCode {
} else { } else {
try { try {
printTrace('xcrun clang'); printTrace('xcrun clang');
io.ProcessResult result = processManager.runSync('/usr/bin/xcrun', <String>['clang']); ProcessResult result = processManager.runSync('/usr/bin/xcrun', <String>['clang']);
if (result.stdout != null && result.stdout.contains('license')) if (result.stdout != null && result.stdout.contains('license'))
_eulaSigned = false; _eulaSigned = false;
...@@ -220,7 +220,7 @@ final RegExp _xcodeVersionRegExp = new RegExp(r'Xcode (\d+)\..*'); ...@@ -220,7 +220,7 @@ final RegExp _xcodeVersionRegExp = new RegExp(r'Xcode (\d+)\..*');
final String _xcodeRequirement = 'Xcode 7.0 or greater is required to develop for iOS.'; final String _xcodeRequirement = 'Xcode 7.0 or greater is required to develop for iOS.';
bool _checkXcodeVersion() { bool _checkXcodeVersion() {
if (!io.Platform.isMacOS) if (!Platform.isMacOS)
return false; return false;
try { try {
String version = runCheckedSync(<String>['xcodebuild', '-version']); String version = runCheckedSync(<String>['xcodebuild', '-version']);
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
import 'dart:async'; import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'dart:io' as io;
import 'dart:math' as math; import 'dart:math' as math;
import 'package:path/path.dart' as path; import 'package:path/path.dart' as path;
...@@ -13,6 +12,7 @@ import '../application_package.dart'; ...@@ -13,6 +12,7 @@ import '../application_package.dart';
import '../base/common.dart'; import '../base/common.dart';
import '../base/context.dart'; import '../base/context.dart';
import '../base/file_system.dart'; import '../base/file_system.dart';
import '../base/io.dart';
import '../base/process.dart'; import '../base/process.dart';
import '../base/process_manager.dart'; import '../base/process_manager.dart';
import '../build_info.dart'; import '../build_info.dart';
...@@ -31,7 +31,7 @@ class IOSSimulators extends PollingDeviceDiscovery { ...@@ -31,7 +31,7 @@ class IOSSimulators extends PollingDeviceDiscovery {
IOSSimulators() : super('IOSSimulators'); IOSSimulators() : super('IOSSimulators');
@override @override
bool get supportsPlatform => io.Platform.isMacOS; bool get supportsPlatform => Platform.isMacOS;
@override @override
List<Device> pollingGetDevices() => IOSSimulatorUtils.instance.getAttachedDevices(); List<Device> pollingGetDevices() => IOSSimulatorUtils.instance.getAttachedDevices();
...@@ -192,7 +192,7 @@ class SimControl { ...@@ -192,7 +192,7 @@ class SimControl {
List<String> args = <String>['simctl', 'list', '--json', section.name]; List<String> args = <String>['simctl', 'list', '--json', section.name];
printTrace('$_xcrunPath ${args.join(' ')}'); printTrace('$_xcrunPath ${args.join(' ')}');
io.ProcessResult results = processManager.runSync(_xcrunPath, args); ProcessResult results = processManager.runSync(_xcrunPath, args);
if (results.exitCode != 0) { if (results.exitCode != 0) {
printError('Error executing simctl: ${results.exitCode}\n${results.stderr}'); printError('Error executing simctl: ${results.exitCode}\n${results.stderr}');
return <String, Map<String, dynamic>>{}; return <String, Map<String, dynamic>>{};
...@@ -359,7 +359,7 @@ class IOSSimulator extends Device { ...@@ -359,7 +359,7 @@ class IOSSimulator extends Device {
@override @override
bool isSupported() { bool isSupported() {
if (!io.Platform.isMacOS) { if (!Platform.isMacOS) {
_supportMessage = "Not supported on a non Mac host"; _supportMessage = "Not supported on a non Mac host";
return false; return false;
} }
...@@ -531,7 +531,7 @@ class IOSSimulator extends Device { ...@@ -531,7 +531,7 @@ class IOSSimulator extends Device {
Future<bool> pushFile( Future<bool> pushFile(
ApplicationPackage app, String localFile, String targetFile) async { ApplicationPackage app, String localFile, String targetFile) async {
if (io.Platform.isMacOS) { if (Platform.isMacOS) {
String simulatorHomeDirectory = _getSimulatorAppHomeDirectory(app); String simulatorHomeDirectory = _getSimulatorAppHomeDirectory(app);
runCheckedSync(<String>['cp', localFile, path.join(simulatorHomeDirectory, targetFile)]); runCheckedSync(<String>['cp', localFile, path.join(simulatorHomeDirectory, targetFile)]);
return true; return true;
...@@ -640,8 +640,8 @@ class _IOSSimulatorLogReader extends DeviceLogReader { ...@@ -640,8 +640,8 @@ class _IOSSimulatorLogReader extends DeviceLogReader {
StreamController<String> _linesController; StreamController<String> _linesController;
// We log from two files: the device and the system log. // We log from two files: the device and the system log.
io.Process _deviceProcess; Process _deviceProcess;
io.Process _systemProcess; Process _systemProcess;
@override @override
Stream<String> get logLines => _linesController.stream; Stream<String> get logLines => _linesController.stream;
......
...@@ -3,13 +3,13 @@ ...@@ -3,13 +3,13 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:async'; import 'dart:async';
import 'dart:io' as io;
import 'package:meta/meta.dart'; import 'package:meta/meta.dart';
import 'package:path/path.dart' as path; import 'package:path/path.dart' as path;
import 'application_package.dart'; import 'application_package.dart';
import 'base/file_system.dart'; import 'base/file_system.dart';
import 'base/io.dart';
import 'base/logger.dart'; import 'base/logger.dart';
import 'build_info.dart'; import 'build_info.dart';
import 'device.dart'; import 'device.dart';
...@@ -78,12 +78,12 @@ abstract class ResidentRunner { ...@@ -78,12 +78,12 @@ abstract class ResidentRunner {
} }
void registerSignalHandlers() { void registerSignalHandlers() {
io.ProcessSignal.SIGINT.watch().listen((io.ProcessSignal signal) async { ProcessSignal.SIGINT.watch().listen((ProcessSignal signal) async {
_resetTerminal(); _resetTerminal();
await cleanupAfterSignal(); await cleanupAfterSignal();
exit(0); exit(0);
}); });
io.ProcessSignal.SIGTERM.watch().listen((io.ProcessSignal signal) async { ProcessSignal.SIGTERM.watch().listen((ProcessSignal signal) async {
_resetTerminal(); _resetTerminal();
await cleanupAfterSignal(); await cleanupAfterSignal();
exit(0); exit(0);
...@@ -92,19 +92,19 @@ abstract class ResidentRunner { ...@@ -92,19 +92,19 @@ abstract class ResidentRunner {
return; return;
if (!supportsRestart) if (!supportsRestart)
return; return;
io.ProcessSignal.SIGUSR1.watch().listen(_handleSignal); ProcessSignal.SIGUSR1.watch().listen(_handleSignal);
io.ProcessSignal.SIGUSR2.watch().listen(_handleSignal); ProcessSignal.SIGUSR2.watch().listen(_handleSignal);
} }
bool _processingSignal = false; bool _processingSignal = false;
Future<Null> _handleSignal(io.ProcessSignal signal) async { Future<Null> _handleSignal(ProcessSignal signal) async {
if (_processingSignal) { if (_processingSignal) {
printTrace('Ignoring signal: "$signal" because we are busy.'); printTrace('Ignoring signal: "$signal" because we are busy.');
return; return;
} }
_processingSignal = true; _processingSignal = true;
final bool fullRestart = signal == io.ProcessSignal.SIGUSR2; final bool fullRestart = signal == ProcessSignal.SIGUSR2;
try { try {
await restart(fullRestart: fullRestart); await restart(fullRestart: fullRestart);
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:async'; import 'dart:async';
import 'dart:io' as io;
import 'package:args/args.dart'; import 'package:args/args.dart';
import 'package:args/command_runner.dart'; import 'package:args/command_runner.dart';
...@@ -13,6 +12,7 @@ import '../android/android_sdk.dart'; ...@@ -13,6 +12,7 @@ import '../android/android_sdk.dart';
import '../base/common.dart'; import '../base/common.dart';
import '../base/context.dart'; import '../base/context.dart';
import '../base/file_system.dart'; import '../base/file_system.dart';
import '../base/io.dart';
import '../base/logger.dart'; import '../base/logger.dart';
import '../base/process.dart'; import '../base/process.dart';
import '../base/process_manager.dart'; import '../base/process_manager.dart';
...@@ -118,12 +118,12 @@ class FlutterCommandRunner extends CommandRunner<Null> { ...@@ -118,12 +118,12 @@ class FlutterCommandRunner extends CommandRunner<Null> {
} }
static String get _defaultFlutterRoot { static String get _defaultFlutterRoot {
if (io.Platform.environment.containsKey(kFlutterRootEnvironmentVariableName)) if (Platform.environment.containsKey(kFlutterRootEnvironmentVariableName))
return io.Platform.environment[kFlutterRootEnvironmentVariableName]; return Platform.environment[kFlutterRootEnvironmentVariableName];
try { try {
if (io.Platform.script.scheme == 'data') if (Platform.script.scheme == 'data')
return '../..'; // we're running as a test return '../..'; // we're running as a test
String script = io.Platform.script.toFilePath(); String script = Platform.script.toFilePath();
if (path.basename(script) == kSnapshotFileName) if (path.basename(script) == kSnapshotFileName)
return path.dirname(path.dirname(path.dirname(script))); return path.dirname(path.dirname(path.dirname(script)));
if (path.basename(script) == kFlutterToolsScriptFileName) if (path.basename(script) == kFlutterToolsScriptFileName)
...@@ -192,7 +192,7 @@ class FlutterCommandRunner extends CommandRunner<Null> { ...@@ -192,7 +192,7 @@ class FlutterCommandRunner extends CommandRunner<Null> {
// enginePath's initialiser uses it). // enginePath's initialiser uses it).
Cache.flutterRoot = path.normalize(path.absolute(globalResults['flutter-root'])); Cache.flutterRoot = path.normalize(path.absolute(globalResults['flutter-root']));
if (io.Platform.environment['FLUTTER_ALREADY_LOCKED'] != 'true') if (Platform.environment['FLUTTER_ALREADY_LOCKED'] != 'true')
await Cache.lock(); await Cache.lock();
if (globalResults['suppress-analytics']) if (globalResults['suppress-analytics'])
...@@ -232,7 +232,7 @@ class FlutterCommandRunner extends CommandRunner<Null> { ...@@ -232,7 +232,7 @@ class FlutterCommandRunner extends CommandRunner<Null> {
} }
String _findEnginePath(ArgResults globalResults) { String _findEnginePath(ArgResults globalResults) {
String engineSourcePath = globalResults['local-engine-src-path'] ?? io.Platform.environment[kFlutterEngineEnvironmentVariableName]; String engineSourcePath = globalResults['local-engine-src-path'] ?? Platform.environment[kFlutterEngineEnvironmentVariableName];
if (engineSourcePath == null && globalResults['local-engine'] != null) { if (engineSourcePath == null && globalResults['local-engine'] != null) {
try { try {
......
...@@ -3,11 +3,12 @@ ...@@ -3,11 +3,12 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:async'; import 'dart:async';
import 'dart:io';
import 'package:coverage/coverage.dart'; import 'package:coverage/coverage.dart';
import 'package:path/path.dart' as path; import 'package:path/path.dart' as path;
import '../base/file_system.dart';
import '../base/io.dart';
import '../dart/package_map.dart'; import '../dart/package_map.dart';
import '../globals.dart'; import '../globals.dart';
...@@ -67,7 +68,7 @@ class CoverageCollector { ...@@ -67,7 +68,7 @@ class CoverageCollector {
return null; return null;
if (formatter == null) { if (formatter == null) {
Resolver resolver = new Resolver(packagesPath: PackageMap.globalPackagesPath); Resolver resolver = new Resolver(packagesPath: PackageMap.globalPackagesPath);
String packagePath = Directory.current.path; String packagePath = fs.currentDirectory.path;
List<String> reportOn = <String>[path.join(packagePath, 'lib')]; List<String> reportOn = <String>[path.join(packagePath, 'lib')];
formatter = new LcovFormatter(resolver, reportOn: reportOn, basePath: packagePath); formatter = new LcovFormatter(resolver, reportOn: reportOn, basePath: packagePath);
} }
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
import 'dart:async'; import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'dart:io' as io;
import 'dart:math' as math; import 'dart:math' as math;
import 'package:path/path.dart' as path; import 'package:path/path.dart' as path;
...@@ -15,13 +14,14 @@ import 'package:test/src/runner/plugin/platform.dart'; // ignore: implementation ...@@ -15,13 +14,14 @@ import 'package:test/src/runner/plugin/platform.dart'; // ignore: implementation
import 'package:test/src/runner/plugin/hack_register_platform.dart' as hack; // ignore: implementation_imports import 'package:test/src/runner/plugin/hack_register_platform.dart' as hack; // ignore: implementation_imports
import '../base/file_system.dart'; import '../base/file_system.dart';
import '../base/io.dart';
import '../base/process_manager.dart'; import '../base/process_manager.dart';
import '../dart/package_map.dart'; import '../dart/package_map.dart';
import '../globals.dart'; import '../globals.dart';
import 'coverage_collector.dart'; import 'coverage_collector.dart';
const Duration _kTestStartupTimeout = const Duration(seconds: 5); const Duration _kTestStartupTimeout = const Duration(seconds: 5);
final io.InternetAddress _kHost = io.InternetAddress.LOOPBACK_IP_V4; final InternetAddress _kHost = InternetAddress.LOOPBACK_IP_V4;
void installHook({ String shellPath }) { void installHook({ String shellPath }) {
hack.registerPlatformPlugin(<TestPlatform>[TestPlatform.vm], () => new FlutterPlatform(shellPath: shellPath)); hack.registerPlatformPlugin(<TestPlatform>[TestPlatform.vm], () => new FlutterPlatform(shellPath: shellPath));
...@@ -62,11 +62,11 @@ class FlutterPlatform extends PlatformPlugin { ...@@ -62,11 +62,11 @@ class FlutterPlatform extends PlatformPlugin {
controller.sink.done.then((_) { controllerSinkClosed = true; }); controller.sink.done.then((_) { controllerSinkClosed = true; });
// Prepare our WebSocket server to talk to the engine subproces. // Prepare our WebSocket server to talk to the engine subproces.
io.HttpServer server = await io.HttpServer.bind(_kHost, 0); HttpServer server = await HttpServer.bind(_kHost, 0);
finalizers.add(() async { await server.close(force: true); }); finalizers.add(() async { await server.close(force: true); });
Completer<io.WebSocket> webSocket = new Completer<io.WebSocket>(); Completer<WebSocket> webSocket = new Completer<WebSocket>();
server.listen((io.HttpRequest request) { server.listen((HttpRequest request) {
webSocket.complete(io.WebSocketTransformer.upgrade(request)); webSocket.complete(WebSocketTransformer.upgrade(request));
}); });
// Prepare a temporary directory to store the Dart file that will talk to us. // Prepare a temporary directory to store the Dart file that will talk to us.
...@@ -91,7 +91,7 @@ class FlutterPlatform extends PlatformPlugin { ...@@ -91,7 +91,7 @@ class FlutterPlatform extends PlatformPlugin {
} }
// Start the engine subprocess. // Start the engine subprocess.
io.Process process = await _startProcess( Process process = await _startProcess(
shellPath, shellPath,
listenerFile.path, listenerFile.path,
packages: PackageMap.globalPackagesPath, packages: PackageMap.globalPackagesPath,
...@@ -120,7 +120,7 @@ class FlutterPlatform extends PlatformPlugin { ...@@ -120,7 +120,7 @@ class FlutterPlatform extends PlatformPlugin {
_InitialResult initialResult = await Future.any(<Future<_InitialResult>>[ _InitialResult initialResult = await Future.any(<Future<_InitialResult>>[
process.exitCode.then<_InitialResult>((int exitCode) { return _InitialResult.crashed; }), process.exitCode.then<_InitialResult>((int exitCode) { return _InitialResult.crashed; }),
new Future<_InitialResult>.delayed(_kTestStartupTimeout, () { return _InitialResult.timedOut; }), new Future<_InitialResult>.delayed(_kTestStartupTimeout, () { return _InitialResult.timedOut; }),
webSocket.future.then<_InitialResult>((io.WebSocket webSocket) { return _InitialResult.connected; }), webSocket.future.then<_InitialResult>((WebSocket webSocket) { return _InitialResult.connected; }),
]); ]);
switch (initialResult) { switch (initialResult) {
...@@ -138,7 +138,7 @@ class FlutterPlatform extends PlatformPlugin { ...@@ -138,7 +138,7 @@ class FlutterPlatform extends PlatformPlugin {
await controller.sink.done; await controller.sink.done;
break; break;
case _InitialResult.connected: case _InitialResult.connected:
io.WebSocket testSocket = await webSocket.future; WebSocket testSocket = await webSocket.future;
Completer<Null> harnessDone = new Completer<Null>(); Completer<Null> harnessDone = new Completer<Null>();
StreamSubscription<dynamic> harnessToTest = controller.stream.listen( StreamSubscription<dynamic> harnessToTest = controller.stream.listen(
...@@ -213,7 +213,7 @@ class FlutterPlatform extends PlatformPlugin { ...@@ -213,7 +213,7 @@ class FlutterPlatform extends PlatformPlugin {
}) { }) {
return ''' return '''
import 'dart:convert'; import 'dart:convert';
import 'dart:io'; import 'dart:io'; // ignore: dart_io_import
import 'package:stream_channel/stream_channel.dart'; import 'package:stream_channel/stream_channel.dart';
import 'package:test/src/runner/plugin/remote_platform_helpers.dart'; import 'package:test/src/runner/plugin/remote_platform_helpers.dart';
...@@ -257,7 +257,7 @@ void main() { ...@@ -257,7 +257,7 @@ void main() {
} }
Future<io.Process> _startProcess(String executable, String testPath, { String packages, int observatoryPort }) { Future<Process> _startProcess(String executable, String testPath, { String packages, int observatoryPort }) {
assert(executable != null); // Please provide the path to the shell in the SKY_SHELL environment variable. assert(executable != null); // Please provide the path to the shell in the SKY_SHELL environment variable.
List<String> arguments = <String>[]; List<String> arguments = <String>[];
if (observatoryPort != null) { if (observatoryPort != null) {
...@@ -280,7 +280,7 @@ void main() { ...@@ -280,7 +280,7 @@ void main() {
return processManager.start(executable, arguments, environment: environment); return processManager.start(executable, arguments, environment: environment);
} }
void _pipeStandardStreamsToConsole(io.Process process) { void _pipeStandardStreamsToConsole(Process process) {
for (Stream<List<int>> stream in for (Stream<List<int>> stream in
<Stream<List<int>>>[process.stderr, process.stdout]) { <Stream<List<int>>>[process.stderr, process.stdout]) {
stream.transform(UTF8.decoder) stream.transform(UTF8.decoder)
......
...@@ -2,8 +2,7 @@ ...@@ -2,8 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:io'; import 'base/io.dart';
import 'base/process.dart'; import 'base/process.dart';
import 'base/process_manager.dart'; import 'base/process_manager.dart';
import 'cache.dart'; import 'cache.dart';
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
import 'dart:async'; import 'dart:async';
import 'dart:convert' show BASE64; import 'dart:convert' show BASE64;
import 'dart:io';
import 'package:json_rpc_2/json_rpc_2.dart' as rpc; import 'package:json_rpc_2/json_rpc_2.dart' as rpc;
import 'package:json_rpc_2/error_code.dart' as rpc_error_code; import 'package:json_rpc_2/error_code.dart' as rpc_error_code;
...@@ -12,6 +11,7 @@ import 'package:path/path.dart' as path; ...@@ -12,6 +11,7 @@ import 'package:path/path.dart' as path;
import 'package:stream_channel/stream_channel.dart'; import 'package:stream_channel/stream_channel.dart';
import 'package:web_socket_channel/io.dart'; import 'package:web_socket_channel/io.dart';
import 'base/io.dart';
import 'globals.dart'; import 'globals.dart';
/// The default VM service request timeout. /// The default VM service request timeout.
......
...@@ -2,9 +2,8 @@ ...@@ -2,9 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:io';
import 'package:args/command_runner.dart'; import 'package:args/command_runner.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/create.dart'; import 'package:flutter_tools/src/commands/create.dart';
import 'package:flutter_tools/src/commands/config.dart'; import 'package:flutter_tools/src/commands/config.dart';
...@@ -21,7 +20,7 @@ void main() { ...@@ -21,7 +20,7 @@ void main() {
setUp(() { setUp(() {
Cache.flutterRoot = '../..'; Cache.flutterRoot = '../..';
temp = Directory.systemTemp.createTempSync('flutter_tools'); temp = fs.systemTempDirectory.createTempSync('flutter_tools');
}); });
tearDown(() { tearDown(() {
......
...@@ -2,8 +2,7 @@ ...@@ -2,8 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:io'; import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/analyze_base.dart'; import 'package:flutter_tools/src/commands/analyze_base.dart';
import 'package:flutter_tools/src/runner/flutter_command_runner.dart'; import 'package:flutter_tools/src/runner/flutter_command_runner.dart';
...@@ -17,7 +16,7 @@ void main() { ...@@ -17,7 +16,7 @@ void main() {
setUp(() { setUp(() {
FlutterCommandRunner.initFlutterRoot(); FlutterCommandRunner.initFlutterRoot();
tempDir = Directory.systemTemp.createTempSync('analysis_test'); tempDir = fs.systemTempDirectory.createTempSync('analysis_test');
}); });
tearDown(() { tearDown(() {
...@@ -33,16 +32,16 @@ void main() { ...@@ -33,16 +32,16 @@ void main() {
expect(inRepo(<String>[Cache.flutterRoot]), isTrue); expect(inRepo(<String>[Cache.flutterRoot]), isTrue);
expect(inRepo(<String>[path.join(Cache.flutterRoot, 'foo')]), isTrue); expect(inRepo(<String>[path.join(Cache.flutterRoot, 'foo')]), isTrue);
// Relative paths // Relative paths
String oldWorkingDirectory = path.current; String oldWorkingDirectory = fs.currentDirectory.path;
try { try {
Directory.current = Cache.flutterRoot; fs.currentDirectory = Cache.flutterRoot;
expect(inRepo(<String>['.']), isTrue); expect(inRepo(<String>['.']), isTrue);
expect(inRepo(<String>['foo']), isTrue); expect(inRepo(<String>['foo']), isTrue);
Directory.current = tempDir.path; fs.currentDirectory = tempDir.path;
expect(inRepo(<String>['.']), isFalse); expect(inRepo(<String>['.']), isFalse);
expect(inRepo(<String>['foo']), isFalse); expect(inRepo(<String>['foo']), isFalse);
} finally { } finally {
Directory.current = oldWorkingDirectory; fs.currentDirectory = oldWorkingDirectory;
} }
// Ensure no exceptions // Ensure no exceptions
inRepo(null); inRepo(null);
......
...@@ -4,11 +4,11 @@ ...@@ -4,11 +4,11 @@
import 'dart:async'; import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'dart:io' as io;
import 'package:args/command_runner.dart'; import 'package:args/command_runner.dart';
import 'package:flutter_tools/src/base/common.dart'; import 'package:flutter_tools/src/base/common.dart';
import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/create.dart'; import 'package:flutter_tools/src/commands/create.dart';
import 'package:flutter_tools/src/dart/sdk.dart'; import 'package:flutter_tools/src/dart/sdk.dart';
...@@ -56,7 +56,7 @@ void main() { ...@@ -56,7 +56,7 @@ void main() {
if (file is File && file.path.endsWith('.dart')) { if (file is File && file.path.endsWith('.dart')) {
String original= file.readAsStringSync(); String original= file.readAsStringSync();
io.Process process = await io.Process.start( Process process = await Process.start(
sdkBinaryName('dartfmt'), sdkBinaryName('dartfmt'),
<String>[file.path], <String>[file.path],
workingDirectory: temp.path, workingDirectory: temp.path,
...@@ -126,7 +126,7 @@ Future<Null> _createAndAnalyzeProject(Directory dir, List<String> createArgs) as ...@@ -126,7 +126,7 @@ Future<Null> _createAndAnalyzeProject(Directory dir, List<String> createArgs) as
String mainPath = path.join(dir.path, 'lib', 'main.dart'); String mainPath = path.join(dir.path, 'lib', 'main.dart');
expect(fs.file(mainPath).existsSync(), true); expect(fs.file(mainPath).existsSync(), true);
String flutterToolsPath = path.absolute(path.join('bin', 'flutter_tools.dart')); String flutterToolsPath = path.absolute(path.join('bin', 'flutter_tools.dart'));
io.ProcessResult exec = io.Process.runSync( ProcessResult exec = Process.runSync(
'$dartSdkPath/bin/dart', <String>[flutterToolsPath, 'analyze'], '$dartSdkPath/bin/dart', <String>[flutterToolsPath, 'analyze'],
workingDirectory: dir.path workingDirectory: dir.path
); );
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:async'; import 'dart:async';
import 'dart:io';
import 'package:flutter_tools/src/base/context.dart'; import 'package:flutter_tools/src/base/context.dart';
import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/base/logger.dart'; import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/commands/daemon.dart'; import 'package:flutter_tools/src/commands/daemon.dart';
import 'package:flutter_tools/src/device.dart'; import 'package:flutter_tools/src/device.dart';
......
...@@ -2,8 +2,7 @@ ...@@ -2,8 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:io'; import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/dart/dependencies.dart'; import 'package:flutter_tools/src/dart/dependencies.dart';
import 'package:path/path.dart' as path; import 'package:path/path.dart' as path;
import 'package:test/test.dart'; import 'package:test/test.dart';
......
...@@ -2,8 +2,7 @@ ...@@ -2,8 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:io'; import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/dart/dependencies.dart'; import 'package:flutter_tools/src/dart/dependencies.dart';
import 'package:flutter_tools/src/dependency_checker.dart'; import 'package:flutter_tools/src/dependency_checker.dart';
import 'package:path/path.dart' as path; import 'package:path/path.dart' as path;
......
...@@ -8,6 +8,7 @@ import 'package:file/memory.dart'; ...@@ -8,6 +8,7 @@ import 'package:file/memory.dart';
import 'package:flutter_tools/src/android/android_device.dart'; import 'package:flutter_tools/src/android/android_device.dart';
import 'package:flutter_tools/src/base/common.dart'; import 'package:flutter_tools/src/base/common.dart';
import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/base/os.dart'; import 'package:flutter_tools/src/base/os.dart';
import 'package:flutter_tools/src/commands/drive.dart'; import 'package:flutter_tools/src/commands/drive.dart';
import 'package:flutter_tools/src/device.dart'; import 'package:flutter_tools/src/device.dart';
......
...@@ -2,9 +2,8 @@ ...@@ -2,9 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:io' as io;
import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/base/os.dart'; import 'package:flutter_tools/src/base/os.dart';
import 'package:path/path.dart' as path; import 'package:path/path.dart' as path;
import 'package:test/test.dart'; import 'package:test/test.dart';
...@@ -29,7 +28,7 @@ void main() { ...@@ -29,7 +28,7 @@ void main() {
os.makeExecutable(file); os.makeExecutable(file);
// Skip this test on windows. // Skip this test on windows.
if (!io.Platform.isWindows) { if (!Platform.isWindows) {
String mode = file.statSync().modeString(); String mode = file.statSync().modeString();
// rwxr--r-- // rwxr--r--
expect(mode.substring(0, 3), endsWith('x')); expect(mode.substring(0, 3), endsWith('x'));
......
...@@ -4,11 +4,11 @@ ...@@ -4,11 +4,11 @@
import 'dart:async'; import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'dart:io' as io;
import 'package:archive/archive.dart'; import 'package:archive/archive.dart';
import 'package:flutter_tools/src/base/context.dart'; import 'package:flutter_tools/src/base/context.dart';
import 'package:flutter_tools/src/base/file_system.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/logger.dart';
import 'package:flutter_tools/src/base/os.dart'; import 'package:flutter_tools/src/base/os.dart';
import 'package:flutter_tools/src/base/process.dart'; import 'package:flutter_tools/src/base/process.dart';
...@@ -42,7 +42,7 @@ void main() { ...@@ -42,7 +42,7 @@ void main() {
}); });
test('start', () async { test('start', () async {
io.Process process = await manager.start('echo', <String>['foo']); Process process = await manager.start('echo', <String>['foo']);
int pid = process.pid; int pid = process.pid;
int exitCode = await process.exitCode; int exitCode = await process.exitCode;
List<int> stdout = await _consume(process.stdout); List<int> stdout = await _consume(process.stdout);
...@@ -64,7 +64,7 @@ void main() { ...@@ -64,7 +64,7 @@ void main() {
}); });
test('run', () async { test('run', () async {
io.ProcessResult result = await manager.run('echo', <String>['bar']); ProcessResult result = await manager.run('echo', <String>['bar']);
int pid = result.pid; int pid = result.pid;
int exitCode = result.exitCode; int exitCode = result.exitCode;
String stdout = result.stdout; String stdout = result.stdout;
...@@ -86,7 +86,7 @@ void main() { ...@@ -86,7 +86,7 @@ void main() {
}); });
test('runSync', () async { test('runSync', () async {
io.ProcessResult result = manager.runSync('echo', <String>['baz']); ProcessResult result = manager.runSync('echo', <String>['baz']);
int pid = result.pid; int pid = result.pid;
int exitCode = result.exitCode; int exitCode = result.exitCode;
String stdout = result.stdout; String stdout = result.stdout;
...@@ -124,7 +124,7 @@ void main() { ...@@ -124,7 +124,7 @@ void main() {
}); });
test('start', () async { test('start', () async {
io.Process process = await manager.start('sing', <String>['ppap']); Process process = await manager.start('sing', <String>['ppap']);
int exitCode = await process.exitCode; int exitCode = await process.exitCode;
List<int> stdout = await _consume(process.stdout); List<int> stdout = await _consume(process.stdout);
List<int> stderr = await _consume(process.stderr); List<int> stderr = await _consume(process.stderr);
...@@ -135,7 +135,7 @@ void main() { ...@@ -135,7 +135,7 @@ void main() {
}); });
test('run', () async { test('run', () async {
io.ProcessResult result = await manager.run('dance', <String>['gangnam-style']); ProcessResult result = await manager.run('dance', <String>['gangnam-style']);
expect(result.pid, 101); expect(result.pid, 101);
expect(result.exitCode, 2); expect(result.exitCode, 2);
expect(result.stdout, ''); expect(result.stdout, '');
...@@ -143,7 +143,7 @@ void main() { ...@@ -143,7 +143,7 @@ void main() {
}); });
test('runSync', () { test('runSync', () {
io.ProcessResult result = manager.runSync('dance', <String>['gangnam-style']); ProcessResult result = manager.runSync('dance', <String>['gangnam-style']);
expect(result.pid, 101); expect(result.pid, 101);
expect(result.exitCode, 2); expect(result.exitCode, 2);
expect(result.stdout, ''); expect(result.stdout, '');
...@@ -196,7 +196,7 @@ class _Recording { ...@@ -196,7 +196,7 @@ class _Recording {
Encoding encoding; Encoding encoding;
if (encodingName != null) if (encodingName != null)
encoding = encodingName == 'system' encoding = encodingName == 'system'
? const io.SystemEncoding() ? SYSTEM_ENCODING
: Encoding.getByName(encodingName); : Encoding.getByName(encodingName);
return _getFileContent('$basename.$type', encoding); return _getFileContent('$basename.$type', encoding);
} }
......
...@@ -3,11 +3,11 @@ ...@@ -3,11 +3,11 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:async'; import 'dart:async';
import 'dart:io';
import 'package:flutter_tools/src/base/config.dart'; import 'package:flutter_tools/src/base/config.dart';
import 'package:flutter_tools/src/base/context.dart'; import 'package:flutter_tools/src/base/context.dart';
import 'package:flutter_tools/src/base/file_system.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/logger.dart';
import 'package:flutter_tools/src/base/os.dart'; import 'package:flutter_tools/src/base/os.dart';
import 'package:flutter_tools/src/base/process_manager.dart'; import 'package:flutter_tools/src/base/process_manager.dart';
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:async'; import 'dart:async';
import 'dart:io' as io;
import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/dart/sdk.dart'; import 'package:flutter_tools/src/dart/sdk.dart';
import 'package:path/path.dart' as path; import 'package:path/path.dart' as path;
...@@ -36,7 +36,7 @@ Future<Null> _testFile(String testName, int wantedExitCode) async { ...@@ -36,7 +36,7 @@ Future<Null> _testFile(String testName, int wantedExitCode) async {
final String fullTestExpectation = path.join(manualTestsDirectory, 'flutter_test', '${testName}_expectation.txt'); final String fullTestExpectation = path.join(manualTestsDirectory, 'flutter_test', '${testName}_expectation.txt');
final File expectationFile = fs.file(fullTestExpectation); final File expectationFile = fs.file(fullTestExpectation);
expect(expectationFile.existsSync(), true); expect(expectationFile.existsSync(), true);
final io.ProcessResult exec = await io.Process.run( final ProcessResult exec = await Process.run(
path.join(dartSdkPath, 'bin', 'dart'), path.join(dartSdkPath, 'bin', 'dart'),
<String>[ <String>[
path.absolute(path.join('bin', 'flutter_tools.dart')), path.absolute(path.join('bin', 'flutter_tools.dart')),
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:async'; import 'dart:async';
import 'dart:io';
import 'package:args/command_runner.dart'; import 'package:args/command_runner.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/os.dart'; import 'package:flutter_tools/src/base/os.dart';
import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/create.dart'; import 'package:flutter_tools/src/commands/create.dart';
...@@ -40,7 +40,7 @@ void main() { ...@@ -40,7 +40,7 @@ void main() {
Directory temp; Directory temp;
setUp(() async { setUp(() async {
temp = Directory.systemTemp.createTempSync('flutter_tools'); temp = fs.systemTempDirectory.createTempSync('flutter_tools');
}); });
tearDown(() { tearDown(() {
......
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
import 'dart:async'; import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'dart:io';
import 'package:flutter_tools/src/base/io.dart';
Process daemon; Process daemon;
......
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