Skip to content

Commit b947ec9

Browse files
committed
Add a way to run tests many times in parallel.
1 parent 50dd650 commit b947ec9

File tree

5 files changed

+27
-0
lines changed

5 files changed

+27
-0
lines changed

pkgs/watcher/test/directory_watcher/file_tests.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ import 'package:watcher/src/utils.dart';
1212
import '../utils.dart';
1313

1414
void fileTests() {
15+
for (var i = 0; i != runsPerTest; ++i) {
16+
_fileTests();
17+
}
18+
}
19+
20+
void _fileTests() {
1521
test('does not notify for files that already exist when started', () async {
1622
// Make some pre-existing files.
1723
writeFile('a.txt');

pkgs/watcher/test/directory_watcher/link_tests.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ import 'package:test/test.dart';
99
import '../utils.dart';
1010

1111
void linkTests({required bool isNative}) {
12+
for (var i = 0; i != runsPerTest; ++i) {
13+
_linkTests(isNative: isNative);
14+
}
15+
}
16+
17+
void _linkTests({required bool isNative}) {
1218
test('notifies when a link is added', () async {
1319
createDir('targets');
1420
createDir('links');

pkgs/watcher/test/file_watcher/file_tests.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ void fileTests({required bool isNative}) {
1313
writeFile('file.txt');
1414
});
1515

16+
for (var i = 0; i != runsPerTest; ++i) {
17+
_fileTests(isNative: isNative);
18+
}
19+
}
20+
21+
void _fileTests({required bool isNative}) {
1622
test("doesn't notify if the file isn't modified", () async {
1723
await startWatcher(path: 'file.txt');
1824
await expectNoEvents();

pkgs/watcher/test/file_watcher/link_tests.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ void linkTests({required bool isNative}) {
1212
writeLink(link: 'link.txt', target: 'target.txt');
1313
});
1414

15+
for (var i = 0; i != runsPerTest; ++i) {
16+
_linkTests(isNative: isNative);
17+
}
18+
}
19+
20+
void _linkTests({required bool isNative}) {
1521
test("doesn't notify if nothing is modified", () async {
1622
await startWatcher(path: 'link.txt');
1723
await expectNoEvents();

pkgs/watcher/test/utils.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ import 'package:test_descriptor/test_descriptor.dart' as d;
1212
import 'package:watcher/src/stat.dart';
1313
import 'package:watcher/watcher.dart';
1414

15+
/// Edit this to run fast-running tests many times.
16+
int runsPerTest = 100;
17+
1518
typedef WatcherFactory = Watcher Function(String directory);
1619

1720
/// Sets the function used to create the watcher.

0 commit comments

Comments
 (0)