Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,39 +31,19 @@ import '../../test_infra/matchers/matchers.dart';
// reduced to under 1 second without introducing flakes.
const inspectorChangeSettleTime = Duration(seconds: 2);

void _copyDirectorySync(Directory source, Directory destination) {
if (!destination.existsSync()) {
destination.createSync(recursive: true);
}
for (final entity in source.listSync()) {
final newPath = p.join(destination.path, p.basename(entity.path));
if (entity is Directory) {
_copyDirectorySync(entity, Directory(newPath));
} else if (entity is File) {
entity.copySync(newPath);
}
}
}

void main() {
// We need to use real async in this test so we need to use this binding.
initializeLiveTestWidgetsFlutterBindingWithAssets();
const windowSize = Size(2600.0, 1200.0);

// We copy the fixture app to a temporary directory because the
// auto-refresh tests modify lib/main.dart in-place. If this used the shared
// 'inspector_app' fixture, it could cause flaky test failures in other tests
// (like inspector_service_test.dart) that run in parallel.
final tempAppDir =
'test/test_infra/fixtures/inspector_app_temp_${DateTime.now().millisecondsSinceEpoch}';
_copyDirectorySync(
Directory('test/test_infra/fixtures/inspector_app'),
Directory(tempAppDir),
);

// The auto-refresh tests modify lib/main.dart in-place.
// We use `useTempDirectory: true` to copy the fixture app to a temporary
// directory. This prevents flaky test failures in other tests (like
// inspector_service_test.dart) that run in parallel.
final env = FlutterTestEnvironment(
const FlutterRunConfiguration(withDebugger: true),
testAppDirectory: tempAppDir,
testAppDirectory: 'test/test_infra/fixtures/inspector_app',
useTempDirectory: true,
);
Comment thread
kenzieschmoll marked this conversation as resolved.

env.afterEverySetup = () async {
Expand Down Expand Up @@ -92,10 +72,6 @@ void main() {

tearDownAll(() {
env.finalTeardown();
final dir = Directory(tempAppDir);
if (dir.existsSync()) {
dir.deleteSync(recursive: true);
}
});

group('screenshot tests', () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ void main() {
final env = FlutterTestEnvironment(
const FlutterRunConfiguration(withDebugger: true),
testAppDirectory: 'test/test_infra/fixtures/inspector_app',
useTempDirectory: true,
);

InspectorService? inspectorService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import '../test_infra/flutter_test_environment.dart';
void main() {
final env = FlutterTestEnvironment(
const FlutterRunConfiguration(withDebugger: true),
useTempDirectory: true,
);

late Disposable isAlive;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ class FlutterTestEnvironment {
_flutterDriverFactory = flutterDriverFactory ?? defaultFlutterRunDriver,
_flutterExe = _parseFlutterExeFromEnv() {
if (useTempDirectory) {
final tempDirectory = Directory.systemTemp.createTempSync(
'flutter_test_temp',
);
final parentDir = p.dirname(testAppDirectory);
final tempDirectory = Directory(
parentDir,
).createTempSync('flutter_test_temp_');
_tempTestAppDirectory = tempDirectory.path;
_copyToTempDirectory(testAppDirectory, tempDirectory);
}
Expand Down
Loading