mirror of
https://github.com/flutter/flutter
synced 2024-10-13 03:32:55 +00:00
fix tests on windows
remove a runInShell arg on windows when launching pub
This commit is contained in:
parent
6b2d6fdc8c
commit
5dbeb8f018
|
@ -9,6 +9,8 @@ import 'package:args/command_runner.dart';
|
|||
import 'package:mustache4dart/mustache4dart.dart' as mustache;
|
||||
import 'package:path/path.dart' as p;
|
||||
|
||||
import '../process.dart';
|
||||
|
||||
class InitCommand extends Command {
|
||||
final String name = 'init';
|
||||
final String description = 'Create a new Flutter project.';
|
||||
|
@ -43,8 +45,8 @@ class InitCommand extends Command {
|
|||
|
||||
if (argResults['pub']) {
|
||||
print("Running pub get...");
|
||||
Process process =
|
||||
await Process.start('pub', ['get'], workingDirectory: out.path);
|
||||
Process process = await Process.start(
|
||||
sdkBinaryName('pub'), ['get'], workingDirectory: out.path);
|
||||
stdout.addStream(process.stdout);
|
||||
stderr.addStream(process.stderr);
|
||||
int code = await process.exitCode;
|
||||
|
|
|
@ -773,8 +773,8 @@ class AndroidDevice extends Device {
|
|||
[adbPath, 'forward', observatoryPortString, observatoryPortString]);
|
||||
|
||||
// Actually start the server.
|
||||
await Process.start('pub', ['run', 'sky_tools:sky_server', _serverPort],
|
||||
workingDirectory: serverRoot, mode: ProcessStartMode.DETACHED, runInShell: Platform.isWindows);
|
||||
await Process.start(sdkBinaryName('pub'), ['run', 'sky_tools:sky_server', _serverPort],
|
||||
workingDirectory: serverRoot, mode: ProcessStartMode.DETACHED);
|
||||
|
||||
// Set up reverse port-forwarding so that the Android app can reach the
|
||||
// server running on localhost.
|
||||
|
|
|
@ -64,6 +64,12 @@ String runCheckedSync(List<String> cmd) =>
|
|||
/// Run cmd and return stdout.
|
||||
String runSync(List<String> cmd) => _runWithLoggingSync(cmd);
|
||||
|
||||
/// Return the platform specific name for the given Dart SDK binary. So, `pub`
|
||||
/// ==> `pub.bat`.
|
||||
String sdkBinaryName(String name) {
|
||||
return Platform.isWindows ? '${name}.bat' : name;
|
||||
}
|
||||
|
||||
String _runWithLoggingSync(List<String> cmd, {bool checked: false}) {
|
||||
_logging.info(cmd.join(' '));
|
||||
ProcessResult results =
|
||||
|
|
|
@ -12,6 +12,7 @@ dependencies:
|
|||
args: ^0.13.0
|
||||
asn1lib: ^0.4.1
|
||||
cipher: ^0.7.1
|
||||
crypto: ^0.9.1
|
||||
mustache4dart: ^1.0.0
|
||||
path: ^1.3.0
|
||||
shelf_route: ^0.13.4
|
||||
|
@ -19,7 +20,6 @@ dependencies:
|
|||
shelf: ^0.6.2
|
||||
test: ">=0.12.4+5 <0.12.5"
|
||||
yaml: ^2.1.3
|
||||
crypto: ^0.9.1
|
||||
|
||||
dev_dependencies:
|
||||
mockito: "^0.10.1"
|
||||
|
|
|
@ -11,6 +11,7 @@ import 'dart:io';
|
|||
import 'package:args/command_runner.dart';
|
||||
import 'package:path/path.dart' as p;
|
||||
import 'package:sky_tools/src/commands/init.dart';
|
||||
import 'package:sky_tools/src/process.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
main() => defineTests();
|
||||
|
@ -38,7 +39,7 @@ defineTests() {
|
|||
String path = p.join(temp.path, 'lib', 'main.dart');
|
||||
expect(new File(path).existsSync(), true);
|
||||
ProcessResult exec = Process.runSync(
|
||||
'dartanalyzer', ['--fatal-warnings', path],
|
||||
sdkBinaryName('dartanalyzer'), ['--fatal-warnings', path],
|
||||
workingDirectory: temp.path);
|
||||
if (exec.exitCode != 0) {
|
||||
print(exec.stdout);
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:args/command_runner.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:sky_tools/src/commands/list.dart';
|
||||
|
@ -14,23 +16,25 @@ main() => defineTests();
|
|||
defineTests() {
|
||||
group('list', () {
|
||||
test('returns 0 when called', () {
|
||||
final String mockCommand = Platform.isWindows ? 'cmd /c echo' : 'echo';
|
||||
|
||||
ListCommand command = new ListCommand();
|
||||
applyMocksToCommand(command);
|
||||
MockDeviceStore mockDevices = command.devices;
|
||||
|
||||
// Avoid relying on adb being installed on the test system.
|
||||
// Instead, cause the test to run the echo command.
|
||||
when(mockDevices.android.adbPath).thenReturn('echo');
|
||||
when(mockDevices.android.adbPath).thenReturn(mockCommand);
|
||||
|
||||
// Avoid relying on idevice* being installed on the test system.
|
||||
// Instead, cause the test to run the echo command.
|
||||
when(mockDevices.iOS.informerPath).thenReturn('echo');
|
||||
when(mockDevices.iOS.installerPath).thenReturn('echo');
|
||||
when(mockDevices.iOS.listerPath).thenReturn('echo');
|
||||
when(mockDevices.iOS.informerPath).thenReturn(mockCommand);
|
||||
when(mockDevices.iOS.installerPath).thenReturn(mockCommand);
|
||||
when(mockDevices.iOS.listerPath).thenReturn(mockCommand);
|
||||
|
||||
// Avoid relying on xcrun being installed on the test system.
|
||||
// Instead, cause the test to run the echo command.
|
||||
when(mockDevices.iOSSimulator.xcrunPath).thenReturn('echo');
|
||||
when(mockDevices.iOSSimulator.xcrunPath).thenReturn(mockCommand);
|
||||
|
||||
|
||||
CommandRunner runner = new CommandRunner('test_flutter', '')
|
||||
|
|
Loading…
Reference in a new issue