foreign-c-libraries/foreign/c/system/test.scm

25 lines
582 B
Scheme

(import (scheme base)
(scheme write)
(scheme file)
(scheme process-context)
(foreign c system)
(srfi 64))
(test-begin "foreign-c-system")
(define testfile "/tmp/foreign-c-system-test.txt")
(define exit-code1 (system (apply string-append `("echo \"Hello\" > " ,testfile))))
(test-assert (= exit-code1 0))
(define text (with-input-from-file testfile (lambda () (read-line))))
(test-assert (string=? text "Hello"))
(define exit-code2 (system "no-such-command 2> /dev/null"))
(test-assert (> exit-code2 0))
(test-end "foreign-c-system")