mirror of
https://github.com/janet-lang/janet
synced 2025-10-17 16:57:40 +00:00
Squashed commit of the following:
commitfbb0711ae1
Author: Calvin Rose <calsrose@gmail.com> Date: Sat Jun 24 12:07:55 2023 -0500 Distinguish between subprocess when testing. commit676b233566
Author: Calvin Rose <calsrose@gmail.com> Date: Sat Jun 24 11:59:17 2023 -0500 Hack for qemu based testing (also should work with valgrind) commitd7431c7cdb
Author: Calvin Rose <calsrose@gmail.com> Date: Sat Jun 24 11:54:04 2023 -0500 Revert "Test removing 32bit ptr marshalling." This reverts commit566b45ea44
. commit566b45ea44
Author: Calvin Rose <calsrose@gmail.com> Date: Sat Jun 24 11:52:22 2023 -0500 Test removing 32bit ptr marshalling. commitff2f71d2bc
Author: Calvin Rose <calsrose@gmail.com> Date: Sat Jun 24 11:42:10 2023 -0500 Conditionally compile marshal_ptr code. commitbd420aeb0e
Author: Calvin Rose <calsrose@gmail.com> Date: Sat Jun 24 11:38:34 2023 -0500 Add range checking to bit-shift code to prevent undefined behavior. commitb738319f8d
Author: Calvin Rose <calsrose@gmail.com> Date: Sat Jun 24 11:17:30 2023 -0500 Remove range check on 32 bit arch since it will always pass. commit7248626235
Author: Calvin Rose <calsrose@gmail.com> Date: Sat Jun 24 10:56:45 2023 -0500 Quiet some build warnings. commit141c1de946
Author: Calvin Rose <calsrose@gmail.com> Date: Sat Jun 24 10:50:13 2023 -0500 Add marshal utilities for pointers. commitc2d77d6720
Merge:677b8a6f
ff90b81e
Author: Calvin Rose <calsrose@gmail.com> Date: Sat Jun 24 10:40:35 2023 -0500 Merge branch 'master' into armtest commit677b8a6f32
Author: Ico Doornekamp <ico@zevv.nl> Date: Mon Jun 12 21:01:26 2023 +0200 Added ARM32 test
This commit is contained in:
@@ -30,10 +30,12 @@
|
||||
(assert (= 1 (brshift 4 2)) "right shift")
|
||||
# unsigned shift
|
||||
(assert (= 32768 (brushift 0x80000000 16)) "right shift unsigned 1")
|
||||
(assert (= -32768 (brshift 0x80000000 16)) "right shift unsigned 2")
|
||||
(assert-error "right shift unsigned 2" (= -32768 (brshift 0x80000000 16)))
|
||||
(assert (= -1 (brshift -1 16)) "right shift unsigned 3")
|
||||
# non-immediate forms
|
||||
(assert (= 32768 (brushift 0x80000000 (+ 0 16))) "right shift unsigned non-immediate")
|
||||
(assert (= -32768 (brshift 0x80000000 (+ 0 16))) "right shift non-immediate")
|
||||
(assert-error "right shift non-immediate" (= -32768 (brshift 0x80000000 (+ 0 16))))
|
||||
(assert (= -1 (brshift -1 (+ 0 16))) "right shift non-immediate 2")
|
||||
(assert (= 32768 (blshift 1 (+ 0 15))) "left shift non-immediate")
|
||||
# 7e46ead
|
||||
(assert (< 1 2 3 4 5 6) "less than integers")
|
||||
|
@@ -25,38 +25,41 @@
|
||||
# 5e1a8c86f
|
||||
(def janet (dyn :executable))
|
||||
|
||||
# Subprocess should inherit the "RUN" parameter for fancy testing
|
||||
(def run (filter next (string/split " " (os/getenv "SUBRUN" ""))))
|
||||
|
||||
(repeat 10
|
||||
|
||||
(let [p (os/spawn [janet "-e" `(print "hello")`] :p {:out :pipe})]
|
||||
(let [p (os/spawn [;run janet "-e" `(print "hello")`] :p {:out :pipe})]
|
||||
(os/proc-wait p)
|
||||
(def x (:read (p :out) :all))
|
||||
(assert (deep= "hello" (string/trim x))
|
||||
"capture stdout from os/spawn pre close."))
|
||||
|
||||
(let [p (os/spawn [janet "-e" `(print "hello")`] :p {:out :pipe})]
|
||||
(let [p (os/spawn [;run janet "-e" `(print "hello")`] :p {:out :pipe})]
|
||||
(def x (:read (p :out) 1024))
|
||||
(os/proc-wait p)
|
||||
(assert (deep= "hello" (string/trim x))
|
||||
"capture stdout from os/spawn post close."))
|
||||
|
||||
(let [p (os/spawn [janet "-e" `(file/read stdin :line)`] :px
|
||||
(let [p (os/spawn [;run janet "-e" `(file/read stdin :line)`] :px
|
||||
{:in :pipe})]
|
||||
(:write (p :in) "hello!\n")
|
||||
(assert-no-error "pipe stdin to process" (os/proc-wait p))))
|
||||
|
||||
(let [p (os/spawn [janet "-e" `(print (file/read stdin :line))`] :px
|
||||
(let [p (os/spawn [;run janet "-e" `(print (file/read stdin :line))`] :px
|
||||
{:in :pipe :out :pipe})]
|
||||
(:write (p :in) "hello!\n")
|
||||
(def x (:read (p :out) 1024))
|
||||
(assert-no-error "pipe stdin to process 2" (os/proc-wait p))
|
||||
(assert (= "hello!" (string/trim x)) "round trip pipeline in process"))
|
||||
|
||||
(let [p (os/spawn [janet "-e" `(do (ev/sleep 30) (os/exit 24)`] :p)]
|
||||
(let [p (os/spawn [;run janet "-e" `(do (ev/sleep 30) (os/exit 24)`] :p)]
|
||||
(os/proc-kill p)
|
||||
(def retval (os/proc-wait p))
|
||||
(assert (not= retval 24) "Process was *not* terminated by parent"))
|
||||
|
||||
(let [p (os/spawn [janet "-e" `(do (ev/sleep 30) (os/exit 24)`] :p)]
|
||||
(let [p (os/spawn [;run janet "-e" `(do (ev/sleep 30) (os/exit 24)`] :p)]
|
||||
(os/proc-kill p false :term)
|
||||
(def retval (os/proc-wait p))
|
||||
(assert (not= retval 24) "Process was *not* terminated by parent"))
|
||||
@@ -66,7 +69,7 @@
|
||||
(defn calc-1
|
||||
"Run subprocess, read from stdout, then wait on subprocess."
|
||||
[code]
|
||||
(let [p (os/spawn [janet "-e" (string `(printf "%j" ` code `)`)] :px
|
||||
(let [p (os/spawn [;run janet "-e" (string `(printf "%j" ` code `)`)] :px
|
||||
{:out :pipe})]
|
||||
(os/proc-wait p)
|
||||
(def output (:read (p :out) :all))
|
||||
@@ -86,7 +89,7 @@
|
||||
to 10 bytes instead of :all
|
||||
``
|
||||
[code]
|
||||
(let [p (os/spawn [janet "-e" (string `(printf "%j" ` code `)`)] :px
|
||||
(let [p (os/spawn [;run janet "-e" (string `(printf "%j" ` code `)`)] :px
|
||||
{:out :pipe})]
|
||||
(def output (:read (p :out) 10))
|
||||
(os/proc-wait p)
|
||||
@@ -104,18 +107,18 @@
|
||||
# a1cc5ca04
|
||||
(assert-no-error "file writing 1"
|
||||
(with [f (file/temp)]
|
||||
(os/execute [janet "-e" `(repeat 20 (print :hello))`] :p {:out f})))
|
||||
(os/execute [;run janet "-e" `(repeat 20 (print :hello))`] :p {:out f})))
|
||||
|
||||
(assert-no-error "file writing 2"
|
||||
(with [f (file/open "unique.txt" :w)]
|
||||
(os/execute [janet "-e" `(repeat 20 (print :hello))`] :p {:out f})
|
||||
(os/execute [;run janet "-e" `(repeat 20 (print :hello))`] :p {:out f})
|
||||
(file/flush f)))
|
||||
|
||||
# Issue #593
|
||||
# a1cc5ca04
|
||||
(assert-no-error "file writing 3"
|
||||
(def outfile (file/open "unique.txt" :w))
|
||||
(os/execute [janet "-e" "(pp (seq [i :range (1 10)] i))"] :p
|
||||
(os/execute [;run janet "-e" "(pp (seq [i :range (1 10)] i))"] :p
|
||||
{:out outfile})
|
||||
(file/flush outfile)
|
||||
(file/close outfile)
|
||||
@@ -256,7 +259,7 @@
|
||||
(ev/cancel fiber "boop")
|
||||
|
||||
# f0dbc2e
|
||||
(assert (os/execute [janet "-e" `(+ 1 2 3)`] :xp) "os/execute self")
|
||||
(assert (os/execute [;run janet "-e" `(+ 1 2 3)`] :xp) "os/execute self")
|
||||
|
||||
# Test some channel
|
||||
# e76b8da26
|
||||
|
@@ -21,6 +21,9 @@
|
||||
(import ./helper :prefix "" :exit true)
|
||||
(start-suite)
|
||||
|
||||
(def janet (dyn :executable))
|
||||
(def run (filter next (string/split " " (os/getenv "SUBRUN" ""))))
|
||||
|
||||
# OS Date test
|
||||
# 719f7ba0c
|
||||
(assert (deep= {:year-day 0
|
||||
@@ -118,14 +121,14 @@
|
||||
|
||||
# os/execute with environment variables
|
||||
# issue #636 - 7e2c433ab
|
||||
(assert (= 0 (os/execute [(dyn :executable) "-e" "(+ 1 2 3)"] :pe
|
||||
(assert (= 0 (os/execute [;run janet "-e" "(+ 1 2 3)"] :pe
|
||||
(merge (os/environ) {"HELLO" "WORLD"})))
|
||||
"os/execute with env")
|
||||
|
||||
# os/execute regressions
|
||||
# 427f7c362
|
||||
(for i 0 10
|
||||
(assert (= i (os/execute [(dyn :executable) "-e"
|
||||
(assert (= i (os/execute [;run janet "-e"
|
||||
(string/format "(os/exit %d)" i)] :p))
|
||||
(string "os/execute " i)))
|
||||
|
||||
@@ -138,7 +141,7 @@
|
||||
"/dev/null"))
|
||||
(os/open path :w))
|
||||
(with [dn (devnull)]
|
||||
(os/execute [(dyn :executable)
|
||||
(os/execute [;run janet
|
||||
"-e"
|
||||
"(print :foo) (eprint :bar)"]
|
||||
:px
|
||||
|
Reference in New Issue
Block a user