mirror of
https://github.com/flutter/packages.git
synced 2025-07-08 03:46:19 +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:
packages/path_provider
path_provider/example/integration_test
path_provider_android/example/integration_test
@ -117,6 +117,13 @@ void _verifySampleFile(Directory? directory, String name) {
|
|||||||
|
|
||||||
file.writeAsStringSync('Hello world!');
|
file.writeAsStringSync('Hello world!');
|
||||||
expect(file.readAsStringSync(), '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();
|
file.deleteSync();
|
||||||
}
|
}
|
||||||
|
@ -101,6 +101,9 @@ void _verifySampleFile(String? directoryPath, String name) {
|
|||||||
|
|
||||||
file.writeAsStringSync('Hello world!');
|
file.writeAsStringSync('Hello world!');
|
||||||
expect(file.readAsStringSync(), '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();
|
file.deleteSync();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user