;;;; pty-test.scm (use testbase testbase-output-human) (use pty) (use utils miscmacros) (define-for-syntax test::timing #f) (define-for-syntax test::filtering #f) (define-for-syntax test::selecting #f) (define-for-syntax test::limiting #f) #;(define (kill-it! pid) (process-signal pid) (process-wait pid #t) ) #;(char-name 'eot (integer->char 4)) (define-test pty-error-test "Pty procedure error" (expect-exception "Invalid Procedure" (property exn (message "invalid procedure") (arguments '(foo)) (location 'call-with-pty-process-io)) (call-with-pty-process-io "foo" 'foo)) ) ;** PROBLEM ** ;Port out appears echoed to in ;Repeat runs have caused system crash on MacOS 10.4 ;Repeat runs have caused process pend on MacOS 10.4 ;Must be using 'bc' wrong #;(define-test pty-bc-test "Pty using 'bc'" (expect-eqv "PI" 3.1415926532 (call-with-pty-process-io '("/usr/bin/bc" "-lqi") (lambda (in out pid) ;operation (display "scale=10; 4*a(1)" out) (newline out) ;result (begin0 (read in) #;(let loop ([lines '()]) (if (char-ready? in) (loop (cons (read-line in) lines)) (reverse! lines))) ;clean termination (display "quit" out) (newline out) ) ) "BC")) (expect-success (gc #t)) ) (define-test pty-units-test "Pty using 'units'" (expect-equal "Meters/Feet" '("meters" "feet" "\t* 3.2808399" "\t/ 0.3048") (call-with-pty-process-io '("/usr/bin/units" "-q") (lambda (in out pid) ;operation (display "meters" out) (newline out) (display "feet" out) (newline out) ;result (begin0 (list (read-line in) (read-line in) (read-line in) (read-line in)) ;clean termination - send EOT (display (integer->char 4) out) ) ) "Units")) (expect-success (gc #t)) ) (test::for-each (cut test::styler-set! <> test::output-style-human)) (run-test "Pty Test")