Fixed order dependency and removed no-shuffle tag in flutter_driver_test (#89477)
This commit is contained in:
committed by
GitHub
parent
51588ab808
commit
baecbdfe14
@@ -25,7 +25,10 @@ class VMServiceFlutterDriver extends FlutterDriver {
|
||||
bool logCommunicationToFile = true,
|
||||
}) : _printCommunication = printCommunication,
|
||||
_logCommunicationToFile = logCommunicationToFile,
|
||||
_driverId = _nextDriverId++;
|
||||
_driverId = _nextDriverId++
|
||||
{
|
||||
_logFilePathName = p.join(testOutputsDirectory, 'flutter_driver_commands_$_driverId.log');
|
||||
}
|
||||
|
||||
/// Connects to a Flutter application.
|
||||
///
|
||||
@@ -287,6 +290,12 @@ class VMServiceFlutterDriver extends FlutterDriver {
|
||||
/// Whether to log communication between host and app to `flutter_driver_commands.log`.
|
||||
final bool _logCommunicationToFile;
|
||||
|
||||
/// Logs are written here when _logCommunicationToFile is true.
|
||||
late final String _logFilePathName;
|
||||
|
||||
/// Getter for file pathname where logs are written when _logCommunicationToFile is true.
|
||||
String get logFilePathName => _logFilePathName;
|
||||
|
||||
|
||||
@override
|
||||
Future<Map<String, dynamic>> sendCommand(Command command) async {
|
||||
@@ -321,7 +330,8 @@ class VMServiceFlutterDriver extends FlutterDriver {
|
||||
if (_printCommunication)
|
||||
_log(message);
|
||||
if (_logCommunicationToFile) {
|
||||
final f.File file = fs.file(p.join(testOutputsDirectory, 'flutter_driver_commands_$_driverId.log'));
|
||||
assert(_logFilePathName != null);
|
||||
final f.File file = fs.file(_logFilePathName);
|
||||
file.createSync(recursive: true); // no-op if file exists
|
||||
file.writeAsStringSync('${DateTime.now()} $message\n', mode: f.FileMode.append, flush: true);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,11 @@ class WebFlutterDriver extends FlutterDriver {
|
||||
}) : _printCommunication = printCommunication,
|
||||
_logCommunicationToFile = logCommunicationToFile,
|
||||
_startTime = DateTime.now(),
|
||||
_driverId = _nextDriverId++;
|
||||
_driverId = _nextDriverId++
|
||||
{
|
||||
_logFilePathName = path.join(testOutputsDirectory, 'flutter_driver_commands_$_driverId.log');
|
||||
}
|
||||
|
||||
|
||||
final FlutterWebConnection _connection;
|
||||
DateTime _startTime;
|
||||
@@ -63,6 +67,12 @@ class WebFlutterDriver extends FlutterDriver {
|
||||
/// Whether to log communication between host and app to `flutter_driver_commands.log`.
|
||||
final bool _logCommunicationToFile;
|
||||
|
||||
/// Logs are written here when _logCommunicationToFile is true.
|
||||
late final String _logFilePathName;
|
||||
|
||||
/// Getter for file pathname where logs are written when _logCommunicationToFile is true
|
||||
String get logFilePathName => _logFilePathName;
|
||||
|
||||
/// Creates a driver that uses a connection provided by the given
|
||||
/// [hostUrl] which would fallback to environment variable VM_SERVICE_URL.
|
||||
/// Driver also depends on environment variables DRIVER_SESSION_ID,
|
||||
@@ -128,7 +138,8 @@ class WebFlutterDriver extends FlutterDriver {
|
||||
driverLog('WebFlutterDriver', message);
|
||||
}
|
||||
if (_logCommunicationToFile) {
|
||||
final File file = fs.file(path.join(testOutputsDirectory, 'flutter_driver_commands_$_driverId.log'));
|
||||
assert(_logFilePathName != null);
|
||||
final File file = fs.file(_logFilePathName);
|
||||
file.createSync(recursive: true); // no-op if file exists
|
||||
file.writeAsStringSync('${DateTime.now()} $message\n', mode: FileMode.append, flush: true);
|
||||
}
|
||||
|
||||
@@ -2,12 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// TODO(gspencergoog): Remove this tag once this test's state leaks/test
|
||||
// dependencies have been fixed.
|
||||
// https://github.com/flutter/flutter/issues/85160
|
||||
// Fails with "flutter test --test-randomize-ordering-seed=20210721"
|
||||
@Tags(<String>['no-shuffle'])
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
@@ -17,10 +11,8 @@ import 'package:flutter_driver/src/common/error.dart';
|
||||
import 'package:flutter_driver/src/common/health.dart';
|
||||
import 'package:flutter_driver/src/common/layer_tree.dart';
|
||||
import 'package:flutter_driver/src/common/wait.dart';
|
||||
import 'package:flutter_driver/src/driver/common.dart';
|
||||
import 'package:flutter_driver/src/driver/driver.dart';
|
||||
import 'package:flutter_driver/src/driver/timeline.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
import 'package:vm_service/vm_service.dart' as vms;
|
||||
|
||||
import '../../common.dart';
|
||||
@@ -44,15 +36,12 @@ void main() {
|
||||
late FakeIsolate fakeIsolate;
|
||||
late VMServiceFlutterDriver driver;
|
||||
late File logFile;
|
||||
int driverId = -1;
|
||||
|
||||
setUp(() {
|
||||
fakeIsolate = FakeIsolate();
|
||||
fakeVM = FakeVM(fakeIsolate);
|
||||
fakeClient = FakeVmService(fakeVM);
|
||||
fakeClient.responses['waitFor'] = makeFakeResponse(<String, dynamic>{'status':'ok'});
|
||||
driverId += 1;
|
||||
logFile = File(path.join(testOutputsDirectory, 'flutter_driver_commands_$driverId.log'));
|
||||
});
|
||||
|
||||
tearDown(() {
|
||||
@@ -64,6 +53,7 @@ void main() {
|
||||
group('logCommunicationToFile', () {
|
||||
test('logCommunicationToFile = true', () async {
|
||||
driver = VMServiceFlutterDriver.connectedTo(fakeClient, fakeIsolate);
|
||||
logFile = File(driver.logFilePathName);
|
||||
|
||||
await driver.waitFor(find.byTooltip('foo'), timeout: _kTestTimeout);
|
||||
|
||||
@@ -80,12 +70,22 @@ void main() {
|
||||
|
||||
test('logCommunicationToFile = false', () async {
|
||||
driver = VMServiceFlutterDriver.connectedTo(fakeClient, fakeIsolate, logCommunicationToFile: false);
|
||||
|
||||
logFile = File(driver.logFilePathName);
|
||||
// clear log file if left in filetree from previous run
|
||||
if (logFile.existsSync()) {
|
||||
logFile.deleteSync();
|
||||
}
|
||||
await driver.waitFor(find.byTooltip('foo'), timeout: _kTestTimeout);
|
||||
|
||||
final bool exists = logFile.existsSync();
|
||||
expect(exists, false, reason: 'because ${logFile.path} exists');
|
||||
});
|
||||
|
||||
test('logFilePathName was set when a new driver was created', () {
|
||||
driver = VMServiceFlutterDriver.connectedTo(fakeClient, fakeIsolate, logCommunicationToFile: true);
|
||||
logFile = File(driver.logFilePathName);
|
||||
expect(logFile.path, endsWith('.log'));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -720,14 +720,11 @@ void main() {
|
||||
late FakeFlutterWebConnection fakeConnection;
|
||||
late WebFlutterDriver driver;
|
||||
late File logFile;
|
||||
int driverId = -1;
|
||||
|
||||
setUp(() {
|
||||
fakeConnection = FakeFlutterWebConnection();
|
||||
fakeConnection.supportsTimelineAction = true;
|
||||
fakeConnection.responses['waitFor'] = jsonEncode(makeFakeResponse(<String, dynamic>{'status': 'ok'}));
|
||||
driverId += 1;
|
||||
logFile = File(path.join(testOutputsDirectory, 'flutter_driver_commands_$driverId.log'));
|
||||
});
|
||||
|
||||
tearDown(() {
|
||||
@@ -738,6 +735,7 @@ void main() {
|
||||
|
||||
test('logCommunicationToFile = true', () async {
|
||||
driver = WebFlutterDriver.connectedTo(fakeConnection);
|
||||
logFile = File(driver.logFilePathName);
|
||||
await driver.waitFor(find.byTooltip('logCommunicationToFile test'), timeout: _kTestTimeout);
|
||||
|
||||
final bool exists = logFile.existsSync();
|
||||
@@ -753,6 +751,11 @@ void main() {
|
||||
|
||||
test('logCommunicationToFile = false', () async {
|
||||
driver = WebFlutterDriver.connectedTo(fakeConnection, logCommunicationToFile: false);
|
||||
logFile = File(driver.logFilePathName);
|
||||
// clear log file if left in filetree from previous run
|
||||
if (logFile.existsSync()) {
|
||||
logFile.deleteSync();
|
||||
}
|
||||
await driver.waitFor(find.byTooltip('logCommunicationToFile test'), timeout: _kTestTimeout);
|
||||
final bool exists = logFile.existsSync();
|
||||
expect(exists, false, reason: 'because ${logFile.path} exists');
|
||||
|
||||
Reference in New Issue
Block a user