File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 1+ (ns libpython-clj2.uv-test
2+ (:require [clojure.test :refer :all ]
3+ [clojure.string :as str]
4+ [libpython-clj2.python.uv :as uv]))
5+
6+
7+ (deftest start-and-print-captures-stdout
8+ (let [out (with-out-str
9+ (@#'libpython-clj2.python.uv/start-and-print!
10+ [" sh" " -lc" " printf 'hello\n ' " ]))]
11+ (is (= " hello\n " out))))
12+
13+ (deftest start-and-print-captures-stderr
14+ (let [out (with-out-str
15+ (@#'libpython-clj2.python.uv/start-and-print!
16+ [" sh" " -lc" " printf 'oops\n ' 1>&2 " ]))]
17+ (is (= " oops\n " out))))
18+
19+ (deftest start-and-print-reads-stdout-then-stderr
20+ ; ; The child process writes interleaved to stdout and stderr, but
21+ ; ; start-and-print! reads stdout to completion before stderr, so the
22+ ; ; captured output should have all stdout first, then all stderr.
23+ (let [script (str/join " ; " [" echo out1"
24+ " echo err1 1>&2"
25+ " echo out2"
26+ " echo err2 1>&2" ])
27+ out (with-out-str
28+ (@#'libpython-clj2.python.uv/start-and-print!
29+ [" sh" " -lc" script]))]
30+ (is (= (str " out1\n "
31+ " out2\n "
32+ " err1\n "
33+ " err2\n " )
34+ out))))
You can’t perform that action at this time.
0 commit comments