Commit 417c2f25 authored by Todd Volkert's avatar Todd Volkert Committed by GitHub

Migrate flutter_tools to use package:platform (#7642)

parent 600c75cb
......@@ -14,6 +14,7 @@ import '../lib/src/base/file_system.dart';
import '../lib/src/base/io.dart';
import '../lib/src/base/logger.dart';
import '../lib/src/base/os.dart';
import '../lib/src/base/platform.dart';
import '../lib/src/cache.dart';
import '../lib/src/flx.dart';
import '../lib/src/globals.dart';
......@@ -38,6 +39,7 @@ Future<Null> main(List<String> args) async {
executableContext.setVariable(Logger, new StdoutLogger());
executableContext.runInZone(() {
// Initialize the context with some defaults.
context.putIfAbsent(Platform, () => new LocalPlatform());
context.putIfAbsent(FileSystem, () => new LocalFileSystem());
context.putIfAbsent(ProcessManager, () => new LocalProcessManager());
context.putIfAbsent(Logger, () => new StdoutLogger());
......@@ -63,7 +65,7 @@ Future<Null> run(List<String> args) async {
printError('Missing option! All options must be specified.');
exit(1);
}
Cache.flutterRoot = Platform.environment['FLUTTER_ROOT'];
Cache.flutterRoot = platform.environment['FLUTTER_ROOT'];
String outputPath = argResults[_kOptionOutput];
try {
await assemble(
......
......@@ -15,6 +15,7 @@ import 'src/base/file_system.dart';
import 'src/base/io.dart';
import 'src/base/logger.dart';
import 'src/base/os.dart';
import 'src/base/platform.dart';
import 'src/base/process.dart';
import 'src/base/utils.dart';
import 'src/cache.dart';
......@@ -100,6 +101,7 @@ Future<Null> main(List<String> args) async {
// in those locations as well to see if you need a similar update there.
// Seed these context entries first since others depend on them
context.putIfAbsent(Platform, () => new LocalPlatform());
context.putIfAbsent(FileSystem, () => new LocalFileSystem());
context.putIfAbsent(ProcessManager, () => new LocalProcessManager());
context.putIfAbsent(Logger, () => new StdoutLogger());
......
......@@ -8,8 +8,8 @@ import 'package:pub_semver/pub_semver.dart';
import '../base/common.dart';
import '../base/context.dart';
import '../base/file_system.dart';
import '../base/io.dart';
import '../base/os.dart';
import '../base/platform.dart';
import '../globals.dart';
AndroidSdk get androidSdk => context[AndroidSdk];
......@@ -64,15 +64,15 @@ class AndroidSdk {
static AndroidSdk locateAndroidSdk() {
String androidHomeDir;
if (Platform.environment.containsKey(kAndroidHome)) {
androidHomeDir = Platform.environment[kAndroidHome];
} else if (Platform.isLinux) {
if (platform.environment.containsKey(kAndroidHome)) {
androidHomeDir = platform.environment[kAndroidHome];
} else if (platform.isLinux) {
if (homeDirPath != null)
androidHomeDir = path.join(homeDirPath, 'Android', 'Sdk');
} else if (Platform.isMacOS) {
} else if (platform.isMacOS) {
if (homeDirPath != null)
androidHomeDir = path.join(homeDirPath, 'Library', 'Android', 'sdk');
} else if (Platform.isWindows) {
} else if (platform.isWindows) {
if (homeDirPath != null)
androidHomeDir = path.join(homeDirPath, 'AppData', 'Local', 'Android', 'sdk');
}
......
......@@ -6,6 +6,7 @@ import 'dart:async';
import '../base/io.dart';
import '../base/os.dart';
import '../base/platform.dart';
import '../base/process_manager.dart';
import '../doctor.dart';
import '../globals.dart';
......@@ -30,8 +31,8 @@ class AndroidWorkflow extends DoctorValidator implements Workflow {
String sdkVersionText;
if (androidSdk == null) {
if (Platform.environment.containsKey(kAndroidHome)) {
String androidHomeDir = Platform.environment[kAndroidHome];
if (platform.environment.containsKey(kAndroidHome)) {
String androidHomeDir = platform.environment[kAndroidHome];
messages.add(new ValidationMessage.error(
'$kAndroidHome = $androidHomeDir\n'
'but Android Studio / Android SDK not found at this location.'
......@@ -56,8 +57,8 @@ class AndroidWorkflow extends DoctorValidator implements Workflow {
));
}
if (Platform.environment.containsKey(kAndroidHome)) {
String androidHomeDir = Platform.environment[kAndroidHome];
if (platform.environment.containsKey(kAndroidHome)) {
String androidHomeDir = platform.environment[kAndroidHome];
messages.add(new ValidationMessage('$kAndroidHome = $androidHomeDir'));
}
......
......@@ -4,7 +4,7 @@
import 'package:path/path.dart' as path;
import 'io.dart';
import 'platform.dart';
const int kDefaultObservatoryPort = 8100;
const int kDefaultDiagnosticPort = 8101;
......@@ -13,9 +13,9 @@ const int kDefaultDrivePort = 8183;
/// Return the absolute path of the user's home directory
String get homeDirPath {
if (_homeDirPath == null) {
_homeDirPath = Platform.isWindows
? Platform.environment['USERPROFILE']
: Platform.environment['HOME'];
_homeDirPath = platform.isWindows
? platform.environment['USERPROFILE']
: platform.environment['HOME'];
if (_homeDirPath != null)
_homeDirPath = path.absolute(_homeDirPath);
}
......
......@@ -8,7 +8,7 @@ import 'package:path/path.dart' as path;
import 'context.dart';
import 'file_system.dart';
import 'io.dart';
import 'platform.dart';
class Config {
Config([File configFile]) {
......@@ -46,7 +46,7 @@ class Config {
}
String _userHomeDir() {
String envKey = Platform.operatingSystem == 'windows' ? 'APPDATA' : 'HOME';
String value = Platform.environment[envKey];
String envKey = platform.operatingSystem == 'windows' ? 'APPDATA' : 'HOME';
String value = platform.environment[envKey];
return value == null ? '.' : value;
}
......@@ -11,16 +11,20 @@
/// 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.
/// We also use `package:platform` to provide an abstraction away from the
/// static methods in the `dart:io` `Platform` class (see `platform.dart`). As
/// such, do not export Platform from this file!
///
/// 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.
/// To ensure that all file system and platform API 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 **platform and file
/// APIs not 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';
......@@ -28,7 +32,10 @@ import 'package:meta/meta.dart';
export 'dart:io'
show
BytesBuilder,
// Directory NO! Use `file_system.dart`
exitCode,
// File NO! Use `file_system.dart`
// FileSystemEntity NO! Use `file_system.dart`
GZIP,
InternetAddress,
IOException,
......@@ -40,13 +47,15 @@ export 'dart:io'
HttpRequest,
HttpServer,
HttpStatus,
// Link NO! Use `file_system.dart`
pid,
Platform,
// Platform NO! use `platform.dart`
Process,
ProcessException,
ProcessResult,
ProcessSignal,
ProcessStartMode,
// RandomAccessFile NO! Use `file_system.dart`
ServerSocket,
stderr,
stdin,
......
......@@ -8,6 +8,7 @@ import 'dart:convert' show ASCII;
import 'package:stack_trace/stack_trace.dart';
import 'io.dart';
import 'platform.dart';
final AnsiTerminal terminal = new AnsiTerminal();
......@@ -202,7 +203,7 @@ enum _LogType {
class AnsiTerminal {
AnsiTerminal() {
// TODO(devoncarew): This detection does not work for Windows.
String term = Platform.environment['TERM'];
String term = platform.environment['TERM'];
supportsColor = term != null && term != 'dumb';
}
......
......@@ -10,6 +10,7 @@ import 'package:path/path.dart' as path;
import 'context.dart';
import 'file_system.dart';
import 'io.dart';
import 'platform.dart';
import 'process.dart';
import 'process_manager.dart';
......@@ -18,7 +19,7 @@ OperatingSystemUtils get os => context[OperatingSystemUtils];
abstract class OperatingSystemUtils {
factory OperatingSystemUtils() {
if (Platform.isWindows) {
if (platform.isWindows) {
return new _WindowsUtils();
} else {
return new _PosixUtils();
......@@ -27,8 +28,9 @@ abstract class OperatingSystemUtils {
OperatingSystemUtils._private();
String get operatingSystem => Platform.operatingSystem;
// TODO(tvolkert): Remove these and migrate callers to Platform
String get operatingSystem => platform.operatingSystem;
bool get isMacOS => operatingSystem == 'macos';
bool get isWindows => operatingSystem == 'windows';
bool get isLinux => operatingSystem == 'linux';
......@@ -46,7 +48,7 @@ abstract class OperatingSystemUtils {
void unzip(File file, Directory targetDirectory);
/// Returns the name of the [binaryName] executable.
///
///
/// No-op on most OS.
/// On Windows it returns [binaryName].[winExtension], if [winExtension] is
/// specified, or [binaryName].exe otherwise.
......
// Copyright 2016 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.
import 'package:platform/platform.dart';
import 'context.dart';
export 'package:platform/platform.dart';
const Platform _kLocalPlatform = const LocalPlatform();
Platform get platform => context == null ? _kLocalPlatform : context[Platform];
......@@ -10,15 +10,15 @@ import 'package:crypto/crypto.dart';
import 'package:path/path.dart' as path;
import 'file_system.dart';
import 'io.dart';
import 'platform.dart';
bool get isRunningOnBot {
// https://docs.travis-ci.com/user/environment-variables/#Default-Environment-Variables
// CHROME_HEADLESS is one property set on Flutter's Chrome Infra bots.
return
Platform.environment['TRAVIS'] == 'true' ||
Platform.environment['CONTINUOUS_INTEGRATION'] == 'true' ||
Platform.environment['CHROME_HEADLESS'] == '1';
platform.environment['TRAVIS'] == 'true' ||
platform.environment['CONTINUOUS_INTEGRATION'] == 'true' ||
platform.environment['CHROME_HEADLESS'] == '1';
}
String hex(List<int> bytes) {
......
......@@ -5,7 +5,7 @@
import 'package:path/path.dart' as path;
import 'base/context.dart';
import 'base/io.dart';
import 'base/platform.dart';
import 'base/utils.dart';
import 'globals.dart';
......@@ -106,9 +106,9 @@ TargetPlatform getTargetPlatformForName(String platform) {
}
HostPlatform getCurrentHostPlatform() {
if (Platform.isMacOS)
if (platform.isMacOS)
return HostPlatform.darwin_x64;
if (Platform.isLinux)
if (platform.isLinux)
return HostPlatform.linux_x64;
printError('Unsupported host platform, defaulting to Linux');
......
......@@ -10,10 +10,10 @@ import 'package:path/path.dart' as path;
import 'base/context.dart';
import 'base/file_system.dart';
import 'base/io.dart';
import 'base/logger.dart';
import 'base/net.dart';
import 'base/os.dart';
import 'base/platform.dart';
import 'globals.dart';
/// A wrapper around the `bin/cache/` directory.
......@@ -84,7 +84,7 @@ class Cache {
static String get dartSdkVersion {
if (_dartSdkVersion == null) {
_dartSdkVersion = Platform.version;
_dartSdkVersion = platform.version;
}
return _dartSdkVersion;
}
......@@ -265,9 +265,9 @@ class FlutterEngine {
if (cache.includeAllPlatforms)
dirs.addAll(<String>['ios', 'ios-profile', 'ios-release', 'linux-x64']);
else if (Platform.isMacOS)
else if (platform.isMacOS)
dirs.addAll(<String>['ios', 'ios-profile', 'ios-release']);
else if (Platform.isLinux)
else if (platform.isLinux)
dirs.add('linux-x64');
return dirs;
......@@ -279,9 +279,9 @@ class FlutterEngine {
return <List<String>>[]
..addAll(_osxToolsDirs)
..addAll(_linuxToolsDirs);
else if (Platform.isMacOS)
else if (platform.isMacOS)
return _osxToolsDirs;
else if (Platform.isLinux)
else if (platform.isLinux)
return _linuxToolsDirs;
else
return <List<String>>[];
......
......@@ -11,6 +11,7 @@ import '../base/common.dart';
import '../base/file_system.dart';
import '../base/io.dart';
import '../base/logger.dart';
import '../base/platform.dart';
import '../base/process_manager.dart';
import '../base/os.dart';
import '../cache.dart';
......@@ -190,7 +191,7 @@ class TestCommand extends FlutterCommand {
}
testArgs.addAll(files);
final String shellPath = tools.getHostToolPath(HostTool.SkyShell) ?? Platform.environment['SKY_SHELL'];
final String shellPath = tools.getHostToolPath(HostTool.SkyShell) ?? platform.environment['SKY_SHELL'];
if (!fs.isFileSync(shellPath))
throwToolExit('Cannot find Flutter shell at $shellPath');
loader.installHook(shellPath: shellPath, collector: collector, debuggerMode: argResults['start-paused']);
......
......@@ -4,7 +4,7 @@
import 'package:path/path.dart' as path;
import '../base/io.dart';
import '../base/platform.dart';
import '../cache.dart';
/// Locate the Dart SDK.
......@@ -16,5 +16,5 @@ String get dartSdkPath {
/// ==> `pub.bat`. The default SDK location can be overridden with a specified
/// [sdkLocation].
String sdkBinaryName(String name, { String sdkLocation }) {
return path.absolute(path.join(sdkLocation ?? dartSdkPath, 'bin', Platform.isWindows ? '$name.bat' : name));
return path.absolute(path.join(sdkLocation ?? dartSdkPath, 'bin', platform.isWindows ? '$name.bat' : name));
}
......@@ -163,6 +163,8 @@ abstract class Device {
// supported by Flutter, and, if not, why.
String supportMessage() => isSupported() ? "Supported" : "Unsupported";
// TODO(tvolkert): Rename to `targetPlatform`, and remove the "as p"
// aliases on the `platform.dart` imports where applicable.
TargetPlatform get platform;
String get sdkNameAndVersion;
......
......@@ -3,16 +3,16 @@
// found in the LICENSE file.
import 'dart:async';
import 'dart:convert' show UTF8;
import 'package:archive/archive.dart';
import 'dart:convert' show UTF8;
import 'package:path/path.dart' as path;
import 'android/android_workflow.dart';
import 'base/common.dart';
import 'base/context.dart';
import 'base/file_system.dart';
import 'base/io.dart';
import 'base/platform.dart';
import 'device.dart';
import 'globals.dart';
import 'ios/ios_workflow.dart';
......@@ -27,7 +27,7 @@ const Map<String, String> _osNames = const <String, String>{
};
String osName() {
String os = Platform.operatingSystem;
String os = platform.operatingSystem;
return _osNames.containsKey(os) ? _osNames[os] : os;
}
......@@ -182,7 +182,7 @@ class ValidationResult {
if (type == ValidationType.missing)
return '[x]';
else if (type == ValidationType.installed)
return Platform.isWindows ? '[√]' : '[✓]';
return platform.isWindows ? '[√]' : '[✓]';
else
return '[-]';
}
......@@ -217,7 +217,7 @@ class _FlutterValidator extends DoctorValidator {
messages.add(new ValidationMessage('Engine revision ${version.engineRevisionShort}'));
messages.add(new ValidationMessage('Tools Dart version ${version.dartSdkVersion}'));
if (Platform.isWindows) {
if (platform.isWindows) {
valid = ValidationType.missing;
messages.add(new ValidationMessage.error(
......@@ -254,9 +254,9 @@ abstract class IntelliJValidator extends DoctorValidator {
};
static Iterable<DoctorValidator> get installedValidators {
if (Platform.isLinux || Platform.isWindows)
if (platform.isLinux || platform.isWindows)
return IntelliJValidatorOnLinuxAndWindows.installed;
if (Platform.isMacOS)
if (platform.isMacOS)
return IntelliJValidatorOnMac.installed;
return <DoctorValidator>[];
}
......
......@@ -9,6 +9,7 @@ import '../application_package.dart';
import '../base/file_system.dart';
import '../base/io.dart';
import '../base/os.dart';
import '../base/platform.dart' as p;
import '../base/process.dart';
import '../base/process_manager.dart';
import '../build_info.dart';
......@@ -28,7 +29,7 @@ class IOSDevices extends PollingDeviceDiscovery {
IOSDevices() : super('IOSDevices');
@override
bool get supportsPlatform => Platform.isMacOS;
bool get supportsPlatform => p.platform.isMacOS;
@override
List<Device> pollingGetDevices() => IOSDevice.getAttachedDevices();
......@@ -125,7 +126,7 @@ class IOSDevice extends Device {
try {
command = runCheckedSync(<String>['which', command]).trim();
} catch (e) {
if (Platform.isMacOS) {
if (p.platform.isMacOS) {
printError('$command not found. $macInstructions');
} else {
printError('Cannot control iOS devices or simulators. $command is not available on your platform.');
......@@ -314,7 +315,7 @@ class IOSDevice extends Device {
}
Future<bool> pushFile(ApplicationPackage app, String localFile, String targetFile) async {
if (Platform.isMacOS) {
if (p.platform.isMacOS) {
runSync(<String>[
pusherPath,
'-t',
......
......@@ -6,6 +6,7 @@ import 'dart:async';
import '../base/io.dart';
import '../base/os.dart';
import '../base/platform.dart';
import '../base/process.dart';
import '../doctor.dart';
import 'mac.dart';
......@@ -16,7 +17,7 @@ class IOSWorkflow extends DoctorValidator implements Workflow {
IOSWorkflow() : super('iOS toolchain - develop for iOS devices');
@override
bool get appliesToHostPlatform => Platform.isMacOS;
bool get appliesToHostPlatform => platform.isMacOS;
// We need xcode (+simctl) to list simulator devices, and idevice_id to list real devices.
@override
......
......@@ -11,6 +11,7 @@ import '../application_package.dart';
import '../base/context.dart';
import '../base/file_system.dart';
import '../base/io.dart';
import '../base/platform.dart';
import '../base/process.dart';
import '../base/process_manager.dart';
import '../build_info.dart';
......@@ -220,7 +221,7 @@ final RegExp _xcodeVersionRegExp = new RegExp(r'Xcode (\d+)\..*');
final String _xcodeRequirement = 'Xcode 7.0 or greater is required to develop for iOS.';
bool _checkXcodeVersion() {
if (!Platform.isMacOS)
if (!platform.isMacOS)
return false;
try {
String version = runCheckedSync(<String>['xcodebuild', '-version']);
......
......@@ -13,6 +13,7 @@ import '../base/common.dart';
import '../base/context.dart';
import '../base/file_system.dart';
import '../base/io.dart';
import '../base/platform.dart' as p;
import '../base/process.dart';
import '../base/process_manager.dart';
import '../build_info.dart';
......@@ -31,7 +32,7 @@ class IOSSimulators extends PollingDeviceDiscovery {
IOSSimulators() : super('IOSSimulators');
@override
bool get supportsPlatform => Platform.isMacOS;
bool get supportsPlatform => p.platform.isMacOS;
@override
List<Device> pollingGetDevices() => IOSSimulatorUtils.instance.getAttachedDevices();
......@@ -359,7 +360,7 @@ class IOSSimulator extends Device {
@override
bool isSupported() {
if (!Platform.isMacOS) {
if (!p.platform.isMacOS) {
_supportMessage = "Not supported on a non Mac host";
return false;
}
......@@ -532,7 +533,7 @@ class IOSSimulator extends Device {
Future<bool> pushFile(
ApplicationPackage app, String localFile, String targetFile) async {
if (Platform.isMacOS) {
if (p.platform.isMacOS) {
String simulatorHomeDirectory = _getSimulatorAppHomeDirectory(app);
runCheckedSync(<String>['cp', localFile, path.join(simulatorHomeDirectory, targetFile)]);
return true;
......
......@@ -12,8 +12,8 @@ import '../android/android_sdk.dart';
import '../base/common.dart';
import '../base/context.dart';
import '../base/file_system.dart';
import '../base/io.dart';
import '../base/logger.dart';
import '../base/platform.dart';
import '../base/process.dart';
import '../base/process_manager.dart';
import '../cache.dart';
......@@ -117,12 +117,12 @@ class FlutterCommandRunner extends CommandRunner<Null> {
}
static String get _defaultFlutterRoot {
if (Platform.environment.containsKey(kFlutterRootEnvironmentVariableName))
return Platform.environment[kFlutterRootEnvironmentVariableName];
if (platform.environment.containsKey(kFlutterRootEnvironmentVariableName))
return platform.environment[kFlutterRootEnvironmentVariableName];
try {
if (Platform.script.scheme == 'data')
if (platform.script.scheme == 'data')
return '../..'; // we're running as a test
String script = Platform.script.toFilePath();
String script = platform.script.toFilePath();
if (path.basename(script) == kSnapshotFileName)
return path.dirname(path.dirname(path.dirname(script)));
if (path.basename(script) == kFlutterToolsScriptFileName)
......@@ -179,7 +179,7 @@ class FlutterCommandRunner extends CommandRunner<Null> {
// enginePath's initialiser uses it).
Cache.flutterRoot = path.normalize(path.absolute(globalResults['flutter-root']));
if (Platform.environment['FLUTTER_ALREADY_LOCKED'] != 'true')
if (platform.environment['FLUTTER_ALREADY_LOCKED'] != 'true')
await Cache.lock();
if (globalResults['suppress-analytics'])
......@@ -219,7 +219,7 @@ class FlutterCommandRunner extends CommandRunner<Null> {
}
String _findEnginePath(ArgResults globalResults) {
String engineSourcePath = globalResults['local-engine-src-path'] ?? Platform.environment[kFlutterEngineEnvironmentVariableName];
String engineSourcePath = globalResults['local-engine-src-path'] ?? platform.environment[kFlutterEngineEnvironmentVariableName];
if (engineSourcePath == null && globalResults['local-engine'] != null) {
try {
......
......@@ -22,6 +22,7 @@ dependencies:
mustache: ^0.2.5
package_config: '>=0.1.5 <2.0.0'
path: ^1.4.0
platform: 1.0.1
process: 1.0.1
pub_semver: ^1.0.0
stack_trace: ^1.4.0
......
......@@ -5,8 +5,8 @@
import 'dart:async';
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/platform.dart';
import 'package:flutter_tools/src/commands/daemon.dart';
import 'package:flutter_tools/src/device.dart';
import 'package:flutter_tools/src/doctor.dart';
......@@ -32,9 +32,10 @@ void main() {
setUp(() {
appContext = new AppContext();
notifyingLogger = new NotifyingLogger();
appContext.setVariable(Platform, new LocalPlatform());
appContext.setVariable(Logger, notifyingLogger);
appContext.setVariable(Doctor, new Doctor());
if (Platform.isMacOS)
if (platform.isMacOS)
appContext.setVariable(XCode, new XCode());
appContext.setVariable(DeviceManager, new MockDeviceManager());
});
......
......@@ -2,15 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/dart/dependencies.dart';
import 'package:flutter_tools/src/base/platform.dart';
import 'package:path/path.dart' as path;
import 'package:test/test.dart';
import 'src/context.dart';
void main() {
group('DartDependencySetBuilder', () {
final String basePath = path.dirname(Platform.script.path);
final String basePath = path.dirname(platform.script.path);
final String dataPath = path.join(basePath, 'data', 'dart_dependencies_test');
testUsingContext('good', () {
final String testPath = path.join(dataPath, 'good');
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/dart/dependencies.dart';
import 'package:flutter_tools/src/dependency_checker.dart';
import 'package:path/path.dart' as path;
......@@ -12,7 +12,7 @@ import 'src/context.dart';
void main() {
group('DependencyChecker', () {
final String basePath = path.dirname(Platform.script.path);
final String basePath = path.dirname(platform.script.path);
final String dataPath = path.join(basePath, 'data', 'dart_dependencies_test');
testUsingContext('good', () {
final String testPath = path.join(dataPath, 'good');
......
......@@ -3,12 +3,12 @@
// found in the LICENSE file.
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/base/platform.dart';
import 'package:test/test.dart';
void main() {
setUp(() {
String flutterRoot = Platform.environment['FLUTTER_ROOT'];
String flutterRoot = platform.environment['FLUTTER_ROOT'];
assert(fs.currentDirectory.path == '$flutterRoot/packages/flutter_tools');
});
......
......@@ -3,8 +3,8 @@
// found in the LICENSE file.
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/platform.dart';
import 'package:path/path.dart' as path;
import 'package:test/test.dart';
......@@ -28,7 +28,7 @@ void main() {
os.makeExecutable(file);
// Skip this test on windows.
if (!Platform.isWindows) {
if (!platform.isWindows) {
String mode = file.statSync().modeString();
// rwxr--r--
expect(mode.substring(0, 3), endsWith('x'));
......
......@@ -7,9 +7,9 @@ import 'dart:async';
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/platform.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/device.dart';
import 'package:flutter_tools/src/devfs.dart';
......@@ -42,6 +42,7 @@ void testUsingContext(String description, dynamic testMethod(), {
// Initialize the test context with some default mocks.
// Seed these context entries first since others depend on them
testContext.putIfAbsent(Platform, () => new LocalPlatform());
testContext.putIfAbsent(FileSystem, () => new LocalFileSystem());
testContext.putIfAbsent(ProcessManager, () => new LocalProcessManager());
testContext.putIfAbsent(Logger, () => new BufferLogger());
......@@ -68,7 +69,7 @@ void testUsingContext(String description, dynamic testMethod(), {
testContext.putIfAbsent(SimControl, () => new MockSimControl());
testContext.putIfAbsent(Usage, () => new MockUsage());
final String basePath = path.dirname(Platform.script.path);
final String basePath = path.dirname(platform.script.path);
final String flutterRoot =
path.normalize(path.join(basePath, '..', '..', '..'));
try {
......@@ -148,7 +149,7 @@ class MockOperatingSystemUtils extends Mock implements OperatingSystemUtils {
// That way it wouldn't really matter what the mock returns here.
@override
String getExecutableName(String binaryName, { String winExtension }) {
if (!Platform.isWindows)
if (!platform.isWindows)
return binaryName;
winExtension ??= 'exe';
if (path.extension(binaryName).isEmpty && winExtension.isNotEmpty)
......
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