Skip to content

Commit 774e999

Browse files
committed
Make test randomness repeatable.
1 parent 37f8242 commit 774e999

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

pkgs/watcher/test/directory_watcher/end_to_end_tests.dart

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ void endToEndTests({required bool isNative}) {
5252
}
5353

5454
// Verify for real and fail the test if still not consistent.
55-
if (!client.verify(log: true)) {
55+
if (true || !client.verify(log: true)) {
5656
// Write the file operations before the failure to a log, fail the test.
5757
final logTemp = Directory.systemTemp.createTempSync();
5858
final fileChangesLogPath = p.join(logTemp.path, 'changes.txt');
@@ -64,7 +64,10 @@ void endToEndTests({required bool isNative}) {
6464
fail('''
6565
Failed on run $i.
6666
Files changes: $fileChangesLogPath
67-
Client log: $clientLogPath''');
67+
Client log: $clientLogPath
68+
69+
${messages.map((m) => '$m\n').join('')}
70+
''');
6871
}
6972
}
7073
});

pkgs/watcher/test/directory_watcher/file_changer.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ class FileChanger {
133133
/// Returns the path to an already-created file, or `null` if none exists.
134134
String? _randomExistingFilePath() =>
135135
(Directory(path).listSync(recursive: true).whereType<File>().toList()
136+
..sort((a, b) => a.path.compareTo(b.path))
136137
..shuffle(_random))
137138
.firstOrNull
138139
?.path;
@@ -142,6 +143,7 @@ class FileChanger {
142143
String? _randomExistingDirectoryPath() => (Directory(
143144
path,
144145
).listSync(recursive: true).whereType<Directory>().toList()
146+
..sort((a, b) => a.path.compareTo(b.path))
145147
..shuffle(_random))
146148
.firstOrNull
147149
?.path;

0 commit comments

Comments
 (0)