This reverts commit 8b6baae44c8661d548643ced73493e6a66862622.
This commit is contained in:
parent
02d441ea55
commit
021311ed8a
@ -7,6 +7,8 @@ environment:
|
||||
dependencies:
|
||||
archive: 3.0.0
|
||||
args: 1.6.0
|
||||
flutter_tools:
|
||||
path: '../../packages/flutter_tools'
|
||||
http: 0.12.2
|
||||
intl: 0.17.0
|
||||
meta: 1.3.0
|
||||
|
@ -11,8 +11,8 @@ import 'package:file/memory.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:platform/platform.dart';
|
||||
|
||||
import '../../../packages/flutter_tools/test/src/fake_process_manager.dart';
|
||||
import './common.dart';
|
||||
import 'fake_process_manager.dart';
|
||||
|
||||
void main() {
|
||||
group('codesign command', () {
|
||||
|
@ -1,376 +0,0 @@
|
||||
// Copyright 2014 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:process/process.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'common.dart';
|
||||
|
||||
// TODO(flutter): consider moving this into package:process.
|
||||
|
||||
typedef VoidCallback = void Function();
|
||||
|
||||
/// A command for [FakeProcessManager].
|
||||
@immutable
|
||||
class FakeCommand {
|
||||
const FakeCommand({
|
||||
@required this.command,
|
||||
this.workingDirectory,
|
||||
this.environment,
|
||||
this.encoding,
|
||||
this.duration = Duration.zero,
|
||||
this.onRun,
|
||||
this.exitCode = 0,
|
||||
this.stdout = '',
|
||||
this.stderr = '',
|
||||
this.completer,
|
||||
this.stdin,
|
||||
}) : assert(command != null),
|
||||
assert(duration != null),
|
||||
assert(exitCode != null);
|
||||
|
||||
/// The exact commands that must be matched for this [FakeCommand] to be
|
||||
/// considered correct.
|
||||
final List<String> command;
|
||||
|
||||
/// The exact working directory that must be matched for this [FakeCommand] to
|
||||
/// be considered correct.
|
||||
///
|
||||
/// If this is null, the working directory is ignored.
|
||||
final String workingDirectory;
|
||||
|
||||
/// The environment that must be matched for this [FakeCommand] to be considered correct.
|
||||
///
|
||||
/// If this is null, then the environment is ignored.
|
||||
///
|
||||
/// Otherwise, each key in this environment must be present and must have a
|
||||
/// value that matches the one given here for the [FakeCommand] to match.
|
||||
final Map<String, String> environment;
|
||||
|
||||
/// The stdout and stderr encoding that must be matched for this [FakeCommand]
|
||||
/// to be considered correct.
|
||||
///
|
||||
/// If this is null, then the encodings are ignored.
|
||||
final Encoding encoding;
|
||||
|
||||
/// The time to allow to elapse before returning the [exitCode], if this command
|
||||
/// is "executed".
|
||||
///
|
||||
/// If you set this to a non-zero time, you should use a [FakeAsync] zone,
|
||||
/// otherwise the test will be artificially slow.
|
||||
final Duration duration;
|
||||
|
||||
/// A callback that is run after [duration] expires but before the [exitCode]
|
||||
/// (and output) are passed back.
|
||||
final VoidCallback onRun;
|
||||
|
||||
/// The process' exit code.
|
||||
///
|
||||
/// To simulate a never-ending process, set [duration] to a value greater than
|
||||
/// 15 minutes (the timeout for our tests).
|
||||
///
|
||||
/// To simulate a crash, subtract the crash signal number from 256. For example,
|
||||
/// SIGPIPE (-13) is 243.
|
||||
final int exitCode;
|
||||
|
||||
/// The output to simulate on stdout. This will be encoded as UTF-8 and
|
||||
/// returned in one go.
|
||||
final String stdout;
|
||||
|
||||
/// The output to simulate on stderr. This will be encoded as UTF-8 and
|
||||
/// returned in one go.
|
||||
final String stderr;
|
||||
|
||||
/// If provided, allows the command completion to be blocked until the future
|
||||
/// resolves.
|
||||
final Completer<void> completer;
|
||||
|
||||
/// An optional stdin sink that will be exposed through the resulting
|
||||
/// [FakeProcess].
|
||||
final IOSink stdin;
|
||||
|
||||
void _matches(
|
||||
List<String> command,
|
||||
String workingDirectory,
|
||||
Map<String, String> environment,
|
||||
Encoding encoding,
|
||||
) {
|
||||
expect(command, equals(this.command));
|
||||
if (this.workingDirectory != null) {
|
||||
expect(this.workingDirectory, workingDirectory);
|
||||
}
|
||||
if (this.environment != null) {
|
||||
expect(this.environment, environment);
|
||||
}
|
||||
if (this.encoding != null) {
|
||||
expect(this.encoding, encoding);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class _FakeProcess implements Process {
|
||||
_FakeProcess(
|
||||
this._exitCode,
|
||||
Duration duration,
|
||||
this.pid,
|
||||
this._stderr,
|
||||
this.stdin,
|
||||
this._stdout,
|
||||
this._completer,
|
||||
) : exitCode = Future<void>.delayed(duration).then((void value) {
|
||||
if (_completer != null) {
|
||||
return _completer.future.then((void _) => _exitCode);
|
||||
}
|
||||
return _exitCode;
|
||||
}),
|
||||
stderr = _stderr == null
|
||||
? const Stream<List<int>>.empty()
|
||||
: Stream<List<int>>.value(utf8.encode(_stderr)),
|
||||
stdout = _stdout == null
|
||||
? const Stream<List<int>>.empty()
|
||||
: Stream<List<int>>.value(utf8.encode(_stdout));
|
||||
|
||||
final int _exitCode;
|
||||
final Completer<void> _completer;
|
||||
|
||||
@override
|
||||
final Future<int> exitCode;
|
||||
|
||||
@override
|
||||
final int pid;
|
||||
|
||||
final String _stderr;
|
||||
|
||||
@override
|
||||
final Stream<List<int>> stderr;
|
||||
|
||||
@override
|
||||
final IOSink stdin;
|
||||
|
||||
@override
|
||||
final Stream<List<int>> stdout;
|
||||
|
||||
final String _stdout;
|
||||
|
||||
@override
|
||||
bool kill([ProcessSignal signal = ProcessSignal.sigterm]) {
|
||||
// Killing a fake process has no effect.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
abstract class FakeProcessManager implements ProcessManager {
|
||||
/// A fake [ProcessManager] which responds to all commands as if they had run
|
||||
/// instantaneously with an exit code of 0 and no output.
|
||||
factory FakeProcessManager.any() = _FakeAnyProcessManager;
|
||||
|
||||
/// A fake [ProcessManager] which responds to particular commands with
|
||||
/// particular results.
|
||||
///
|
||||
/// On creation, pass in a list of [FakeCommand] objects. When the
|
||||
/// [ProcessManager] methods such as [start] are invoked, the next
|
||||
/// [FakeCommand] must match (otherwise the test fails); its settings are used
|
||||
/// to simulate the result of running that command.
|
||||
///
|
||||
/// If no command is found, then one is implied which immediately returns exit
|
||||
/// code 0 with no output.
|
||||
///
|
||||
/// There is no logic to ensure that all the listed commands are run. Use
|
||||
/// [FakeCommand.onRun] to set a flag, or specify a sentinel command as your
|
||||
/// last command and verify its execution is successful, to ensure that all
|
||||
/// the specified commands are actually called.
|
||||
factory FakeProcessManager.list(List<FakeCommand> commands) = _SequenceProcessManager;
|
||||
|
||||
FakeProcessManager._();
|
||||
|
||||
/// Adds a new [FakeCommand] to the current process manager.
|
||||
///
|
||||
/// This can be used to configure test expectations after the [ProcessManager] has been
|
||||
/// provided to another interface.
|
||||
///
|
||||
/// This is a no-op on [FakeProcessManager.any].
|
||||
void addCommand(FakeCommand command);
|
||||
|
||||
/// Add multiple [FakeCommand] to the current process manager.
|
||||
void addCommands(Iterable<FakeCommand> commands) {
|
||||
commands.forEach(addCommand);
|
||||
}
|
||||
|
||||
final Map<int, _FakeProcess> _fakeRunningProcesses = <int, _FakeProcess>{};
|
||||
|
||||
/// Whether this fake has more [FakeCommand]s that are expected to run.
|
||||
///
|
||||
/// This is always `true` for [FakeProcessManager.any].
|
||||
bool get hasRemainingExpectations;
|
||||
|
||||
@protected
|
||||
FakeCommand findCommand(
|
||||
List<String> command,
|
||||
String workingDirectory,
|
||||
Map<String, String> environment,
|
||||
Encoding encoding,
|
||||
);
|
||||
|
||||
int _pid = 9999;
|
||||
|
||||
_FakeProcess _runCommand(
|
||||
List<String> command,
|
||||
String workingDirectory,
|
||||
Map<String, String> environment,
|
||||
Encoding encoding,
|
||||
) {
|
||||
_pid += 1;
|
||||
final FakeCommand fakeCommand = findCommand(command, workingDirectory, environment, encoding);
|
||||
if (fakeCommand.onRun != null) {
|
||||
fakeCommand.onRun();
|
||||
}
|
||||
return _FakeProcess(
|
||||
fakeCommand.exitCode,
|
||||
fakeCommand.duration,
|
||||
_pid,
|
||||
fakeCommand.stderr,
|
||||
fakeCommand.stdin,
|
||||
fakeCommand.stdout,
|
||||
fakeCommand.completer,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Process> start(
|
||||
List<dynamic> command, {
|
||||
String workingDirectory,
|
||||
Map<String, String> environment,
|
||||
bool includeParentEnvironment = true, // ignored
|
||||
bool runInShell = false, // ignored
|
||||
ProcessStartMode mode = ProcessStartMode.normal, // ignored
|
||||
}) {
|
||||
final _FakeProcess process = _runCommand(command.cast<String>(), workingDirectory, environment, systemEncoding);
|
||||
if (process._completer != null) {
|
||||
_fakeRunningProcesses[process.pid] = process;
|
||||
process.exitCode.whenComplete(() {
|
||||
_fakeRunningProcesses.remove(process.pid);
|
||||
});
|
||||
}
|
||||
return Future<Process>.value(process);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<ProcessResult> run(
|
||||
List<dynamic> command, {
|
||||
String workingDirectory,
|
||||
Map<String, String> environment,
|
||||
bool includeParentEnvironment = true, // ignored
|
||||
bool runInShell = false, // ignored
|
||||
Encoding stdoutEncoding = systemEncoding,
|
||||
Encoding stderrEncoding = systemEncoding,
|
||||
}) async {
|
||||
final _FakeProcess process = _runCommand(command.cast<String>(), workingDirectory, environment, stdoutEncoding);
|
||||
await process.exitCode;
|
||||
return ProcessResult(
|
||||
process.pid,
|
||||
process._exitCode,
|
||||
stdoutEncoding == null ? process.stdout : await stdoutEncoding.decodeStream(process.stdout),
|
||||
stderrEncoding == null ? process.stderr : await stderrEncoding.decodeStream(process.stderr),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
ProcessResult runSync(
|
||||
List<dynamic> command, {
|
||||
String workingDirectory,
|
||||
Map<String, String> environment,
|
||||
bool includeParentEnvironment = true, // ignored
|
||||
bool runInShell = false, // ignored
|
||||
Encoding stdoutEncoding = systemEncoding, // actual encoder is ignored
|
||||
Encoding stderrEncoding = systemEncoding, // actual encoder is ignored
|
||||
}) {
|
||||
final _FakeProcess process = _runCommand(command.cast<String>(), workingDirectory, environment, stdoutEncoding);
|
||||
return ProcessResult(
|
||||
process.pid,
|
||||
process._exitCode,
|
||||
stdoutEncoding == null ? utf8.encode(process._stdout) : process._stdout,
|
||||
stderrEncoding == null ? utf8.encode(process._stderr) : process._stderr,
|
||||
);
|
||||
}
|
||||
|
||||
/// Returns false if executable in [excludedExecutables].
|
||||
@override
|
||||
bool canRun(dynamic executable, {String workingDirectory}) => !excludedExecutables.contains(executable);
|
||||
|
||||
Set<String> excludedExecutables = <String>{};
|
||||
|
||||
@override
|
||||
bool killPid(int pid, [ProcessSignal signal = ProcessSignal.sigterm]) {
|
||||
// Killing a fake process has no effect unless it has an attached completer.
|
||||
final _FakeProcess fakeProcess = _fakeRunningProcesses[pid];
|
||||
if (fakeProcess == null) {
|
||||
return false;
|
||||
}
|
||||
fakeProcess._completer.complete();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
class _FakeAnyProcessManager extends FakeProcessManager {
|
||||
_FakeAnyProcessManager() : super._();
|
||||
|
||||
@override
|
||||
FakeCommand findCommand(
|
||||
List<String> command,
|
||||
String workingDirectory,
|
||||
Map<String, String> environment,
|
||||
Encoding encoding,
|
||||
) {
|
||||
return FakeCommand(
|
||||
command: command,
|
||||
workingDirectory: workingDirectory,
|
||||
environment: environment,
|
||||
encoding: encoding,
|
||||
duration: Duration.zero,
|
||||
exitCode: 0,
|
||||
stdout: '',
|
||||
stderr: '',
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void addCommand(FakeCommand command) { }
|
||||
|
||||
@override
|
||||
bool get hasRemainingExpectations => true;
|
||||
}
|
||||
|
||||
class _SequenceProcessManager extends FakeProcessManager {
|
||||
_SequenceProcessManager(this._commands) : super._();
|
||||
|
||||
final List<FakeCommand> _commands;
|
||||
|
||||
@override
|
||||
FakeCommand findCommand(
|
||||
List<String> command,
|
||||
String workingDirectory,
|
||||
Map<String, String> environment,
|
||||
Encoding encoding,
|
||||
) {
|
||||
expect(_commands, isNotEmpty,
|
||||
reason: 'ProcessManager was told to execute $command (in $workingDirectory) '
|
||||
'but the FakeProcessManager.list expected no more processes.'
|
||||
);
|
||||
_commands.first._matches(command, workingDirectory, environment, encoding);
|
||||
return _commands.removeAt(0);
|
||||
}
|
||||
|
||||
@override
|
||||
void addCommand(FakeCommand command) {
|
||||
_commands.add(command);
|
||||
}
|
||||
|
||||
@override
|
||||
bool get hasRemainingExpectations => _commands.isNotEmpty;
|
||||
}
|
@ -9,8 +9,8 @@ import 'package:dev_tools/roll_dev.dart';
|
||||
import 'package:dev_tools/globals.dart';
|
||||
import 'package:dev_tools/repository.dart';
|
||||
|
||||
import '../../../packages/flutter_tools/test/src/fake_process_manager.dart';
|
||||
import './common.dart';
|
||||
import 'fake_process_manager.dart';
|
||||
|
||||
void main() {
|
||||
group('rollDev()', () {
|
||||
|
@ -7,6 +7,7 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../android/android_builder.dart';
|
||||
import '../android/android_sdk.dart';
|
||||
|
@ -5,6 +5,7 @@
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../base/common.dart';
|
||||
import '../base/file_system.dart';
|
||||
|
@ -7,6 +7,7 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../android/android_sdk.dart';
|
||||
import '../android/android_workflow.dart';
|
||||
|
@ -5,6 +5,7 @@
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../base/common.dart';
|
||||
import '../base/context.dart';
|
||||
@ -13,7 +14,6 @@ import '../base/io.dart';
|
||||
import '../base/logger.dart';
|
||||
import '../base/os.dart';
|
||||
import '../base/platform.dart';
|
||||
import '../base/process.dart';
|
||||
import '../base/user_messages.dart' hide userMessages;
|
||||
import '../base/version.dart';
|
||||
import '../convert.dart';
|
||||
|
@ -7,6 +7,7 @@
|
||||
import 'dart:collection';
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:process/process.dart';
|
||||
import 'package:xml/xml.dart';
|
||||
|
||||
import 'android/android_sdk.dart';
|
||||
|
@ -5,11 +5,11 @@
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import 'base/common.dart';
|
||||
import 'base/file_system.dart';
|
||||
import 'base/platform.dart';
|
||||
import 'base/process.dart';
|
||||
import 'base/utils.dart';
|
||||
import 'build_info.dart';
|
||||
import 'cache.dart';
|
||||
|
@ -5,6 +5,7 @@
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../artifacts.dart';
|
||||
import '../build_info.dart';
|
||||
|
@ -5,18 +5,17 @@
|
||||
// @dart = 2.8
|
||||
|
||||
import 'dart:convert';
|
||||
import 'dart:io' as io show Directory, File, Link, ProcessException, ProcessResult, systemEncoding, Process, ProcessStartMode;
|
||||
import 'dart:io' as io show Directory, File, Link, ProcessException, ProcessResult, ProcessSignal, systemEncoding, Process, ProcessStartMode;
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:file/file.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:path/path.dart' as p; // ignore: package_path_import
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../reporting/reporting.dart';
|
||||
import 'common.dart' show throwToolExit;
|
||||
import 'io.dart';
|
||||
import 'platform.dart';
|
||||
import 'process.dart';
|
||||
|
||||
// The Flutter tool hits file system and process errors that only the end-user can address.
|
||||
// We would like these errors to not hit crash logging. In these cases, we
|
||||
@ -674,7 +673,7 @@ class ErrorHandlingProcessManager extends ProcessManager {
|
||||
}
|
||||
|
||||
@override
|
||||
bool canRun(String executable, {String workingDirectory}) {
|
||||
bool canRun(dynamic executable, {String workingDirectory}) {
|
||||
return _runSync(
|
||||
() => _delegate.canRun(executable, workingDirectory: workingDirectory),
|
||||
platform: _platform,
|
||||
@ -682,7 +681,7 @@ class ErrorHandlingProcessManager extends ProcessManager {
|
||||
}
|
||||
|
||||
@override
|
||||
bool killPid(int pid, [ProcessSignal signal = ProcessSignal.SIGTERM]) {
|
||||
bool killPid(int pid, [io.ProcessSignal signal = io.ProcessSignal.sigterm]) {
|
||||
return _runSync(
|
||||
() => _delegate.killPid(pid, signal),
|
||||
platform: _platform,
|
||||
@ -691,7 +690,7 @@ class ErrorHandlingProcessManager extends ProcessManager {
|
||||
|
||||
@override
|
||||
Future<io.ProcessResult> run(
|
||||
List<String> command, {
|
||||
List<dynamic> command, {
|
||||
String workingDirectory,
|
||||
Map<String, String> environment,
|
||||
bool includeParentEnvironment = true,
|
||||
@ -725,7 +724,7 @@ class ErrorHandlingProcessManager extends ProcessManager {
|
||||
|
||||
@override
|
||||
Future<io.Process> start(
|
||||
List<String> command, {
|
||||
List<dynamic> command, {
|
||||
String workingDirectory,
|
||||
Map<String, String> environment,
|
||||
bool includeParentEnvironment = true,
|
||||
@ -754,7 +753,7 @@ class ErrorHandlingProcessManager extends ProcessManager {
|
||||
|
||||
@override
|
||||
io.ProcessResult runSync(
|
||||
List<String> command, {
|
||||
List<dynamic> command, {
|
||||
String workingDirectory,
|
||||
Map<String, String> environment,
|
||||
bool includeParentEnvironment = true,
|
||||
|
@ -7,6 +7,7 @@
|
||||
import 'package:archive/archive.dart';
|
||||
import 'package:file/file.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../build_info.dart';
|
||||
import '../globals.dart' as globals;
|
||||
|
@ -7,15 +7,13 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:file/local.dart' as local_fs;
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../convert.dart';
|
||||
import 'common.dart';
|
||||
import 'context.dart';
|
||||
import 'file_system.dart';
|
||||
import 'io.dart';
|
||||
import 'logger.dart';
|
||||
import 'platform.dart';
|
||||
|
||||
typedef StringConverter = String Function(String string);
|
||||
|
||||
@ -609,386 +607,3 @@ class _DefaultProcessUtils implements ProcessUtils {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Manages the creation of abstract processes.
|
||||
///
|
||||
/// Using instances of this class provides level of indirection from the static
|
||||
/// methods in the [Process] class, which in turn allows the underlying
|
||||
/// implementation to be mocked out or decorated for testing and debugging
|
||||
/// purposes.
|
||||
abstract class ProcessManager {
|
||||
/// Starts a process by running the specified [command].
|
||||
///
|
||||
/// The first element in [command] will be treated as the executable to run,
|
||||
/// with subsequent elements being passed as arguments to the executable. It
|
||||
/// is left to implementations to decide what element types they support in
|
||||
/// the [command] list.
|
||||
///
|
||||
/// Returns a `Future<Process>` that completes with a Process instance when
|
||||
/// the process has been successfully started. That [Process] object can be
|
||||
/// used to interact with the process. If the process cannot be started, the
|
||||
/// returned [Future] completes with an exception.
|
||||
///
|
||||
/// Use [workingDirectory] to set the working directory for the process. Note
|
||||
/// that the change of directory occurs before executing the process on some
|
||||
/// platforms, which may have impact when using relative paths for the
|
||||
/// executable and the arguments.
|
||||
///
|
||||
/// Use [environment] to set the environment variables for the process. If not
|
||||
/// set, the environment of the parent process is inherited. Currently, only
|
||||
/// US-ASCII environment variables are supported and errors are likely to occur
|
||||
/// if an environment variable with code-points outside the US-ASCII range is
|
||||
/// passed in.
|
||||
///
|
||||
/// If [includeParentEnvironment] is `true`, the process's environment will
|
||||
/// include the parent process's environment, with [environment] taking
|
||||
/// precedence. Default is `true`.
|
||||
///
|
||||
/// If [runInShell] is `true`, the process will be spawned through a system
|
||||
/// shell. On Linux and OS X, `/bin/sh` is used, while
|
||||
/// `%WINDIR%\system32\cmd.exe` is used on Windows.
|
||||
///
|
||||
/// Users must read all data coming on the `stdout` and `stderr`
|
||||
/// streams of processes started with [start]. If the user
|
||||
/// does not read all data on the streams the underlying system
|
||||
/// resources will not be released since there is still pending data.
|
||||
///
|
||||
/// The following code uses `start` to grep for `main` in the
|
||||
/// file `test.dart` on Linux.
|
||||
///
|
||||
/// ProcessManager mgr = new LocalProcessManager();
|
||||
/// mgr.start('grep', ['-i', 'main', 'test.dart']).then((process) {
|
||||
/// stdout.addStream(process.stdout);
|
||||
/// stderr.addStream(process.stderr);
|
||||
/// });
|
||||
///
|
||||
/// If [mode] is [ProcessStartMode.normal] (the default) a child
|
||||
/// process will be started with `stdin`, `stdout` and `stderr`
|
||||
/// connected.
|
||||
///
|
||||
/// If `mode` is [ProcessStartMode.detached] a detached process will
|
||||
/// be created. A detached process has no connection to its parent,
|
||||
/// and can keep running on its own when the parent dies. The only
|
||||
/// information available from a detached process is its `pid`. There
|
||||
/// is no connection to its `stdin`, `stdout` or `stderr`, nor will
|
||||
/// the process' exit code become available when it terminates.
|
||||
///
|
||||
/// If `mode` is [ProcessStartMode.detachedWithStdio] a detached
|
||||
/// process will be created where the `stdin`, `stdout` and `stderr`
|
||||
/// are connected. The creator can communicate with the child through
|
||||
/// these. The detached process will keep running even if these
|
||||
/// communication channels are closed. The process' exit code will
|
||||
/// not become available when it terminated.
|
||||
///
|
||||
/// The default value for `mode` is `ProcessStartMode.NORMAL`.
|
||||
Future<Process> start(
|
||||
List<String> command, {
|
||||
String workingDirectory,
|
||||
Map<String, String> environment,
|
||||
bool includeParentEnvironment = true,
|
||||
bool runInShell = false,
|
||||
ProcessStartMode mode = ProcessStartMode.normal,
|
||||
});
|
||||
|
||||
/// Starts a process and runs it non-interactively to completion.
|
||||
///
|
||||
/// The first element in [command] will be treated as the executable to run,
|
||||
/// with subsequent elements being passed as arguments to the executable.
|
||||
///
|
||||
/// Use [workingDirectory] to set the working directory for the process. Note
|
||||
/// that the change of directory occurs before executing the process on some
|
||||
/// platforms, which may have impact when using relative paths for the
|
||||
/// executable and the arguments.
|
||||
///
|
||||
/// Use [environment] to set the environment variables for the process. If not
|
||||
/// set the environment of the parent process is inherited. Currently, only
|
||||
/// US-ASCII environment variables are supported and errors are likely to occur
|
||||
/// if an environment variable with code-points outside the US-ASCII range is
|
||||
/// passed in.
|
||||
///
|
||||
/// If [includeParentEnvironment] is `true`, the process's environment will
|
||||
/// include the parent process's environment, with [environment] taking
|
||||
/// precedence. Default is `true`.
|
||||
///
|
||||
/// If [runInShell] is true, the process will be spawned through a system
|
||||
/// shell. On Linux and OS X, `/bin/sh` is used, while
|
||||
/// `%WINDIR%\system32\cmd.exe` is used on Windows.
|
||||
///
|
||||
/// The encoding used for decoding `stdout` and `stderr` into text is
|
||||
/// controlled through [stdoutEncoding] and [stderrEncoding]. The
|
||||
/// default encoding is [systemEncoding]. If `null` is used no
|
||||
/// decoding will happen and the [ProcessResult] will hold binary
|
||||
/// data.
|
||||
///
|
||||
/// Returns a `Future<ProcessResult>` that completes with the
|
||||
/// result of running the process, i.e., exit code, standard out and
|
||||
/// standard in.
|
||||
///
|
||||
/// The following code uses `run` to grep for `main` in the
|
||||
/// file `test.dart` on Linux.
|
||||
///
|
||||
/// ProcessManager mgr = new LocalProcessManager();
|
||||
/// mgr.run('grep', ['-i', 'main', 'test.dart']).then((result) {
|
||||
/// stdout.write(result.stdout);
|
||||
/// stderr.write(result.stderr);
|
||||
/// });
|
||||
Future<ProcessResult> run(
|
||||
List<String> command, {
|
||||
String workingDirectory,
|
||||
Map<String, String> environment,
|
||||
bool includeParentEnvironment = true,
|
||||
bool runInShell = false,
|
||||
Encoding stdoutEncoding = systemEncoding,
|
||||
Encoding stderrEncoding = systemEncoding,
|
||||
});
|
||||
|
||||
/// Starts a process and runs it to completion. This is a synchronous
|
||||
/// call and will block until the child process terminates.
|
||||
///
|
||||
/// The arguments are the same as for [run]`.
|
||||
///
|
||||
/// Returns a `ProcessResult` with the result of running the process,
|
||||
/// i.e., exit code, standard out and standard in.
|
||||
ProcessResult runSync(
|
||||
List<String> command, {
|
||||
String workingDirectory,
|
||||
Map<String, String> environment,
|
||||
bool includeParentEnvironment = true,
|
||||
bool runInShell = false,
|
||||
Encoding stdoutEncoding = systemEncoding,
|
||||
Encoding stderrEncoding = systemEncoding,
|
||||
});
|
||||
|
||||
/// Returns `true` if the [executable] exists and if it can be executed.
|
||||
bool canRun(String executable, {String workingDirectory});
|
||||
|
||||
/// Kills the process with id [pid].
|
||||
///
|
||||
/// Where possible, sends the [signal] to the process with id
|
||||
/// `pid`. This includes Linux and OS X. The default signal is
|
||||
/// [ProcessSignal.sigterm] which will normally terminate the
|
||||
/// process.
|
||||
///
|
||||
/// On platforms without signal support, including Windows, the call
|
||||
/// just terminates the process with id `pid` in a platform specific
|
||||
/// way, and the `signal` parameter is ignored.
|
||||
///
|
||||
/// Returns `true` if the signal is successfully delivered to the
|
||||
/// process. Otherwise the signal could not be sent, usually meaning
|
||||
/// that the process is already dead.
|
||||
bool killPid(int pid, [ProcessSignal signal = ProcessSignal.SIGTERM]);
|
||||
}
|
||||
|
||||
/// A process manager that delegates directly to the dart:io Process class.
|
||||
class LocalProcessManager implements ProcessManager {
|
||||
const LocalProcessManager({
|
||||
@visibleForTesting FileSystem fileSystem = const local_fs.LocalFileSystem(),
|
||||
@visibleForTesting Platform platform = const LocalPlatform(),
|
||||
}) : _platform = platform,
|
||||
_fileSystem = fileSystem;
|
||||
|
||||
final Platform _platform;
|
||||
final FileSystem _fileSystem;
|
||||
|
||||
@override
|
||||
bool canRun(String executable, {String workingDirectory}) {
|
||||
return getExecutablePath(executable, workingDirectory, platform: _platform, fileSystem: _fileSystem) != null;
|
||||
}
|
||||
|
||||
@override
|
||||
bool killPid(int pid, [ProcessSignal signal = ProcessSignal.SIGTERM]) {
|
||||
return signal.send(pid);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<ProcessResult> run(List<String> command, {
|
||||
String workingDirectory,
|
||||
Map<String, String> environment,
|
||||
bool includeParentEnvironment = true,
|
||||
bool runInShell = false,
|
||||
Encoding stdoutEncoding = systemEncoding,
|
||||
Encoding stderrEncoding = systemEncoding,
|
||||
}) {
|
||||
return Process.run(
|
||||
sanitizeExecutablePath(_getExecutable(
|
||||
command,
|
||||
workingDirectory,
|
||||
runInShell,
|
||||
), platform: _platform),
|
||||
_getArguments(command),
|
||||
environment: environment,
|
||||
includeParentEnvironment: includeParentEnvironment,
|
||||
stdoutEncoding: systemEncoding,
|
||||
stderrEncoding: systemEncoding,
|
||||
workingDirectory: workingDirectory,
|
||||
runInShell: runInShell,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
ProcessResult runSync(List<String> command, {
|
||||
String workingDirectory,
|
||||
Map<String, String> environment,
|
||||
bool includeParentEnvironment = true,
|
||||
bool runInShell = false,
|
||||
Encoding stdoutEncoding = systemEncoding,
|
||||
Encoding stderrEncoding = systemEncoding,
|
||||
}) {
|
||||
return Process.runSync(
|
||||
sanitizeExecutablePath(_getExecutable(
|
||||
command,
|
||||
workingDirectory,
|
||||
runInShell,
|
||||
), platform: _platform),
|
||||
_getArguments(command),
|
||||
environment: environment,
|
||||
includeParentEnvironment: includeParentEnvironment,
|
||||
stdoutEncoding: systemEncoding,
|
||||
stderrEncoding: systemEncoding,
|
||||
workingDirectory: workingDirectory,
|
||||
runInShell: runInShell,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Process> start(
|
||||
List<String> command, {
|
||||
String workingDirectory,
|
||||
Map<String, String> environment,
|
||||
bool includeParentEnvironment = true,
|
||||
bool runInShell = false,
|
||||
ProcessStartMode mode = ProcessStartMode.normal,
|
||||
}) {
|
||||
return Process.start(
|
||||
sanitizeExecutablePath(_getExecutable(
|
||||
command,
|
||||
workingDirectory,
|
||||
runInShell,
|
||||
), platform: _platform),
|
||||
_getArguments(command),
|
||||
workingDirectory: workingDirectory,
|
||||
environment: environment,
|
||||
includeParentEnvironment: includeParentEnvironment,
|
||||
runInShell: runInShell,
|
||||
mode: mode,
|
||||
);
|
||||
}
|
||||
|
||||
String _getExecutable(
|
||||
List<String> command,
|
||||
String workingDirectory,
|
||||
bool runInShell,
|
||||
) {
|
||||
final String commandName = command.first.toString();
|
||||
if (runInShell) {
|
||||
return commandName;
|
||||
}
|
||||
final String executable = getExecutablePath(commandName, workingDirectory, platform: _platform, fileSystem: _fileSystem);
|
||||
if (executable == null) {
|
||||
throw ArgumentError('Could not resolve $commandName to executablePath in $workingDirectory');
|
||||
}
|
||||
return executable;
|
||||
}
|
||||
|
||||
List<String> _getArguments(
|
||||
List<String> command,
|
||||
) {
|
||||
return command.skip(1).toList();
|
||||
}
|
||||
}
|
||||
|
||||
/// Sanatizes the executable path on Windows.
|
||||
/// https://github.com/dart-lang/sdk/issues/37751
|
||||
String sanitizeExecutablePath(String executable, {@required Platform platform }) {
|
||||
if (executable.isEmpty) {
|
||||
return executable;
|
||||
}
|
||||
if (!platform.isWindows) {
|
||||
return executable;
|
||||
}
|
||||
if (executable.contains(' ') && !executable.contains('"')) {
|
||||
// Use quoted strings to indicate where the file name ends and the arguments begin;
|
||||
// otherwise, the file name is ambiguous.
|
||||
return '"$executable"';
|
||||
}
|
||||
return executable;
|
||||
}
|
||||
|
||||
/// Searches the `PATH` for the executable that [command] is supposed to launch.
|
||||
///
|
||||
/// This first builds a list of candidate paths where the executable may reside.
|
||||
/// If [command] is already an absolute path, then the `PATH` environment
|
||||
/// variable will not be consulted, and the specified absolute path will be the
|
||||
/// only candidate that is considered.
|
||||
///
|
||||
/// Once the list of candidate paths has been constructed, this will pick the
|
||||
/// first such path that represents an existent file.
|
||||
///
|
||||
/// Return `null` if there were no viable candidates, meaning the executable
|
||||
/// could not be found.
|
||||
///
|
||||
/// If [platform] is not specified, it will default to the current platform.
|
||||
@visibleForTesting
|
||||
String getExecutablePath(
|
||||
String command,
|
||||
String workingDirectory, {
|
||||
@required Platform platform,
|
||||
@required FileSystem fileSystem,
|
||||
}) {
|
||||
try {
|
||||
workingDirectory ??= fileSystem.currentDirectory.path;
|
||||
} on FileSystemException {
|
||||
// The `currentDirectory` getter can throw a FileSystemException for example
|
||||
// when the process doesn't have read/list permissions in each component of
|
||||
// the cwd path. In this case, fall back on '.'.
|
||||
workingDirectory ??= '.';
|
||||
}
|
||||
final String pathSeparator = platform.isWindows ? ';' : ':';
|
||||
|
||||
List<String> extensions = <String>[];
|
||||
if (platform.isWindows && fileSystem.path.extension(command).isEmpty) {
|
||||
extensions = platform.environment['PATHEXT'].split(pathSeparator);
|
||||
}
|
||||
|
||||
List<String> candidates = <String>[];
|
||||
if (command.contains(fileSystem.path.separator)) {
|
||||
candidates = _getCandidatePaths(
|
||||
command, <String>[workingDirectory], extensions, fileSystem);
|
||||
} else {
|
||||
final List<String> searchPath = platform.environment['PATH'].split(pathSeparator);
|
||||
candidates = _getCandidatePaths(command, searchPath, extensions, fileSystem);
|
||||
}
|
||||
for (final String path in candidates) {
|
||||
if (fileSystem.file(path).existsSync()) {
|
||||
return path;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Returns all possible combinations of `$searchPath\$command.$ext` for
|
||||
/// `searchPath` in [searchPaths] and `ext` in [extensions].
|
||||
///
|
||||
/// If [extensions] is empty, it will just enumerate all
|
||||
/// `$searchPath\$command`.
|
||||
/// If [command] is an absolute path, it will just enumerate
|
||||
/// `$command.$ext`.
|
||||
List<String> _getCandidatePaths(
|
||||
String command,
|
||||
List<String> searchPaths,
|
||||
List<String> extensions,
|
||||
FileSystem fileSystem,
|
||||
) {
|
||||
final List<String> withExtensions = extensions.isNotEmpty
|
||||
? extensions.map((String ext) => '$command$ext').toList()
|
||||
: <String>[command];
|
||||
if (fileSystem.path.isAbsolute(command)) {
|
||||
return withExtensions;
|
||||
}
|
||||
return searchPaths
|
||||
.map((String path) =>
|
||||
withExtensions.map((String command) => fileSystem.path.join(path, command)))
|
||||
.expand((Iterable<String> e) => e)
|
||||
.toList()
|
||||
.cast<String>();
|
||||
}
|
||||
|
@ -9,13 +9,13 @@ import 'package:convert/convert.dart';
|
||||
import 'package:crypto/crypto.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:pool/pool.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../artifacts.dart';
|
||||
import '../base/error_handling_io.dart';
|
||||
import '../base/file_system.dart';
|
||||
import '../base/logger.dart';
|
||||
import '../base/platform.dart';
|
||||
import '../base/process.dart';
|
||||
import '../base/utils.dart';
|
||||
import '../cache.dart';
|
||||
import '../convert.dart';
|
||||
|
@ -5,6 +5,7 @@
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:process/process.dart';
|
||||
import 'package:mime/mime.dart' as mime;
|
||||
|
||||
import '../../artifacts.dart';
|
||||
@ -12,7 +13,6 @@ import '../../base/common.dart';
|
||||
import '../../base/file_system.dart';
|
||||
import '../../base/io.dart';
|
||||
import '../../base/logger.dart';
|
||||
import '../../base/process.dart';
|
||||
import '../../convert.dart';
|
||||
import '../../devfs.dart';
|
||||
import '../build_system.dart';
|
||||
|
@ -10,6 +10,7 @@ import 'package:crypto/crypto.dart';
|
||||
import 'package:file/memory.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:package_config/package_config.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import 'android/gradle_utils.dart';
|
||||
import 'base/common.dart';
|
||||
|
@ -5,12 +5,12 @@
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../artifacts.dart';
|
||||
import '../base/file_system.dart';
|
||||
import '../base/logger.dart';
|
||||
import '../base/platform.dart';
|
||||
import '../base/process.dart';
|
||||
import '../base/terminal.dart';
|
||||
import '../runner/flutter_command.dart';
|
||||
import 'analyze_continuously.dart';
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
import 'package:args/args.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:process/process.dart';
|
||||
import 'package:yaml/yaml.dart' as yaml;
|
||||
|
||||
import '../artifacts.dart';
|
||||
@ -13,7 +14,6 @@ import '../base/common.dart';
|
||||
import '../base/file_system.dart';
|
||||
import '../base/logger.dart';
|
||||
import '../base/platform.dart';
|
||||
import '../base/process.dart';
|
||||
import '../base/terminal.dart';
|
||||
import '../base/utils.dart';
|
||||
import '../cache.dart';
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
import 'package:args/args.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../artifacts.dart';
|
||||
import '../base/common.dart';
|
||||
@ -13,7 +14,6 @@ import '../base/file_system.dart';
|
||||
import '../base/io.dart';
|
||||
import '../base/logger.dart';
|
||||
import '../base/platform.dart';
|
||||
import '../base/process.dart';
|
||||
import '../base/terminal.dart';
|
||||
import '../dart/analysis.dart';
|
||||
import 'analyze_base.dart';
|
||||
|
@ -8,13 +8,13 @@ import 'dart:async';
|
||||
|
||||
import 'package:args/args.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../artifacts.dart';
|
||||
import '../base/common.dart';
|
||||
import '../base/file_system.dart';
|
||||
import '../base/logger.dart';
|
||||
import '../base/platform.dart';
|
||||
import '../base/process.dart';
|
||||
import '../base/terminal.dart';
|
||||
import '../dart/analysis.dart';
|
||||
import 'analyze_base.dart';
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../base/common.dart';
|
||||
import '../base/file_system.dart';
|
||||
import '../base/io.dart';
|
||||
|
@ -8,6 +8,7 @@ import 'dart:async';
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:package_config/package_config.dart';
|
||||
import 'package:process/process.dart';
|
||||
import 'package:usage/uuid/uuid.dart';
|
||||
|
||||
import 'artifacts.dart';
|
||||
@ -16,7 +17,6 @@ import 'base/file_system.dart';
|
||||
import 'base/io.dart';
|
||||
import 'base/logger.dart';
|
||||
import 'base/platform.dart';
|
||||
import 'base/process.dart';
|
||||
import 'build_info.dart';
|
||||
import 'convert.dart';
|
||||
|
||||
|
@ -6,6 +6,8 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import 'android/android_sdk.dart';
|
||||
import 'android/android_studio.dart';
|
||||
import 'android/android_workflow.dart';
|
||||
|
@ -8,13 +8,13 @@ import 'dart:async';
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../base/common.dart';
|
||||
import '../base/file_system.dart';
|
||||
import '../base/io.dart';
|
||||
import '../base/logger.dart';
|
||||
import '../base/platform.dart';
|
||||
import '../base/process.dart';
|
||||
import '../base/terminal.dart';
|
||||
import '../base/utils.dart';
|
||||
import '../convert.dart';
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:package_config/package_config.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../base/bot_detector.dart';
|
||||
import '../base/common.dart';
|
||||
|
@ -7,6 +7,7 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import 'application_package.dart';
|
||||
import 'base/common.dart';
|
||||
@ -14,7 +15,6 @@ import 'base/file_system.dart';
|
||||
import 'base/io.dart';
|
||||
import 'base/logger.dart';
|
||||
import 'base/os.dart';
|
||||
import 'base/process.dart';
|
||||
import 'build_info.dart';
|
||||
import 'convert.dart';
|
||||
import 'devfs.dart';
|
||||
|
@ -8,6 +8,7 @@ import 'dart:async';
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:process/process.dart';
|
||||
import 'package:vm_service/vm_service.dart' as vm_service;
|
||||
|
||||
import 'android/android_device_discovery.dart';
|
||||
@ -24,7 +25,6 @@ import 'base/io.dart';
|
||||
import 'base/logger.dart';
|
||||
import 'base/os.dart';
|
||||
import 'base/platform.dart';
|
||||
import 'base/process.dart';
|
||||
import 'base/terminal.dart';
|
||||
import 'base/user_messages.dart' hide userMessages;
|
||||
import 'base/utils.dart';
|
||||
|
@ -8,11 +8,11 @@ import 'dart:async';
|
||||
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import 'base/io.dart' as io;
|
||||
import 'base/logger.dart';
|
||||
import 'base/platform.dart';
|
||||
import 'base/process.dart';
|
||||
import 'convert.dart';
|
||||
import 'persistent_tool_state.dart';
|
||||
import 'resident_runner.dart';
|
||||
|
@ -5,6 +5,7 @@
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import 'android/android_studio_validator.dart';
|
||||
import 'android/android_workflow.dart';
|
||||
@ -15,7 +16,6 @@ import 'base/file_system.dart';
|
||||
import 'base/logger.dart';
|
||||
import 'base/os.dart';
|
||||
import 'base/platform.dart';
|
||||
import 'base/process.dart';
|
||||
import 'base/terminal.dart';
|
||||
import 'base/user_messages.dart';
|
||||
import 'base/utils.dart';
|
||||
|
@ -7,6 +7,7 @@
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import 'android/android_emulator.dart';
|
||||
import 'android/android_sdk.dart';
|
||||
|
@ -5,6 +5,7 @@
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../base/common.dart';
|
||||
import '../base/logger.dart';
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import 'android/android_sdk.dart';
|
||||
import 'android/android_studio.dart';
|
||||
import 'artifacts.dart';
|
||||
@ -80,8 +82,10 @@ FileSystemUtils get fsUtils => context.get<FileSystemUtils>() ?? FileSystemUtils
|
||||
platform: platform,
|
||||
);
|
||||
|
||||
const ProcessManager _kLocalProcessManager = LocalProcessManager();
|
||||
|
||||
/// The active process manager.
|
||||
ProcessManager get processManager => context.get<ProcessManager>();
|
||||
ProcessManager get processManager => context.get<ProcessManager>() ?? _kLocalProcessManager;
|
||||
ProcessUtils get processUtils => context.get<ProcessUtils>();
|
||||
|
||||
const Platform _kLocalPlatform = LocalPlatform();
|
||||
|
@ -5,6 +5,7 @@
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../application_package.dart';
|
||||
import '../base/common.dart';
|
||||
|
@ -7,6 +7,7 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:process/process.dart';
|
||||
import 'package:vm_service/vm_service.dart' as vm_service;
|
||||
|
||||
import '../application_package.dart';
|
||||
@ -16,7 +17,6 @@ import '../base/io.dart';
|
||||
import '../base/logger.dart';
|
||||
import '../base/os.dart';
|
||||
import '../base/platform.dart';
|
||||
import '../base/process.dart';
|
||||
import '../base/utils.dart';
|
||||
import '../build_info.dart';
|
||||
import '../convert.dart';
|
||||
|
@ -7,6 +7,7 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../artifacts.dart';
|
||||
import '../base/common.dart';
|
||||
|
@ -5,6 +5,7 @@
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../base/io.dart';
|
||||
import '../base/logger.dart';
|
||||
|
@ -5,6 +5,7 @@
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../application_package.dart';
|
||||
import '../artifacts.dart';
|
||||
|
@ -5,6 +5,7 @@
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../base/file_system.dart';
|
||||
import '../base/io.dart';
|
||||
|
@ -8,6 +8,7 @@ import 'dart:async';
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../application_package.dart';
|
||||
import '../base/common.dart';
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
import 'package:file/memory.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../artifacts.dart';
|
||||
import '../base/common.dart';
|
||||
|
@ -5,12 +5,12 @@
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../base/file_system.dart';
|
||||
import '../base/logger.dart';
|
||||
import '../base/os.dart';
|
||||
import '../base/platform.dart';
|
||||
import '../base/process.dart';
|
||||
import '../build_info.dart';
|
||||
import '../desktop_device.dart';
|
||||
import '../device.dart';
|
||||
|
@ -5,9 +5,9 @@
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../base/io.dart';
|
||||
import '../base/process.dart';
|
||||
import '../base/user_messages.dart';
|
||||
import '../base/version.dart';
|
||||
import '../doctor.dart';
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
import 'package:file/file.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../base/common.dart';
|
||||
import '../base/error_handling_io.dart';
|
||||
|
@ -5,13 +5,13 @@
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../base/file_system.dart';
|
||||
import '../base/io.dart';
|
||||
import '../base/logger.dart';
|
||||
import '../base/os.dart';
|
||||
import '../base/platform.dart';
|
||||
import '../base/process.dart';
|
||||
import '../build_info.dart';
|
||||
import '../desktop_device.dart';
|
||||
import '../device.dart';
|
||||
|
@ -8,6 +8,7 @@ import 'dart:async';
|
||||
|
||||
import 'package:file/memory.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../artifacts.dart';
|
||||
import '../base/common.dart';
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:package_config/package_config.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../artifacts.dart';
|
||||
import '../base/common.dart';
|
||||
@ -13,7 +14,6 @@ import '../base/config.dart';
|
||||
import '../base/file_system.dart';
|
||||
import '../base/logger.dart';
|
||||
import '../base/platform.dart';
|
||||
import '../base/process.dart';
|
||||
import '../build_info.dart';
|
||||
import '../bundle.dart';
|
||||
import '../compile.dart';
|
||||
|
@ -7,6 +7,7 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../application_package.dart';
|
||||
import '../artifacts.dart';
|
||||
@ -14,7 +15,6 @@ import '../base/config.dart';
|
||||
import '../base/file_system.dart';
|
||||
import '../base/io.dart';
|
||||
import '../base/logger.dart';
|
||||
import '../base/process.dart';
|
||||
import '../build_info.dart';
|
||||
import '../bundle.dart';
|
||||
import '../convert.dart';
|
||||
|
@ -7,6 +7,7 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:process/process.dart';
|
||||
import 'package:webkit_inspection_protocol/webkit_inspection_protocol.dart';
|
||||
|
||||
import '../base/common.dart';
|
||||
@ -15,7 +16,6 @@ import '../base/io.dart';
|
||||
import '../base/logger.dart';
|
||||
import '../base/os.dart';
|
||||
import '../base/platform.dart';
|
||||
import '../base/process.dart';
|
||||
import '../convert.dart';
|
||||
|
||||
/// An environment variable used to override the location of Google Chrome.
|
||||
|
@ -5,6 +5,7 @@
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../application_package.dart';
|
||||
import '../base/file_system.dart';
|
||||
@ -12,7 +13,6 @@ import '../base/io.dart';
|
||||
import '../base/logger.dart';
|
||||
import '../base/os.dart';
|
||||
import '../base/platform.dart';
|
||||
import '../base/process.dart';
|
||||
import '../base/version.dart';
|
||||
import '../build_info.dart';
|
||||
import '../device.dart';
|
||||
|
@ -5,6 +5,7 @@
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../base/file_system.dart';
|
||||
import '../base/io.dart';
|
||||
|
@ -5,11 +5,11 @@
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../base/file_system.dart';
|
||||
import '../base/logger.dart';
|
||||
import '../base/os.dart';
|
||||
import '../base/process.dart';
|
||||
import '../build_info.dart';
|
||||
import '../desktop_device.dart';
|
||||
import '../device.dart';
|
||||
|
@ -13,7 +13,6 @@ 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/platform.dart';
|
||||
import 'package:flutter_tools/src/base/process.dart';
|
||||
import 'package:flutter_tools/src/base/terminal.dart';
|
||||
import 'package:flutter_tools/src/cache.dart';
|
||||
import 'package:flutter_tools/src/commands/analyze.dart';
|
||||
@ -21,6 +20,7 @@ import 'package:flutter_tools/src/dart/analysis.dart';
|
||||
import 'package:flutter_tools/src/dart/pub.dart';
|
||||
import 'package:flutter_tools/src/globals.dart' as globals;
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../../src/common.dart';
|
||||
import '../../src/context.dart';
|
||||
@ -41,10 +41,7 @@ void main() {
|
||||
setUp(() {
|
||||
fileSystem = LocalFileSystem.instance;
|
||||
platform = const LocalPlatform();
|
||||
processManager = LocalProcessManager(
|
||||
fileSystem: fileSystem,
|
||||
platform: platform,
|
||||
);
|
||||
processManager = const LocalProcessManager();
|
||||
terminal = AnsiTerminal(platform: platform, stdio: Stdio());
|
||||
logger = BufferLogger(outputPreferences: OutputPreferences.test(), terminal: terminal);
|
||||
tempDir = fileSystem.systemTempDirectory.createTempSync('flutter_analysis_test.');
|
||||
|
@ -26,6 +26,7 @@ import 'package:flutter_tools/src/run_hot.dart';
|
||||
import 'package:flutter_tools/src/vmservice.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:process/process.dart';
|
||||
import 'package:vm_service/vm_service.dart' as vm_service;
|
||||
|
||||
import '../../src/common.dart';
|
||||
|
@ -18,6 +18,7 @@ import 'package:flutter_tools/src/fuchsia/fuchsia_sdk.dart';
|
||||
import 'package:flutter_tools/src/project.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../../src/common.dart';
|
||||
import '../../src/context.dart';
|
||||
|
@ -8,11 +8,11 @@ import 'package:file/memory.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/base/logger.dart';
|
||||
import 'package:flutter_tools/src/base/platform.dart';
|
||||
import 'package:flutter_tools/src/base/process.dart';
|
||||
import 'package:flutter_tools/src/cache.dart';
|
||||
import 'package:flutter_tools/src/commands/build.dart';
|
||||
import 'package:flutter_tools/src/ios/xcodeproj.dart';
|
||||
import 'package:flutter_tools/src/reporting/reporting.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../../src/common.dart';
|
||||
import '../../src/context.dart';
|
||||
|
@ -9,7 +9,6 @@ import 'package:file/memory.dart';
|
||||
import 'package:file_testing/file_testing.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/base/platform.dart';
|
||||
import 'package:flutter_tools/src/base/process.dart';
|
||||
import 'package:flutter_tools/src/base/utils.dart';
|
||||
import 'package:flutter_tools/src/cache.dart';
|
||||
import 'package:flutter_tools/src/cmake.dart';
|
||||
@ -18,6 +17,7 @@ import 'package:flutter_tools/src/commands/build_linux.dart';
|
||||
import 'package:flutter_tools/src/features.dart';
|
||||
import 'package:flutter_tools/src/project.dart';
|
||||
import 'package:flutter_tools/src/reporting/reporting.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../../src/common.dart';
|
||||
import '../../src/context.dart';
|
||||
|
@ -12,7 +12,6 @@ import 'package:flutter_tools/src/artifacts.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/base/logger.dart';
|
||||
import 'package:flutter_tools/src/base/platform.dart';
|
||||
import 'package:flutter_tools/src/base/process.dart';
|
||||
import 'package:flutter_tools/src/build_info.dart';
|
||||
import 'package:flutter_tools/src/cache.dart';
|
||||
import 'package:flutter_tools/src/commands/build.dart';
|
||||
@ -21,6 +20,7 @@ import 'package:flutter_tools/src/features.dart';
|
||||
import 'package:flutter_tools/src/ios/xcodeproj.dart';
|
||||
import 'package:flutter_tools/src/project.dart';
|
||||
import 'package:flutter_tools/src/reporting/reporting.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../../src/common.dart';
|
||||
import '../../src/context.dart';
|
||||
|
@ -8,7 +8,6 @@ import 'package:args/command_runner.dart';
|
||||
import 'package:file/memory.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/base/platform.dart';
|
||||
import 'package:flutter_tools/src/base/process.dart';
|
||||
import 'package:flutter_tools/src/build_info.dart';
|
||||
import 'package:flutter_tools/src/build_system/build_system.dart';
|
||||
import 'package:flutter_tools/src/cache.dart';
|
||||
|
@ -8,13 +8,13 @@ import 'package:file/memory.dart';
|
||||
import 'package:file_testing/file_testing.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/base/platform.dart';
|
||||
import 'package:flutter_tools/src/base/process.dart';
|
||||
import 'package:flutter_tools/src/cache.dart';
|
||||
import 'package:flutter_tools/src/commands/build_windows.dart';
|
||||
import 'package:flutter_tools/src/features.dart';
|
||||
import 'package:flutter_tools/src/reporting/reporting.dart';
|
||||
import 'package:flutter_tools/src/windows/visual_studio.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../../src/common.dart';
|
||||
import '../../src/context.dart';
|
||||
|
@ -9,12 +9,12 @@ import 'package:flutter_tools/src/base/context.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/base/logger.dart';
|
||||
import 'package:flutter_tools/src/base/platform.dart';
|
||||
import 'package:flutter_tools/src/base/process.dart';
|
||||
import 'package:flutter_tools/src/commands/clean.dart';
|
||||
import 'package:flutter_tools/src/ios/xcodeproj.dart';
|
||||
import 'package:flutter_tools/src/macos/xcode.dart';
|
||||
import 'package:flutter_tools/src/project.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../../src/common.dart';
|
||||
import '../../src/context.dart';
|
||||
|
@ -8,11 +8,11 @@ import 'dart:convert';
|
||||
|
||||
import 'package:flutter_tools/src/android/android_sdk.dart';
|
||||
import 'package:flutter_tools/src/artifacts.dart';
|
||||
import 'package:flutter_tools/src/base/process.dart';
|
||||
import 'package:flutter_tools/src/cache.dart';
|
||||
import 'package:flutter_tools/src/commands/devices.dart';
|
||||
import 'package:flutter_tools/src/device.dart';
|
||||
import 'package:flutter_tools/src/globals.dart' as globals;
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../../src/common.dart';
|
||||
import '../../src/context.dart';
|
||||
|
@ -14,7 +14,6 @@ import 'package:flutter_tools/src/base/common.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/base/logger.dart';
|
||||
import 'package:flutter_tools/src/base/platform.dart';
|
||||
import 'package:flutter_tools/src/base/process.dart';
|
||||
import 'package:flutter_tools/src/base/terminal.dart';
|
||||
import 'package:flutter_tools/src/base/user_messages.dart';
|
||||
import 'package:flutter_tools/src/build_info.dart';
|
||||
@ -30,6 +29,7 @@ import 'package:flutter_tools/src/vscode/vscode.dart';
|
||||
import 'package:flutter_tools/src/vscode/vscode_validator.dart';
|
||||
import 'package:flutter_tools/src/web/workflow.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:process/process.dart';
|
||||
import 'package:fake_async/fake_async.dart';
|
||||
|
||||
import '../../src/common.dart';
|
||||
|
@ -8,7 +8,6 @@ import 'package:file/file.dart';
|
||||
import 'package:file/memory.dart';
|
||||
import 'package:flutter_tools/src/base/io.dart';
|
||||
import 'package:flutter_tools/src/base/logger.dart';
|
||||
import 'package:flutter_tools/src/base/process.dart';
|
||||
import 'package:flutter_tools/src/base/terminal.dart';
|
||||
import 'package:flutter_tools/src/cache.dart';
|
||||
import 'package:flutter_tools/src/commands/downgrade.dart';
|
||||
|
@ -7,7 +7,6 @@
|
||||
import 'package:args/command_runner.dart';
|
||||
import 'package:file/memory.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/base/process.dart';
|
||||
import 'package:flutter_tools/src/cache.dart';
|
||||
import 'package:flutter_tools/src/commands/packages.dart';
|
||||
import 'package:flutter_tools/src/dart/pub.dart';
|
||||
|
@ -15,7 +15,6 @@ 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/process.dart';
|
||||
import 'package:flutter_tools/src/base/user_messages.dart';
|
||||
import 'package:flutter_tools/src/build_info.dart';
|
||||
import 'package:flutter_tools/src/cache.dart';
|
||||
|
@ -9,9 +9,9 @@ import 'package:flutter_tools/src/base/common.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/process.dart';
|
||||
import 'package:flutter_tools/src/cache.dart';
|
||||
import 'package:flutter_tools/src/commands/shell_completion.dart';
|
||||
import 'package:process/process.dart';
|
||||
import 'package:flutter_tools/src/globals.dart' as globals;
|
||||
|
||||
import '../../src/common.dart';
|
||||
|
@ -10,7 +10,6 @@ import 'package:args/command_runner.dart';
|
||||
import 'package:file/memory.dart';
|
||||
import 'package:flutter_tools/src/base/common.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/base/process.dart';
|
||||
import 'package:flutter_tools/src/build_info.dart';
|
||||
import 'package:flutter_tools/src/cache.dart';
|
||||
import 'package:flutter_tools/src/commands/test.dart';
|
||||
@ -20,6 +19,7 @@ import 'package:flutter_tools/src/test/runner.dart';
|
||||
import 'package:flutter_tools/src/test/test_wrapper.dart';
|
||||
import 'package:flutter_tools/src/test/watcher.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../../src/common.dart';
|
||||
import '../../src/context.dart';
|
||||
|
@ -5,7 +5,6 @@
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:flutter_tools/src/base/error_handling_io.dart';
|
||||
import 'package:flutter_tools/src/base/process.dart';
|
||||
import 'package:flutter_tools/src/base/user_messages.dart';
|
||||
import 'package:flutter_tools/src/globals.dart' as globals;
|
||||
import 'package:flutter_tools/src/artifacts.dart';
|
||||
@ -18,6 +17,7 @@ import 'package:flutter_tools/src/base/terminal.dart';
|
||||
import 'package:flutter_tools/src/cache.dart';
|
||||
import 'package:flutter_tools/src/commands/analyze.dart';
|
||||
import 'package:flutter_tools/src/runner/flutter_command.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../../src/common.dart';
|
||||
import '../../src/context.dart';
|
||||
@ -108,13 +108,10 @@ void main() {
|
||||
|
||||
setUpAll(() {
|
||||
Cache.disableLocking();
|
||||
processManager = const LocalProcessManager();
|
||||
platform = const LocalPlatform();
|
||||
terminal = AnsiTerminal(platform: platform, stdio: Stdio());
|
||||
fileSystem = LocalFileSystem.instance;
|
||||
processManager = LocalProcessManager(
|
||||
platform: platform,
|
||||
fileSystem: fileSystem,
|
||||
);
|
||||
logger = BufferLogger.test();
|
||||
analyzerSeparator = platform.isWindows ? '-' : '•';
|
||||
artifacts = CachedArtifacts(
|
||||
|
@ -10,7 +10,6 @@ import 'package:args/command_runner.dart';
|
||||
import 'package:flutter_tools/src/android/android_builder.dart';
|
||||
import 'package:flutter_tools/src/android/android_sdk.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/base/process.dart';
|
||||
import 'package:flutter_tools/src/build_info.dart';
|
||||
import 'package:flutter_tools/src/cache.dart';
|
||||
import 'package:flutter_tools/src/commands/build_aar.dart';
|
||||
@ -18,6 +17,7 @@ import 'package:flutter_tools/src/project.dart';
|
||||
import 'package:flutter_tools/src/reporting/reporting.dart';
|
||||
import 'package:flutter_tools/src/globals.dart' as globals;
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../../src/android_common.dart';
|
||||
import '../../src/common.dart';
|
||||
|
@ -11,7 +11,6 @@ import 'package:flutter_tools/src/android/android_builder.dart';
|
||||
import 'package:flutter_tools/src/android/android_sdk.dart';
|
||||
import 'package:flutter_tools/src/base/context.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/base/process.dart';
|
||||
|
||||
import 'package:flutter_tools/src/cache.dart';
|
||||
import 'package:flutter_tools/src/commands/build_apk.dart';
|
||||
@ -19,6 +18,7 @@ import 'package:flutter_tools/src/project.dart';
|
||||
import 'package:flutter_tools/src/reporting/reporting.dart';
|
||||
import 'package:flutter_tools/src/globals.dart' as globals;
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../../src/android_common.dart';
|
||||
import '../../src/common.dart';
|
||||
|
@ -17,6 +17,7 @@ import 'package:flutter_tools/src/globals.dart' as globals;
|
||||
import 'package:flutter_tools/src/project.dart';
|
||||
import 'package:flutter_tools/src/reporting/reporting.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../../src/android_common.dart';
|
||||
import '../../src/common.dart';
|
||||
|
@ -7,7 +7,6 @@
|
||||
import 'package:args/command_runner.dart';
|
||||
import 'package:file/memory.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/base/process.dart';
|
||||
import 'package:flutter_tools/src/build_system/build_system.dart';
|
||||
import 'package:flutter_tools/src/build_system/targets/common.dart';
|
||||
import 'package:flutter_tools/src/build_system/targets/icon_tree_shaker.dart';
|
||||
@ -17,6 +16,7 @@ import 'package:flutter_tools/src/commands/build_bundle.dart';
|
||||
import 'package:flutter_tools/src/features.dart';
|
||||
import 'package:flutter_tools/src/reporting/reporting.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:process/process.dart';
|
||||
import 'package:flutter_tools/src/globals.dart' as globals;
|
||||
|
||||
import '../../src/common.dart';
|
||||
|
@ -16,7 +16,6 @@ import 'package:flutter_tools/src/base/io.dart';
|
||||
import 'package:flutter_tools/src/base/logger.dart';
|
||||
import 'package:flutter_tools/src/base/net.dart';
|
||||
import 'package:flutter_tools/src/base/platform.dart';
|
||||
import 'package:flutter_tools/src/base/process.dart';
|
||||
import 'package:flutter_tools/src/build_info.dart';
|
||||
import 'package:flutter_tools/src/cache.dart';
|
||||
import 'package:flutter_tools/src/commands/create.dart';
|
||||
@ -26,6 +25,7 @@ import 'package:flutter_tools/src/globals.dart' as globals;
|
||||
import 'package:flutter_tools/src/project.dart';
|
||||
import 'package:flutter_tools/src/version.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:process/process.dart';
|
||||
import 'package:pub_semver/pub_semver.dart';
|
||||
import 'package:pubspec_parse/pubspec_parse.dart';
|
||||
|
||||
|
@ -11,11 +11,11 @@ import 'package:flutter_tools/src/base/bot_detector.dart';
|
||||
import 'package:flutter_tools/src/base/error_handling_io.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart' hide IOSink;
|
||||
import 'package:flutter_tools/src/base/io.dart';
|
||||
import 'package:flutter_tools/src/base/process.dart';
|
||||
import 'package:flutter_tools/src/cache.dart';
|
||||
import 'package:flutter_tools/src/commands/packages.dart';
|
||||
import 'package:flutter_tools/src/dart/pub.dart';
|
||||
import 'package:flutter_tools/src/reporting/reporting.dart';
|
||||
import 'package:process/process.dart';
|
||||
import 'package:flutter_tools/src/globals.dart' as globals;
|
||||
|
||||
import '../../src/common.dart';
|
||||
|
@ -7,7 +7,6 @@
|
||||
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:flutter_tools/src/base/process.dart';
|
||||
import 'package:flutter_tools/src/cache.dart';
|
||||
import 'package:flutter_tools/src/commands/upgrade.dart';
|
||||
import 'package:flutter_tools/src/convert.dart';
|
||||
@ -16,6 +15,7 @@ import 'package:flutter_tools/src/persistent_tool_state.dart';
|
||||
import 'package:flutter_tools/src/runner/flutter_command.dart';
|
||||
import 'package:flutter_tools/src/version.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../../src/common.dart';
|
||||
import '../../src/context.dart';
|
||||
|
@ -10,7 +10,6 @@ import 'package:flutter_tools/src/base/config.dart';
|
||||
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:flutter_tools/src/base/process.dart';
|
||||
import 'package:flutter_tools/src/base/time.dart';
|
||||
import 'package:flutter_tools/src/cache.dart';
|
||||
import 'package:flutter_tools/src/commands/build.dart';
|
||||
|
@ -10,7 +10,6 @@ import 'package:flutter_tools/src/android/android_sdk.dart';
|
||||
import 'package:flutter_tools/src/android/android_workflow.dart';
|
||||
import 'package:flutter_tools/src/base/logger.dart';
|
||||
import 'package:flutter_tools/src/base/platform.dart';
|
||||
import 'package:flutter_tools/src/base/process.dart';
|
||||
import 'package:flutter_tools/src/base/user_messages.dart';
|
||||
import 'package:flutter_tools/src/device.dart';
|
||||
import 'package:test/fake.dart';
|
||||
|
@ -16,11 +16,11 @@ 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/platform.dart';
|
||||
import 'package:flutter_tools/src/base/process.dart';
|
||||
import 'package:flutter_tools/src/build_info.dart';
|
||||
import 'package:flutter_tools/src/device.dart';
|
||||
import 'package:flutter_tools/src/project.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../../src/common.dart';
|
||||
import '../../src/context.dart';
|
||||
|
@ -11,7 +11,6 @@ import 'package:flutter_tools/src/application_package.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/base/logger.dart';
|
||||
import 'package:flutter_tools/src/base/platform.dart';
|
||||
import 'package:flutter_tools/src/base/process.dart';
|
||||
import 'package:test/fake.dart';
|
||||
|
||||
import '../../src/common.dart';
|
||||
|
@ -10,9 +10,9 @@ import 'package:flutter_tools/src/base/config.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/base/io.dart' show ProcessResult;
|
||||
import 'package:flutter_tools/src/base/platform.dart';
|
||||
import 'package:flutter_tools/src/base/process.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../../src/common.dart';
|
||||
import '../../src/context.dart';
|
||||
|
@ -8,7 +8,6 @@ import 'package:file/memory.dart';
|
||||
import 'package:flutter_tools/src/android/android_studio.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/base/platform.dart';
|
||||
import 'package:flutter_tools/src/base/process.dart';
|
||||
import 'package:flutter_tools/src/base/version.dart';
|
||||
import 'package:flutter_tools/src/globals.dart' as globals;
|
||||
import 'package:flutter_tools/src/ios/plist_parser.dart';
|
||||
|
@ -10,10 +10,10 @@ import 'package:flutter_tools/src/base/config.dart';
|
||||
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:flutter_tools/src/base/process.dart';
|
||||
import 'package:flutter_tools/src/base/user_messages.dart';
|
||||
import 'package:flutter_tools/src/doctor.dart';
|
||||
import 'package:flutter_tools/src/globals.dart' as globals;
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../../src/common.dart';
|
||||
import '../../src/context.dart';
|
||||
|
@ -12,11 +12,11 @@ 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/platform.dart';
|
||||
import 'package:flutter_tools/src/base/process.dart';
|
||||
import 'package:flutter_tools/src/globals.dart' as globals;
|
||||
import 'package:flutter_tools/src/project.dart';
|
||||
import 'package:flutter_tools/src/reporting/reporting.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../../src/common.dart';
|
||||
import '../../src/context.dart';
|
||||
|
@ -18,7 +18,6 @@ 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/platform.dart';
|
||||
import 'package:flutter_tools/src/base/process.dart';
|
||||
import 'package:flutter_tools/src/base/terminal.dart';
|
||||
import 'package:flutter_tools/src/build_info.dart';
|
||||
import 'package:flutter_tools/src/cache.dart';
|
||||
@ -26,6 +25,7 @@ import 'package:flutter_tools/src/globals.dart' as globals;
|
||||
import 'package:flutter_tools/src/project.dart';
|
||||
import 'package:flutter_tools/src/reporting/reporting.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../../src/common.dart';
|
||||
import '../../src/context.dart';
|
||||
|
@ -8,11 +8,11 @@ import 'package:file/memory.dart';
|
||||
import 'package:flutter_tools/src/android/gradle_utils.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/base/os.dart';
|
||||
import 'package:flutter_tools/src/base/process.dart';
|
||||
import 'package:flutter_tools/src/cache.dart';
|
||||
import 'package:flutter_tools/src/project.dart';
|
||||
import 'package:flutter_tools/src/globals.dart' as globals;
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../../src/common.dart';
|
||||
import '../../src/context.dart';
|
||||
|
@ -13,7 +13,6 @@ import 'package:flutter_tools/src/base/file_system.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/base/process.dart';
|
||||
import 'package:flutter_tools/src/base/user_messages.dart';
|
||||
import 'package:flutter_tools/src/build_info.dart';
|
||||
import 'package:flutter_tools/src/cache.dart';
|
||||
@ -22,6 +21,7 @@ import 'package:flutter_tools/src/globals.dart' as globals;
|
||||
import 'package:flutter_tools/src/ios/plist_parser.dart';
|
||||
import 'package:flutter_tools/src/project.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../src/common.dart';
|
||||
import '../src/context.dart';
|
||||
|
@ -11,7 +11,6 @@ import 'package:file/memory.dart';
|
||||
|
||||
import 'package:flutter_tools/src/asset.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/base/process.dart';
|
||||
|
||||
import 'package:flutter_tools/src/globals.dart' as globals;
|
||||
|
||||
|
@ -11,11 +11,11 @@ import 'package:flutter_tools/src/base/error_handling_io.dart';
|
||||
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:flutter_tools/src/base/process.dart';
|
||||
import 'package:flutter_tools/src/globals.dart' as globals show flutterUsage;
|
||||
import 'package:flutter_tools/src/reporting/reporting.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:path/path.dart' as path; // ignore: package_path_import
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../../src/common.dart';
|
||||
import '../../src/context.dart';
|
||||
|
@ -13,6 +13,7 @@ import 'package:flutter_tools/src/base/os.dart';
|
||||
import 'package:flutter_tools/src/base/platform.dart';
|
||||
import 'package:flutter_tools/src/build_info.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../../src/common.dart';
|
||||
import '../../src/context.dart';
|
||||
|
@ -8,8 +8,8 @@ import 'package:flutter_tools/src/base/file_system.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/base/process.dart';
|
||||
import 'package:flutter_tools/src/base/signals.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../../src/common.dart';
|
||||
|
||||
|
@ -1,327 +0,0 @@
|
||||
// Copyright 2014 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:file/memory.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/base/platform.dart';
|
||||
import 'package:flutter_tools/src/base/process.dart';
|
||||
|
||||
import '../../src/common.dart';
|
||||
|
||||
void main() {
|
||||
group('getExecutablePath', () {
|
||||
FileSystem fileSystem;
|
||||
Directory workingDir;
|
||||
Directory dir1;
|
||||
Directory dir2;
|
||||
Directory dir3;
|
||||
|
||||
void initialize(FileSystemStyle style) {
|
||||
setUp(() {
|
||||
fileSystem = MemoryFileSystem(style: style);
|
||||
workingDir = fileSystem.systemTempDirectory.createTempSync('work_dir_');
|
||||
dir1 = fileSystem.systemTempDirectory.createTempSync('dir1_');
|
||||
dir2 = fileSystem.systemTempDirectory.createTempSync('dir2_');
|
||||
dir3 = fileSystem.systemTempDirectory.createTempSync('dir3_');
|
||||
});
|
||||
}
|
||||
|
||||
tearDown(() {
|
||||
workingDir.deleteSync(recursive: true);
|
||||
dir1.deleteSync(recursive: true);
|
||||
dir2.deleteSync(recursive: true);
|
||||
dir3.deleteSync(recursive: true);
|
||||
});
|
||||
|
||||
group('on windows', () {
|
||||
Platform platform;
|
||||
|
||||
initialize(FileSystemStyle.windows);
|
||||
|
||||
setUp(() {
|
||||
platform = FakePlatform(
|
||||
operatingSystem: 'windows',
|
||||
environment: <String, String>{
|
||||
'PATH': '${dir1.path};${dir2.path}',
|
||||
'PATHEXT': '.exe;.bat'
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
test('absolute', () {
|
||||
String command = fileSystem.path.join(dir3.path, 'bla.exe');
|
||||
final String expectedPath = command;
|
||||
fileSystem.file(command).createSync();
|
||||
|
||||
String executablePath = getExecutablePath(
|
||||
command,
|
||||
workingDir.path,
|
||||
platform: platform,
|
||||
fileSystem: fileSystem,
|
||||
);
|
||||
_expectSamePath(executablePath, expectedPath);
|
||||
|
||||
command = fileSystem.path.withoutExtension(command);
|
||||
executablePath = getExecutablePath(
|
||||
command,
|
||||
workingDir.path,
|
||||
platform: platform,
|
||||
fileSystem: fileSystem,
|
||||
);
|
||||
_expectSamePath(executablePath, expectedPath);
|
||||
});
|
||||
|
||||
test('in path', () {
|
||||
String command = 'bla.exe';
|
||||
final String expectedPath = fileSystem.path.join(dir2.path, command);
|
||||
fileSystem.file(expectedPath).createSync();
|
||||
|
||||
String executablePath = getExecutablePath(
|
||||
command,
|
||||
workingDir.path,
|
||||
platform: platform,
|
||||
fileSystem: fileSystem,
|
||||
);
|
||||
_expectSamePath(executablePath, expectedPath);
|
||||
|
||||
command = fileSystem.path.withoutExtension(command);
|
||||
executablePath = getExecutablePath(
|
||||
command,
|
||||
workingDir.path,
|
||||
platform: platform,
|
||||
fileSystem: fileSystem,
|
||||
);
|
||||
_expectSamePath(executablePath, expectedPath);
|
||||
});
|
||||
|
||||
test('in path multiple times', () {
|
||||
String command = 'bla.exe';
|
||||
final String expectedPath = fileSystem.path.join(dir1.path, command);
|
||||
final String wrongPath = fileSystem.path.join(dir2.path, command);
|
||||
fileSystem.file(expectedPath).createSync();
|
||||
fileSystem.file(wrongPath).createSync();
|
||||
|
||||
String executablePath = getExecutablePath(
|
||||
command,
|
||||
workingDir.path,
|
||||
platform: platform,
|
||||
fileSystem: fileSystem,
|
||||
);
|
||||
_expectSamePath(executablePath, expectedPath);
|
||||
|
||||
command = fileSystem.path.withoutExtension(command);
|
||||
executablePath = getExecutablePath(
|
||||
command,
|
||||
workingDir.path,
|
||||
platform: platform,
|
||||
fileSystem: fileSystem,
|
||||
);
|
||||
_expectSamePath(executablePath, expectedPath);
|
||||
});
|
||||
|
||||
test('in subdir of work dir', () {
|
||||
String command = fileSystem.path.join('.', 'foo', 'bla.exe');
|
||||
final String expectedPath = fileSystem.path.join(workingDir.path, command);
|
||||
fileSystem.file(expectedPath).createSync(recursive: true);
|
||||
|
||||
String executablePath = getExecutablePath(
|
||||
command,
|
||||
workingDir.path,
|
||||
platform: platform,
|
||||
fileSystem: fileSystem,
|
||||
);
|
||||
_expectSamePath(executablePath, expectedPath);
|
||||
|
||||
command = fileSystem.path.withoutExtension(command);
|
||||
executablePath = getExecutablePath(
|
||||
command,
|
||||
workingDir.path,
|
||||
platform: platform,
|
||||
fileSystem: fileSystem,
|
||||
);
|
||||
_expectSamePath(executablePath, expectedPath);
|
||||
});
|
||||
|
||||
test('in work dir', () {
|
||||
String command = fileSystem.path.join('.', 'bla.exe');
|
||||
final String expectedPath = fileSystem.path.join(workingDir.path, command);
|
||||
final String wrongPath = fileSystem.path.join(dir2.path, command);
|
||||
fileSystem.file(expectedPath).createSync();
|
||||
fileSystem.file(wrongPath).createSync();
|
||||
|
||||
String executablePath = getExecutablePath(
|
||||
command,
|
||||
workingDir.path,
|
||||
platform: platform,
|
||||
fileSystem: fileSystem,
|
||||
);
|
||||
_expectSamePath(executablePath, expectedPath);
|
||||
|
||||
command = fileSystem.path.withoutExtension(command);
|
||||
executablePath = getExecutablePath(
|
||||
command,
|
||||
workingDir.path,
|
||||
platform: platform,
|
||||
fileSystem: fileSystem,
|
||||
);
|
||||
_expectSamePath(executablePath, expectedPath);
|
||||
});
|
||||
|
||||
test('with multiple extensions', () {
|
||||
const String command = 'foo';
|
||||
final String expectedPath = fileSystem.path.join(dir1.path, '$command.exe');
|
||||
final String wrongPath1 = fileSystem.path.join(dir1.path, '$command.bat');
|
||||
final String wrongPath2 = fileSystem.path.join(dir2.path, '$command.exe');
|
||||
fileSystem.file(expectedPath).createSync();
|
||||
fileSystem.file(wrongPath1).createSync();
|
||||
fileSystem.file(wrongPath2).createSync();
|
||||
|
||||
final String executablePath = getExecutablePath(
|
||||
command,
|
||||
workingDir.path,
|
||||
platform: platform,
|
||||
fileSystem: fileSystem,
|
||||
);
|
||||
_expectSamePath(executablePath, expectedPath);
|
||||
});
|
||||
|
||||
test('not found', () {
|
||||
const String command = 'foo.exe';
|
||||
|
||||
final String executablePath = getExecutablePath(
|
||||
command,
|
||||
workingDir.path,
|
||||
platform: platform,
|
||||
fileSystem: fileSystem,
|
||||
);
|
||||
expect(executablePath, isNull);
|
||||
});
|
||||
|
||||
test('when path has spaces', () {
|
||||
expect(
|
||||
sanitizeExecutablePath(r'Program Files\bla.exe', platform: platform),
|
||||
r'"Program Files\bla.exe"');
|
||||
expect(
|
||||
sanitizeExecutablePath(r'ProgramFiles\bla.exe', platform: platform),
|
||||
r'ProgramFiles\bla.exe');
|
||||
expect(
|
||||
sanitizeExecutablePath(r'"Program Files\bla.exe"', platform: platform),
|
||||
r'"Program Files\bla.exe"');
|
||||
expect(
|
||||
sanitizeExecutablePath(r'"Program Files\bla.exe"', platform: platform),
|
||||
r'"Program Files\bla.exe"');
|
||||
expect(
|
||||
sanitizeExecutablePath(r'C:"Program Files"\bla.exe', platform: platform),
|
||||
r'C:"Program Files"\bla.exe');
|
||||
});
|
||||
|
||||
test('with absolute path when currentDirectory getter throws', () {
|
||||
final FileSystem fileSystemNoCwd = MemoryFileSystemNoCwd(fileSystem);
|
||||
final String command = fileSystem.path.join(dir3.path, 'bla.exe');
|
||||
final String expectedPath = command;
|
||||
fileSystem.file(command).createSync();
|
||||
|
||||
final String executablePath = getExecutablePath(
|
||||
command,
|
||||
null,
|
||||
platform: platform,
|
||||
fileSystem: fileSystemNoCwd,
|
||||
);
|
||||
_expectSamePath(executablePath, expectedPath);
|
||||
});
|
||||
|
||||
test('with relative path when currentDirectory getter throws', () {
|
||||
final FileSystem fileSystemNoCwd = MemoryFileSystemNoCwd(fileSystem);
|
||||
final String command = fileSystem.path.join('.', 'bla.exe');
|
||||
|
||||
final String executablePath = getExecutablePath(
|
||||
command,
|
||||
null,
|
||||
platform: platform,
|
||||
fileSystem: fileSystemNoCwd,
|
||||
);
|
||||
expect(executablePath, isNull);
|
||||
});
|
||||
});
|
||||
|
||||
group('on Linux', () {
|
||||
Platform platform;
|
||||
|
||||
initialize(FileSystemStyle.posix);
|
||||
|
||||
setUp(() {
|
||||
platform = FakePlatform(
|
||||
operatingSystem: 'linux',
|
||||
environment: <String, String>{'PATH': '${dir1.path}:${dir2.path}'});
|
||||
});
|
||||
|
||||
test('absolute', () {
|
||||
final String command = fileSystem.path.join(dir3.path, 'bla');
|
||||
final String expectedPath = command;
|
||||
final String wrongPath = fileSystem.path.join(dir3.path, 'bla.bat');
|
||||
fileSystem.file(command).createSync();
|
||||
fileSystem.file(wrongPath).createSync();
|
||||
|
||||
final String executablePath = getExecutablePath(
|
||||
command,
|
||||
workingDir.path,
|
||||
platform: platform,
|
||||
fileSystem: fileSystem,
|
||||
);
|
||||
_expectSamePath(executablePath, expectedPath);
|
||||
});
|
||||
|
||||
test('in path multiple times', () {
|
||||
const String command = 'xxx';
|
||||
final String expectedPath = fileSystem.path.join(dir1.path, command);
|
||||
final String wrongPath = fileSystem.path.join(dir2.path, command);
|
||||
fileSystem.file(expectedPath).createSync();
|
||||
fileSystem.file(wrongPath).createSync();
|
||||
|
||||
final String executablePath = getExecutablePath(
|
||||
command,
|
||||
workingDir.path,
|
||||
platform: platform,
|
||||
fileSystem: fileSystem,
|
||||
);
|
||||
_expectSamePath(executablePath, expectedPath);
|
||||
});
|
||||
|
||||
test('not found', () {
|
||||
const String command = 'foo';
|
||||
|
||||
final String executablePath = getExecutablePath(
|
||||
command,
|
||||
workingDir.path,
|
||||
platform: platform,
|
||||
fileSystem: fileSystem,
|
||||
);
|
||||
expect(executablePath, isNull);
|
||||
});
|
||||
|
||||
test('when path has spaces', () {
|
||||
expect(
|
||||
sanitizeExecutablePath('/usr/local/bin/foo bar',
|
||||
platform: platform),
|
||||
'/usr/local/bin/foo bar');
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
void _expectSamePath(String actual, String expected) {
|
||||
expect(actual, isNotNull);
|
||||
expect(actual.toLowerCase(), expected.toLowerCase());
|
||||
}
|
||||
|
||||
class MemoryFileSystemNoCwd extends ForwardingFileSystem {
|
||||
MemoryFileSystemNoCwd(FileSystem delegate) : super(delegate);
|
||||
|
||||
@override
|
||||
Directory get currentDirectory {
|
||||
throw const FileSystemException('Access denied');
|
||||
}
|
||||
}
|
@ -15,6 +15,7 @@ import 'package:flutter_tools/src/build_system/targets/common.dart';
|
||||
import 'package:flutter_tools/src/build_system/targets/web.dart';
|
||||
import 'package:flutter_tools/src/globals.dart' as globals;
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../../../src/common.dart';
|
||||
import '../../../src/context.dart';
|
||||
|
@ -18,6 +18,7 @@ import 'package:flutter_tools/src/cache.dart';
|
||||
import 'package:flutter_tools/src/dart/pub.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../src/common.dart';
|
||||
import '../src/context.dart';
|
||||
|
@ -11,6 +11,7 @@ import 'package:flutter_tools/src/cache.dart';
|
||||
import 'package:flutter_tools/src/globals.dart' as globals;
|
||||
import 'package:flutter_tools/src/commands/channel.dart';
|
||||
import 'package:flutter_tools/src/version.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../src/common.dart';
|
||||
import '../src/context.dart';
|
||||
|
@ -15,6 +15,7 @@ import 'package:flutter_tools/src/compile.dart';
|
||||
import 'package:flutter_tools/src/convert.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:package_config/package_config.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../src/common.dart';
|
||||
import '../src/context.dart';
|
||||
|
@ -16,6 +16,7 @@ import 'package:flutter_tools/src/compile.dart';
|
||||
import 'package:flutter_tools/src/convert.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:package_config/package_config.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../src/common.dart';
|
||||
import '../src/context.dart';
|
||||
|
@ -16,6 +16,7 @@ import 'package:flutter_tools/src/compile.dart';
|
||||
import 'package:flutter_tools/src/convert.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:package_config/package_config.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../src/common.dart';
|
||||
import '../src/context.dart';
|
||||
|
@ -16,6 +16,7 @@ import 'package:flutter_tools/src/cache.dart';
|
||||
import 'package:flutter_tools/src/dart/pub.dart';
|
||||
import 'package:flutter_tools/src/reporting/reporting.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:process/process.dart';
|
||||
import 'package:fake_async/fake_async.dart';
|
||||
|
||||
import '../../src/common.dart';
|
||||
|
@ -18,6 +18,7 @@ import 'package:flutter_tools/src/device.dart';
|
||||
import 'package:flutter_tools/src/project.dart';
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:process/process.dart';
|
||||
import 'package:test/fake.dart';
|
||||
|
||||
import '../src/common.dart';
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user