Unverified Commit 857bdc7a authored by Danny Tuppeny's avatar Danny Tuppeny Committed by GitHub

Allow FlutterTester to be provided with the working directory for execution (#21119)

* Allow FlutterTester to be provided with the working directory for execution

Previously this test set fs.currentDirectory which prevents running tests concurrently. This allows setting the working directory for a FlutterTester in the cosntructor (optionally) and passes it through from the test (without setting fs.currentDirectory).

* Remove trailing whitespace
parent bae44b29
......@@ -41,8 +41,9 @@ class FlutterTesterApp extends ApplicationPackage {
// TODO(scheglov): This device does not currently work with full restarts.
class FlutterTesterDevice extends Device {
FlutterTesterDevice(String deviceId) : super(deviceId);
FlutterTesterDevice(String deviceId, { this.workingDirectory }) : super(deviceId);
final String workingDirectory;
Process _process;
final DevicePortForwarder _portForwarder = new _NoopPortForwarder();
......@@ -151,6 +152,7 @@ class FlutterTesterDevice extends Device {
environment: <String, String>{
'FLUTTER_TEST': 'true',
},
workingDirectory: workingDirectory,
);
// Setting a bool can't fail in the callback.
_process.exitCode.then((_) => _isRunning = false); // ignore: unawaited_futures
......
......@@ -15,25 +15,18 @@ import '../src/context.dart';
import 'test_utils.dart';
void main() {
Directory tempDir;
Directory oldCurrentDir;
setUp(() async {
tempDir = fs.systemTempDirectory.createTempSync('flutter_tester_device_test.');
oldCurrentDir = fs.currentDirectory;
fs.currentDirectory = tempDir;
});
tearDown(() {
fs.currentDirectory = oldCurrentDir;
tryToDelete(tempDir);
});
group('FlutterTesterDevice', () {
Directory tempDir;
FlutterTesterDevice device;
setUp(() {
device = new FlutterTesterDevice('flutter-tester');
setUp(() async {
tempDir = fs.systemTempDirectory.createTempSync('flutter_tester_device_test.');
device = new FlutterTesterDevice('flutter-tester', workingDirectory: tempDir.path);
});
tearDown(() {
tryToDelete(tempDir);
});
Future<LaunchResult> start(String mainPath) async {
......@@ -50,7 +43,7 @@ void main() {
writePubspec(tempDir.path);
writePackages(tempDir.path);
final String mainPath = fs.path.join('lib', 'main.dart');
final String mainPath = fs.path.join(tempDir.path, 'lib', 'main.dart');
writeFile(mainPath, r'''
import 'dart:async';
void main() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment