Skip to content

Commit eaa83ef

Browse files
committed
Debug indexingRescanOnOverflow test
1 parent 7e415a2 commit eaa83ef

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/main/java/engineering/swat/watch/impl/overflows/IndexingRescanner.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public class IndexingRescanner extends MemorylessRescanner {
5252
public IndexingRescanner(Executor exec, Path path, WatchScope scope) {
5353
super(exec);
5454
new Indexer(path, scope).walkFileTree(); // Make an initial scan to populate the index
55+
System.out.println("Initial scan done");
5556
}
5657

5758
private class Indexer extends BaseFileVisitor {
@@ -149,6 +150,7 @@ public void accept(EventHandlingWatch watch, WatchEvent event) {
149150
try {
150151
var lastModifiedTimeNew = Files.getLastModifiedTime(fullPath);
151152
var lastModifiedTimeOld = index.put(fullPath, lastModifiedTimeNew);
153+
System.out.println("Index of " + event.getRelativePath() + " updated from " + lastModifiedTimeOld + " to " + lastModifiedTimeNew);
152154

153155
// If a `MODIFIED` event happens for a path that wasn't in
154156
// the index yet, then a `CREATED` event has somehow been

src/test/java/engineering/swat/watch/SingleDirectoryTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ public void execute(Runnable command) {
232232
try (var watch = watchConfig.start()) {
233233
// At this point, the index of last-modified-times inside `watch` is
234234
// populated with initial values.
235+
System.out.println("Performing IO...");
235236

236237
Files.writeString(directory.resolve("a.txt"), "foo");
237238
Files.writeString(directory.resolve("b.txt"), "bar");
@@ -250,8 +251,8 @@ public void execute(Runnable command) {
250251

251252
var overflow = new WatchEvent(WatchEvent.Kind.OVERFLOW, directory);
252253
((EventHandlingWatch) watch).handleEvent(overflow);
253-
System.out.println("------------");
254254
Thread.sleep(TestHelper.NORMAL_WAIT.toMillis());
255+
System.out.println("------------");
255256
// At this point, the current thread has presumably slept long
256257
// enough for the `OVERFLOW` event to have been handled by the
257258
// rescanner. This means that synthetic events must have been issued

0 commit comments

Comments
 (0)