diff --git a/examples/flutter_gallery/test_driver/transitions_perf_test.dart b/examples/flutter_gallery/test_driver/transitions_perf_test.dart index 2fafa7d89a..973cd67a69 100644 --- a/examples/flutter_gallery/test_driver/transitions_perf_test.dart +++ b/examples/flutter_gallery/test_driver/transitions_perf_test.dart @@ -6,7 +6,7 @@ import 'dart:async'; import 'dart:convert' show JsonEncoder; import 'package:file/file.dart'; -import 'package:file/io.dart'; +import 'package:file/local.dart'; import 'package:flutter_driver/flutter_driver.dart'; import 'package:path/path.dart' as path; import 'package:test/test.dart'; diff --git a/packages/flutter_driver/lib/src/common.dart b/packages/flutter_driver/lib/src/common.dart index 4268ab23d2..603cbfee56 100644 --- a/packages/flutter_driver/lib/src/common.dart +++ b/packages/flutter_driver/lib/src/common.dart @@ -5,7 +5,8 @@ import 'dart:io' show Platform; import 'package:file/file.dart'; -import 'package:file/io.dart'; +import 'package:file/local.dart'; +import 'package:file/memory.dart'; /// The file system implementation used by this library. /// diff --git a/packages/flutter_driver/pubspec.yaml b/packages/flutter_driver/pubspec.yaml index 4042a2d0bd..d81bfcc7b3 100644 --- a/packages/flutter_driver/pubspec.yaml +++ b/packages/flutter_driver/pubspec.yaml @@ -8,7 +8,7 @@ environment: sdk: '>=1.19.0 <2.0.0' dependencies: - file: '^0.1.0' + file: '^1.0.0' json_rpc_2: '^2.0.0' matcher: '>=0.12.0 <1.0.0' path: '^1.4.0' diff --git a/packages/flutter_tools/lib/src/base/file_system.dart b/packages/flutter_tools/lib/src/base/file_system.dart index 16cc449456..ded00802a8 100644 --- a/packages/flutter_tools/lib/src/base/file_system.dart +++ b/packages/flutter_tools/lib/src/base/file_system.dart @@ -4,28 +4,19 @@ import 'dart:io' as dart_io; -import 'package:file/io.dart'; -import 'package:file/sync_io.dart'; +import 'package:file/file.dart'; +import 'package:file/local.dart'; +import 'package:file/memory.dart'; import 'package:path/path.dart' as path; -export 'package:file/io.dart'; -export 'package:file/sync_io.dart'; +export 'package:file/file.dart'; +export 'package:file/local.dart'; /// Currently active implementation of the file system. /// /// By default it uses local disk-based implementation. Override this in tests /// with [MemoryFileSystem]. FileSystem fs = new LocalFileSystem(); -SyncFileSystem syncFs = new SyncLocalFileSystem(); - -typedef String CurrentDirectoryGetter(); - -final CurrentDirectoryGetter _defaultCurrentDirectoryGetter = () { - return dart_io.Directory.current.path; -}; - -/// Points to the current working directory (like `pwd`). -CurrentDirectoryGetter getCurrentDirectory = _defaultCurrentDirectoryGetter; /// Exits the process with the given [exitCode]. typedef void ExitFunction([int exitCode]); @@ -37,20 +28,19 @@ final ExitFunction _defaultExitFunction = ([int exitCode]) { /// Exits the process. ExitFunction exit = _defaultExitFunction; -/// Restores [fs] and [syncFs] to the default local disk-based implementation. +/// Restores [fs] to the default local disk-based implementation. void restoreFileSystem() { fs = new LocalFileSystem(); - syncFs = new SyncLocalFileSystem(); - getCurrentDirectory = _defaultCurrentDirectoryGetter; exit = _defaultExitFunction; } /// Uses in-memory replacments for `dart:io` functionality. Useful in tests. void useInMemoryFileSystem({ String cwd: '/', ExitFunction exitFunction }) { - MemoryFileSystem memFs = new MemoryFileSystem(); - fs = memFs; - syncFs = new SyncMemoryFileSystem(backedBy: memFs.storage); - getCurrentDirectory = () => cwd; + fs = new MemoryFileSystem(); + if (!fs.directory(cwd).existsSync()) { + fs.directory(cwd).createSync(recursive: true); + } + fs.currentDirectory = cwd; exit = exitFunction ?? ([int exitCode]) { throw new Exception('Exited with code $exitCode'); }; @@ -60,9 +50,9 @@ void useInMemoryFileSystem({ String cwd: '/', ExitFunction exitFunction }) { void ensureDirectoryExists(String filePath) { String dirPath = path.dirname(filePath); - if (syncFs.type(dirPath) == FileSystemEntityType.DIRECTORY) + if (fs.typeSync(dirPath) == FileSystemEntityType.DIRECTORY) return; - syncFs.directory(dirPath).create(recursive: true); + fs.directory(dirPath).createSync(recursive: true); } /// Recursively copies a folder from `srcPath` to `destPath` diff --git a/packages/flutter_tools/lib/src/commands/drive.dart b/packages/flutter_tools/lib/src/commands/drive.dart index 9970edb642..b3803bcd2b 100644 --- a/packages/flutter_tools/lib/src/commands/drive.dart +++ b/packages/flutter_tools/lib/src/commands/drive.dart @@ -155,7 +155,7 @@ class DriveCommand extends RunCommandBase { String appFile = path.normalize(targetFile); // This command extends `flutter start` and therefore CWD == package dir - String packageDir = getCurrentDirectory(); + String packageDir = fs.currentDirectory.path; // Make appFile path relative to package directory because we are looking // for the corresponding test file relative to it. diff --git a/packages/flutter_tools/pubspec.yaml b/packages/flutter_tools/pubspec.yaml index c7a023894d..58e599b59e 100644 --- a/packages/flutter_tools/pubspec.yaml +++ b/packages/flutter_tools/pubspec.yaml @@ -12,7 +12,7 @@ dependencies: args: ^0.13.4 coverage: ^0.8.0 crypto: '>=1.1.1 <3.0.0' - file: ^0.1.0 + file: ^1.0.0 http: ^0.11.3 intl: '>=0.14.0 <0.15.0' json_rpc_2: ^2.0.0 diff --git a/packages/flutter_tools/test/drive_test.dart b/packages/flutter_tools/test/drive_test.dart index 4db7bad712..fd0b78011f 100644 --- a/packages/flutter_tools/test/drive_test.dart +++ b/packages/flutter_tools/test/drive_test.dart @@ -4,7 +4,7 @@ import 'dart:async'; -import 'package:file/file.dart'; +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'; @@ -34,6 +34,8 @@ void main() { command = new DriveCommand(); applyMocksToCommand(command); useInMemoryFileSystem(cwd: '/some/app'); + fs.directory('test').createSync(); + fs.directory('test_driver').createSync(); targetDeviceFinder = () { throw 'Unexpected call to targetDeviceFinder'; };