mirror of
https://github.com/flutter/packages.git
synced 2025-06-26 03:03:23 +08:00
[path_provider] De-flake getExternalStorageDirectories test (#5628)
Fixes the flaky path provider test. Directories.listSync will sometimes not return the files in the directory (as discussed in https://github.com/flutter/flutter/issues/139378), but the files are there and (after letting it loop for quite a while and comparing to current flake) they always appear in the output of `Process.runSync('ls', ...)`.
This commit is contained in:
@ -117,6 +117,13 @@ void _verifySampleFile(Directory? directory, String name) {
|
||||
|
||||
file.writeAsStringSync('Hello world!');
|
||||
expect(file.readAsStringSync(), 'Hello world!');
|
||||
expect(directory.listSync(), isNotEmpty);
|
||||
// This check intentionally avoids using Directory.listSync on Android due to
|
||||
// https://github.com/dart-lang/sdk/issues/54287.
|
||||
if (Platform.isAndroid) {
|
||||
expect(
|
||||
Process.runSync('ls', <String>[directory.path]).stdout, contains(name));
|
||||
} else {
|
||||
expect(directory.listSync(), isNotEmpty);
|
||||
}
|
||||
file.deleteSync();
|
||||
}
|
||||
|
@ -101,6 +101,9 @@ void _verifySampleFile(String? directoryPath, String name) {
|
||||
|
||||
file.writeAsStringSync('Hello world!');
|
||||
expect(file.readAsStringSync(), 'Hello world!');
|
||||
expect(directory.listSync(), isNotEmpty);
|
||||
// This check intentionally avoids using Directory.listSync due to
|
||||
// https://github.com/dart-lang/sdk/issues/54287.
|
||||
expect(
|
||||
Process.runSync('ls', <String>[directory.path]).stdout, contains(name));
|
||||
file.deleteSync();
|
||||
}
|
||||
|
Reference in New Issue
Block a user