Description
Context: flutter/flutter#139378
We have an integration test in the flutter/packages repo that creates a file, reads it, and then checks also that the directory contains the file (actual contents of the test here):
final File file = File('${directory.path}/$name');
...
file.writeAsStringSync('Hello world!');
expect(file.readAsStringSync(), 'Hello world!');
expect(directory.listSync(), isNotEmpty);
This test is flaking from time to time on the last expect. I don't believe that this is a timing issue (it shouldn't be because these are synchronous operations, but also I've tried adding a sleep just in case and still saw it flake) nor a permissions issue (the read for the file still succeeds, and also it flakes even locally on my machine where the permissions aren't changing).
I've also tried looping for some time and comparing the output of directory.listSync
to Process.runSync('ls', [directory.path])
, and even when the file is missing in the former it is still there in the output of the latter.
Is there something that I'm missing that is wrong with the test here, or might there be an issue with Directory.listSync
itself?
If you aren't sure, file the issue here, and we'll find the right home for it.
In your issue, please include:
- Dart version and tooling diagnostic info (
dart info
)
If providing this information as part of reporting a bug, please review the information
below to ensure it only contains things you're comfortable posting publicly.
#### General info
- Dart 3.3.0-198.0.dev (dev) (Wed Dec 6 04:03:18 2023 -0800) on "macos_arm64"
- on macos / Version 14.1 (Build 23B74)
- locale is en
#### Process info
| Memory | CPU | Elapsed time | Command line |
| -----: | ---: | -----------: | ------------------------------------------------------------------------------------------ |
| 22 MB | 0.0% | 01-18:08:37 | dart language-server --client-id=Android-Studio --client-version=AI-222.4459.24 --protocol=analyzer |
| 14 MB | 0.0% | 01-18:08:36 | dart language-server --client-id=Android-Studio --client-version=AI-222.4459.24 --protocol=analyzer |
| 10 MB | 0.0% | 02-23:10:18 | dart language-server --client-id=Android-Studio --client-version=AI-222.4459.24 --protocol=analyzer |
| 20 MB | 0.2% | 01-18:08:39 | flutter_tools.snapshot daemon |
| 26 MB | 0.1% | 19:54:16 | flutter_tools.snapshot daemon |
| 38 MB | 0.3% | 24:11 | flutter_tools.snapshot daemon
- Whether you are using Windows, macOS, or Linux (if applicable)
Locally macOS, but flake is also happens on linux in CI.
Missing some or all of the above might make the issue take longer or
be impossible to act on.
If you simply have a question, please consider using the listed Dart
developer communities on the following page: