[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:
Gray Mackall
2023-12-13 12:26:56 -08:00
committed by GitHub
parent b08f91588d
commit 2133991a46
2 changed files with 12 additions and 2 deletions

View File

@ -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();
}

View File

@ -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();
}