diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 43ce993..ab7dbbe 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -25,7 +25,7 @@ jobs: - name: Setup Zig uses: goto-bus-stop/setup-zig@v2 with: - version: '0.14.0-dev.1911+3bf89f55c' + version: '0.14.0-dev.2254+73f2671c7' - name: Setup Gradle uses: gradle/actions/setup-gradle@v4 diff --git a/README.md b/README.md index bcf5314..8064992 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,6 @@ utilizes [Zig](https://ziglang.org/) to cross-compile the C/C++ code. ### Prerequisites - [JDK 17](https://adoptopenjdk.net/) -- [Zig nightly](https://ziglang.org/download/) (tested on `0.14.0-dev.1224+16d74809d`) The project currently requires macOS to link to the SDK. It also depends on JDK to be specifically for Darwin. Both of these limitations should be removable with some legwork in the future. diff --git a/build.gradle.kts b/build.gradle.kts index 0e90a4f..a6b416d 100755 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -98,7 +98,7 @@ sourceSets { } zig { - zigVersion = "0.14.0-dev.1911+3bf89f55c" + zigVersion = "0.14.0-dev.2254+73f2671c7" outputDir = layout.buildDirectory.dir("zig") targets { create("x86_64-linux-gnu") diff --git a/src/test/groovy/org/gradle/fileevents/internal/BasicFileEventFunctionsTest.groovy b/src/test/groovy/org/gradle/fileevents/internal/BasicFileEventFunctionsTest.groovy index 0ef70f6..9322ea5 100644 --- a/src/test/groovy/org/gradle/fileevents/internal/BasicFileEventFunctionsTest.groovy +++ b/src/test/groovy/org/gradle/fileevents/internal/BasicFileEventFunctionsTest.groovy @@ -28,7 +28,6 @@ import java.util.concurrent.BlockingQueue import java.util.concurrent.TimeUnit import java.util.regex.Pattern -import static java.util.concurrent.TimeUnit.SECONDS import static org.gradle.fileevents.FileWatchEvent.ChangeType.CREATED import static org.gradle.fileevents.FileWatchEvent.ChangeType.MODIFIED import static org.gradle.fileevents.FileWatchEvent.ChangeType.REMOVED @@ -749,15 +748,6 @@ class BasicFileEventFunctionsTest extends AbstractFileEventFunctionsTest { expectLogMessage(ERROR, "Couldn't queue event: TERMINATE") } - def "can handle watcher start timing out"() { - when: - service.newWatcher(eventQueue).start(0, SECONDS) - - then: - def ex = thrown AbstractFileEventFunctions.FileWatcherTimeoutException - ex.message == "Starting the watcher timed out" - } - @IgnoreIf(value = { Platform.current().windows }, reason = "Windows 2019 Server does not handle this") def "can detect events in directory removed then re-added"() { given: diff --git a/src/test/groovy/org/gradle/fileevents/internal/SyntheticFileEventFunctionsTest.groovy b/src/test/groovy/org/gradle/fileevents/internal/SyntheticFileEventFunctionsTest.groovy index 0c97c22..a931148 100644 --- a/src/test/groovy/org/gradle/fileevents/internal/SyntheticFileEventFunctionsTest.groovy +++ b/src/test/groovy/org/gradle/fileevents/internal/SyntheticFileEventFunctionsTest.groovy @@ -4,28 +4,51 @@ import org.gradle.fileevents.testfixtures.TestFileEventFunctions import spock.lang.Specification import java.util.concurrent.LinkedBlockingDeque -import java.util.concurrent.TimeUnit + +import static java.util.concurrent.TimeUnit.MILLISECONDS +import static java.util.concurrent.TimeUnit.SECONDS class SyntheticFileEventFunctionsTest extends Specification { - def service = new TestFileEventFunctions() def eventQueue = new LinkedBlockingDeque() - def watcher = service - .newWatcher(eventQueue) - .start() def "normal termination produces termination event"() { + def service = new TestFileEventFunctions() + def watcher = service + .newWatcher(eventQueue) + .start() + when: watcher.shutdown() - watcher.awaitTermination(1, TimeUnit.SECONDS) + watcher.awaitTermination(1, SECONDS) + then: eventQueue*.toString() == ["TERMINATE"] } def "failure in run loop produces failure event followed by termination events"() { + def service = new TestFileEventFunctions() + def watcher = service + .newWatcher(eventQueue) + .start() + when: watcher.injectFailureIntoRunLoop() - watcher.awaitTermination(1, TimeUnit.SECONDS) + watcher.awaitTermination(1, SECONDS) + then: eventQueue*.toString() == ["FAILURE Error", "TERMINATE"] } + + def "can handle watcher start timing out"() { + def service = new TestFileEventFunctions({ + Thread.sleep(200) + }) + + when: + service.newWatcher(eventQueue).start(100, MILLISECONDS) + + then: + def ex = thrown AbstractFileEventFunctions.FileWatcherTimeoutException + ex.message == "Starting the watcher timed out" + } } diff --git a/src/test/groovy/org/gradle/fileevents/testfixtures/TestFileEventFunctions.groovy b/src/test/groovy/org/gradle/fileevents/testfixtures/TestFileEventFunctions.groovy index 370e4d6..12016d8 100644 --- a/src/test/groovy/org/gradle/fileevents/testfixtures/TestFileEventFunctions.groovy +++ b/src/test/groovy/org/gradle/fileevents/testfixtures/TestFileEventFunctions.groovy @@ -23,12 +23,18 @@ import java.util.concurrent.LinkedBlockingQueue class TestFileEventFunctions extends AbstractFileEventFunctions { + private final Closure initRunLoop + + TestFileEventFunctions(Closure initRunLoop = {}) { + this.initRunLoop = initRunLoop + } + @Override WatcherBuilder newWatcher(BlockingQueue eventQueue) { new WatcherBuilder(eventQueue) } - static class TestFileWatcher extends AbstractFileEventFunctions.AbstractFileWatcher { + class TestFileWatcher extends AbstractFileEventFunctions.AbstractFileWatcher { enum Command { FAIL, TERMINATE } @@ -41,6 +47,7 @@ class TestFileEventFunctions extends AbstractFileEventFunctions @Override protected void initializeRunLoop() { + initRunLoop.call() } @Override @@ -66,7 +73,7 @@ class TestFileEventFunctions extends AbstractFileEventFunctions @Override protected boolean awaitTermination(long timeoutInMillis) { - return true; + return true } @Override @@ -80,7 +87,7 @@ class TestFileEventFunctions extends AbstractFileEventFunctions } } - static class WatcherBuilder extends AbstractFileEventFunctions.AbstractWatcherBuilder { + class WatcherBuilder extends AbstractFileEventFunctions.AbstractWatcherBuilder { WatcherBuilder(BlockingQueue eventQueue) { super(eventQueue) }