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.
This commit is contained in:
@@ -2,9 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:io';
|
||||
|
||||
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/commands/create.dart';
|
||||
import 'package:flutter_tools/src/commands/config.dart';
|
||||
@@ -21,7 +20,7 @@ void main() {
|
||||
|
||||
setUp(() {
|
||||
Cache.flutterRoot = '../..';
|
||||
temp = Directory.systemTemp.createTempSync('flutter_tools');
|
||||
temp = fs.systemTempDirectory.createTempSync('flutter_tools');
|
||||
});
|
||||
|
||||
tearDown(() {
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// 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/commands/analyze_base.dart';
|
||||
import 'package:flutter_tools/src/runner/flutter_command_runner.dart';
|
||||
@@ -17,7 +16,7 @@ void main() {
|
||||
|
||||
setUp(() {
|
||||
FlutterCommandRunner.initFlutterRoot();
|
||||
tempDir = Directory.systemTemp.createTempSync('analysis_test');
|
||||
tempDir = fs.systemTempDirectory.createTempSync('analysis_test');
|
||||
});
|
||||
|
||||
tearDown(() {
|
||||
@@ -33,16 +32,16 @@ void main() {
|
||||
expect(inRepo(<String>[Cache.flutterRoot]), isTrue);
|
||||
expect(inRepo(<String>[path.join(Cache.flutterRoot, 'foo')]), isTrue);
|
||||
// Relative paths
|
||||
String oldWorkingDirectory = path.current;
|
||||
String oldWorkingDirectory = fs.currentDirectory.path;
|
||||
try {
|
||||
Directory.current = Cache.flutterRoot;
|
||||
fs.currentDirectory = Cache.flutterRoot;
|
||||
expect(inRepo(<String>['.']), isTrue);
|
||||
expect(inRepo(<String>['foo']), isTrue);
|
||||
Directory.current = tempDir.path;
|
||||
fs.currentDirectory = tempDir.path;
|
||||
expect(inRepo(<String>['.']), isFalse);
|
||||
expect(inRepo(<String>['foo']), isFalse);
|
||||
} finally {
|
||||
Directory.current = oldWorkingDirectory;
|
||||
fs.currentDirectory = oldWorkingDirectory;
|
||||
}
|
||||
// Ensure no exceptions
|
||||
inRepo(null);
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io' as io;
|
||||
|
||||
import 'package:args/command_runner.dart';
|
||||
import 'package:flutter_tools/src/base/common.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/base/io.dart';
|
||||
import 'package:flutter_tools/src/cache.dart';
|
||||
import 'package:flutter_tools/src/commands/create.dart';
|
||||
import 'package:flutter_tools/src/dart/sdk.dart';
|
||||
@@ -56,7 +56,7 @@ void main() {
|
||||
if (file is File && file.path.endsWith('.dart')) {
|
||||
String original= file.readAsStringSync();
|
||||
|
||||
io.Process process = await io.Process.start(
|
||||
Process process = await Process.start(
|
||||
sdkBinaryName('dartfmt'),
|
||||
<String>[file.path],
|
||||
workingDirectory: temp.path,
|
||||
@@ -126,7 +126,7 @@ Future<Null> _createAndAnalyzeProject(Directory dir, List<String> createArgs) as
|
||||
String mainPath = path.join(dir.path, 'lib', 'main.dart');
|
||||
expect(fs.file(mainPath).existsSync(), true);
|
||||
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'],
|
||||
workingDirectory: dir.path
|
||||
);
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
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/commands/daemon.dart';
|
||||
import 'package:flutter_tools/src/device.dart';
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// 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:path/path.dart' as path;
|
||||
import 'package:test/test.dart';
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// 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/dependency_checker.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
@@ -8,6 +8,7 @@ import 'package:file/memory.dart';
|
||||
import 'package:flutter_tools/src/android/android_device.dart';
|
||||
import 'package:flutter_tools/src/base/common.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/base/io.dart';
|
||||
import 'package:flutter_tools/src/base/os.dart';
|
||||
import 'package:flutter_tools/src/commands/drive.dart';
|
||||
import 'package:flutter_tools/src/device.dart';
|
||||
|
||||
@@ -2,9 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// 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/io.dart';
|
||||
import 'package:flutter_tools/src/base/os.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
import 'package:test/test.dart';
|
||||
@@ -29,7 +28,7 @@ void main() {
|
||||
os.makeExecutable(file);
|
||||
|
||||
// Skip this test on windows.
|
||||
if (!io.Platform.isWindows) {
|
||||
if (!Platform.isWindows) {
|
||||
String mode = file.statSync().modeString();
|
||||
// rwxr--r--
|
||||
expect(mode.substring(0, 3), endsWith('x'));
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io' as io;
|
||||
|
||||
import 'package:archive/archive.dart';
|
||||
import 'package:flutter_tools/src/base/context.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/os.dart';
|
||||
import 'package:flutter_tools/src/base/process.dart';
|
||||
@@ -42,7 +42,7 @@ void main() {
|
||||
});
|
||||
|
||||
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 exitCode = await process.exitCode;
|
||||
List<int> stdout = await _consume(process.stdout);
|
||||
@@ -64,7 +64,7 @@ void main() {
|
||||
});
|
||||
|
||||
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 exitCode = result.exitCode;
|
||||
String stdout = result.stdout;
|
||||
@@ -86,7 +86,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('runSync', () async {
|
||||
io.ProcessResult result = manager.runSync('echo', <String>['baz']);
|
||||
ProcessResult result = manager.runSync('echo', <String>['baz']);
|
||||
int pid = result.pid;
|
||||
int exitCode = result.exitCode;
|
||||
String stdout = result.stdout;
|
||||
@@ -124,7 +124,7 @@ void main() {
|
||||
});
|
||||
|
||||
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;
|
||||
List<int> stdout = await _consume(process.stdout);
|
||||
List<int> stderr = await _consume(process.stderr);
|
||||
@@ -135,7 +135,7 @@ void main() {
|
||||
});
|
||||
|
||||
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.exitCode, 2);
|
||||
expect(result.stdout, '');
|
||||
@@ -143,7 +143,7 @@ void main() {
|
||||
});
|
||||
|
||||
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.exitCode, 2);
|
||||
expect(result.stdout, '');
|
||||
@@ -196,7 +196,7 @@ class _Recording {
|
||||
Encoding encoding;
|
||||
if (encodingName != null)
|
||||
encoding = encodingName == 'system'
|
||||
? const io.SystemEncoding()
|
||||
? SYSTEM_ENCODING
|
||||
: Encoding.getByName(encodingName);
|
||||
return _getFileContent('$basename.$type', encoding);
|
||||
}
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter_tools/src/base/config.dart';
|
||||
import 'package:flutter_tools/src/base/context.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/os.dart';
|
||||
import 'package:flutter_tools/src/base/process_manager.dart';
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:io' as io;
|
||||
|
||||
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/dart/sdk.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
@@ -36,7 +36,7 @@ Future<Null> _testFile(String testName, int wantedExitCode) async {
|
||||
final String fullTestExpectation = path.join(manualTestsDirectory, 'flutter_test', '${testName}_expectation.txt');
|
||||
final File expectationFile = fs.file(fullTestExpectation);
|
||||
expect(expectationFile.existsSync(), true);
|
||||
final io.ProcessResult exec = await io.Process.run(
|
||||
final ProcessResult exec = await Process.run(
|
||||
path.join(dartSdkPath, 'bin', 'dart'),
|
||||
<String>[
|
||||
path.absolute(path.join('bin', 'flutter_tools.dart')),
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
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/cache.dart';
|
||||
import 'package:flutter_tools/src/commands/create.dart';
|
||||
@@ -40,7 +40,7 @@ void main() {
|
||||
Directory temp;
|
||||
|
||||
setUp(() async {
|
||||
temp = Directory.systemTemp.createTempSync('flutter_tools');
|
||||
temp = fs.systemTempDirectory.createTempSync('flutter_tools');
|
||||
});
|
||||
|
||||
tearDown(() {
|
||||
|
||||
Reference in New Issue
Block a user