file.dart
file.dart copied to clipboard
MemoryDirectory does not list files properly on Windows
I'm using the MemoryFileSystem in some of my tests, and they fail only on Windows.
I tracked down the cause of the failure to this minimal test of MemoryDirectory:
import 'package:file/memory.dart';
import 'package:path/path.dart';
import 'package:test/test.dart';
void main([List<String> args = const []]) {
group('MemoryFileSystem', () {
var fs = MemoryFileSystem();
setUp(() async {
fs = MemoryFileSystem();
});
test('can list files inside a directory', () async {
final dir = fs.directory('d');
await dir.create();
final foo = fs.file(join('d', 'foo'));
await foo.writeAsString('foo');
final bar = fs.file(join('d', 'bar'));
await bar.writeAsString('bar');
expect(dir.list().map((f) => f.basename),
emitsInAnyOrder(['foo', 'bar', emitsDone]));
});
});
}
The failure on Windows only (it passes on Mac and Linux):
00:18 +26 -6: test\files_test.dart: MemoryFileSystem can list files inside a directory [E]
Expected: should do the following in any order:
* emit an event that 'foo'
* emit an event that 'bar'
* be done
Actual: <Instance of '_MapStream<FileSystemEntity, String>'>
Which: emitted x Stream closed.
package:test_api expect
test\files_test.dart 70:7 main.<fn>.<fn>
===== asynchronous gap ===========================
dart:async _asyncThenWrapperHelper
test\files_test.dart main.<fn>.<fn>
You can see the actual test logs of my project where I added this test, on the GitHub Actions Log.