41
41
(if (version<? *gaunit-version* "0.1.1")
42
42
(error "GaUnit 0.1.1 is required"))
44
(sys-putenv "LIBUIM_SCM_FILES" "./scm")
44
(sys-putenv "LIBUIM_SYSTEM_SCM_FILES" (string-append (sys-realpath ".")
46
(sys-putenv "LIBUIM_SCM_FILES" (string-append (sys-realpath ".") "/scm"))
47
;; FIXME: '.libs' is hardcoded
48
(sys-putenv "LIBUIM_PLUGIN_LIB_DIR"
49
(string-append (sys-realpath ".") "/uim/.libs"))
45
50
(sys-putenv "LIBUIM_VERBOSE" "2") ;; must be 1 or 2 (2 enables backtrace)
46
51
(sys-putenv "LIBUIM_VANILLA" "1")
100
105
(uim-sh-read (process-output *uim-sh-process*)))
102
107
(define (uim-bool sexp)
103
(not (null? (uim sexp))))
108
(not (not (uim sexp))))
110
;; only the tricky tests require this 'require' emulation.
111
(define (uim-define-siod-compatible-require)
116
(let* ((provided-str (string-append "*" filename "-loaded*"))
117
(provided-sym (string->symbol provided-str)))
118
(if (not (symbol-bound? provided-sym))
121
(eval (list 'define provided-sym #t)
122
(interaction-environment))))
106
(if (version>=? *gaunit-version* "0.0.6")
108
128
(define (*uim-sh-setup-proc*)
109
129
(set! *uim-sh-process* (run-process "uim/uim-sh"
133
(uim '(%%set-current-error-port! (current-output-port))))
113
134
(define (*uim-sh-teardown-proc*)
114
135
(close-input-port (process-input *uim-sh-process*))
115
136
(set! *uim-sh-process* #f))
123
144
(define-test-case arg ...)
124
145
(gaunit-delete-default-setup-proc! *uim-sh-setup-proc*)
125
146
(gaunit-delete-default-teardown-proc! *uim-sh-teardown-proc*))))))
128
(define (**default-test-suite**)
129
(with-module test.unit *default-test-suite*))
131
(with-module test.unit <test-case>))
133
(with-module test.unit make-tests))
134
(define add-test-case!
135
(with-module test.unit add-test-case!))
137
(define (make-uim-sh-setup-proc . args)
138
(let-optionals* args ((additional-setup-proc (lambda () #f)))
140
(set! *uim-sh-process* (run-process "uim/uim-sh"
144
(additional-setup-proc))))
146
(define (make-uim-sh-teardown-proc . args)
147
(let-optionals* args ((additional-teardown-proc (lambda () #f)))
149
(close-input-port (process-input *uim-sh-process*))
150
(set! *uim-sh-process* #f)
151
(additional-teardown-proc))))
153
(define-syntax define-uim-test-case
157
(add-test-case! (**default-test-suite**)
158
(make-uim-test-case name rest ...)))))
160
(define-syntax make-uim-test-case
161
(syntax-rules (setup teardown)
162
((_ name (setup setup-proc) (teardown teardown-proc) test ...)
165
:setup (make-uim-sh-setup-proc setup-proc)
166
:teardown (make-uim-sh-teardown-proc teardown-proc)
167
:tests (make-tests test ...)))
168
((_ name (setup proc) test ...)
171
:setup (make-uim-sh-setup-proc proc)
172
:teardown (make-uim-sh-teardown-proc)
173
:tests (make-tests test ...)))
174
((_ name (teardown proc) test ...)
177
:setup (make-uim-sh-setup-proc)
178
:teardown (make-uim-sh-teardown-proc proc)
179
:tests (make-tests test ...)))
183
:setup (make-uim-sh-setup-proc)
184
:teardown (make-uim-sh-teardown-proc)
185
:tests (make-tests test ...)))))))
186
147
(current-module))
188
149
(provide "test/uim-test-utils")