From 2ea90334a3e25405fa4112ae0822fb40fd9e1b7a Mon Sep 17 00:00:00 2001 From: Calvin Rose Date: Mon, 2 Oct 2023 23:25:26 -0700 Subject: [PATCH] Remove some checking code for iocp events. Be more permissive abouts events we get. --- src/core/ev.c | 1 - test/suite-ev.janet | 27 ++++++++++++++++++++++++--- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/core/ev.c b/src/core/ev.c index 5b0914f5..057296a7 100644 --- a/src/core/ev.c +++ b/src/core/ev.c @@ -1525,7 +1525,6 @@ void janet_loop1_impl(int has_timeout, JanetTimestamp to) { } else { /* Normal event */ JanetStream *stream = (JanetStream *) completionKey; - janet_assert(stream->handle != INVALID_HANDLE_VALUE, "got closed stream event"); JanetListenerState *state = NULL; if (stream->read_state && stream->read_state->tag == overlapped) { state = stream->read_state; diff --git a/test/suite-ev.janet b/test/suite-ev.janet index ccecdf4e..6e1e8a15 100644 --- a/test/suite-ev.janet +++ b/test/suite-ev.janet @@ -23,7 +23,7 @@ # Subprocess # 5e1a8c86f -(def janet (dyn :executable)) +(def janet (dyn *executable*)) # Subprocess should inherit the "RUN" parameter for fancy testing (def run (filter next (string/split " " (os/getenv "SUBRUN" "")))) @@ -205,7 +205,8 @@ (test-echo "world") (test-echo (string/repeat "abcd" 200)) - (:close s)) + (:close s) + (gccollect)) # Test on both server and client # 504411e @@ -344,5 +345,25 @@ (ev/go |(ev/chan-close ch)) (assert (= (ev/select [ch 1]) [:close ch])) -(end-suite) +# ev/gather check +(defn exec-slurp + "Read stdout of subprocess and return it trimmed in a string." + [& args] + (def env (os/environ)) + (put env :out :pipe) + (def proc (os/spawn args :epx env)) + (def out (get proc :out)) + (def buf @"") + (ev/gather + (:read out :all buf) + (:wait proc)) + (string/trimr buf)) +(assert-no-error + "ev/with-deadline 1" + (assert (= "hi" + (ev/with-deadline + 10 + (exec-slurp janet "-e" "(print :hi)"))) + "exec-slurp 1")) +(end-suite)