;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Schematic program tests. ;;; ;;; These tests requires CHICKEN Scheme. ;;; ;;; See this project's README for more information. ;;; ;;; Copyright (c) 2014, Evan Hanson ;;; See LICENSE for details. ;;; (cond-expand (chicken (use r7rs files posix test)) (else (import (scheme base) (scheme write) (scheme process-context)))) (cond-expand (chicken) (else (display "Tests require CHICKEN Scheme, skipping.\n") (exit 1))) (define-values (version bin) (call-with-input-file "../schematic.setup" (lambda (setup) (eval (read setup)) ; (define version ...) (eval (read setup)) ; (define bin ...) (values version bin)))) ;; --version flag. (for-each (lambda (b) (test (format "~a (version)" b) (string->symbol version) (with-input-from-pipe (format "../~a --version" b) read))) bin) ;; Empty input. (for-each (lambda (b) (let*-values (((i o) (create-pipe)) ((_) (file-close o)) ((pid) (process-fork (lambda () (duplicate-fileno i fileno/stdin) (process-execute (format "../~a" b))))) ((_ _ status) (process-wait pid))) (test-assert (format "~a (no input)" b) (zero? status)))) bin)