Skip to content

Commit 922eb19

Browse files
committed
fix hook integration test for Windows
1 parent 88850ef commit 922eb19

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

integration-test/integration/chat/hooks_test.clj

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,8 @@
181181

182182
(llm.mocks/set-case! :tool-calling-0)
183183

184-
(let [log-path (io/file h/default-root-project-path ".eca/posttool-log.txt")]
184+
(let [log-path (io/file h/default-root-project-path ".eca/posttool-log.txt")
185+
win? (string/starts-with? (System/getProperty "os.name") "Windows")]
185186
(io/make-parents log-path)
186187
(io/delete-file log-path true)
187188

@@ -193,7 +194,9 @@
193194
:actions [{:type "shell"
194195
;; Use a single jq invocation to extract both values
195196
;; stdin is only available once per hook execution
196-
:shell (str "cat >" log-path)}]}})}))
197+
:shell (if win?
198+
(str "$Input | Set-Content " log-path)
199+
(str "cat >" log-path))}]}})}))
197200

198201
(eca/notify! (fixture/initialized-notification))
199202

@@ -288,18 +291,21 @@
288291

289292
(deftest pretoolcall-exit-code-rejection-with-stop-test
290293
(testing "preToolCall hook exit code 2 rejects tool and continue:false stops chat"
291-
(eca/start-process!)
294+
(let [win? (string/starts-with? (System/getProperty "os.name") "Windows")]
295+
(eca/start-process!)
292296

293-
(llm.mocks/set-case! :tool-calling-0)
297+
(llm.mocks/set-case! :tool-calling-0)
294298

295-
(eca/request!
296-
(fixture/initialize-request
297-
{:initializationOptions
298-
(hooks-init-options
299-
{"reject-and-stop" {:type "preToolCall"
300-
:actions [{:type "shell"
301-
;; Exit code 2 means rejection, with continue:false and stopReason
302-
:shell "echo '{\"continue\":false,\"stopReason\":\"Security policy violation\"}' && exit 2"}]}})}))
299+
(eca/request!
300+
(fixture/initialize-request
301+
{:initializationOptions
302+
(hooks-init-options
303+
{"reject-and-stop" {:type "preToolCall"
304+
:actions [{:type "shell"
305+
;; Exit code 2 means rejection, with continue:false and stopReason
306+
:shell (if win?
307+
"Write-Output '{\"continue\":false,\"stopReason\":\"Security policy violation\"}'; exit 2"
308+
"echo '{\"continue\":false,\"stopReason\":\"Security policy violation\"}' && exit 2")}]}})})))
303309

304310
(eca/notify! (fixture/initialized-notification))
305311

0 commit comments

Comments
 (0)