Skip to content

Commit cb95d05

Browse files
committed
Improve tests
1 parent e8ddff2 commit cb95d05

1 file changed

Lines changed: 20 additions & 10 deletions

File tree

t/tests.lisp

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,39 @@
55
(fiasco:define-test-package :ql-https/test)
66
(in-package #:ql-https/test)
77

8+
(defmacro wait ((&key (timeout 10)) &body body)
9+
(let ((gthread (gensym "thread")))
10+
`(let ((,gthread (sb-thread:make-thread (lambda ()
11+
(progn ,@body)))))
12+
(sb-thread:join-thread ,gthread :timeout ,timeout))))
13+
814
(deftest test-ql-https-is-initialized-correctly ()
915
(let ((http-function (cdr (assoc "http" ql-http:*fetch-scheme-functions* :test #'string=)))
1016
(https-function (cdr (assoc "https" ql-http:*fetch-scheme-functions* :test #'string=))))
1117
(is (eq 'ql-https:fetcher http-function) "HTTP doesn't use `ql-https:fetch'")
1218
(is (eq 'ql-https:fetcher https-function) "HTTP doesn't use `ql-https:fetch'")))
1319

1420
(deftest test-downloading-system ()
21+
(ql:uninstall "str")
1522
(let ((ql-https:*quietly-use-https* nil))
1623
(signals ql-https:no-https-error
17-
(ql:quickload "str" :silent t))))
24+
(ql:quickload "str" :silent t))))
1825

1926
(deftest test-quicklisp-download ()
20-
(let ((ql-https:*quietly-use-https* t))
21-
(ql:quickload "str" :silent t))
22-
(is (probe-file (merge-pathnames "quicklisp/dists/quicklisp/installed/systems/str.txt"
23-
(user-homedir-pathname)))))
27+
(ql:uninstall "str")
28+
(wait ()
29+
(let ((ql-https:*quietly-use-https* t))
30+
(ql:quickload "str" :silent t)))
31+
(is (find-package :str)))
2432

2533
(deftest test-ultralisp-download ()
26-
;; install ultralisp
27-
(ql-dist:install-dist "https://dist.ultralisp.org/")
28-
(let ((ql-https:*quietly-use-https* t))
29-
(ql:quickload "hyperdoc" :silent t))
30-
(is (probe-file (merge-pathnames "quicklisp/dists/ultralisp/installed/systems/hyperdoc.txt"))))
34+
(ql:uninstall "hyperdoc")
35+
(wait ()
36+
(let ((ql-https:*quietly-use-https* t))
37+
;; install ultralisp
38+
(ql-dist:install-dist "https://dist.ultralisp.org/" :prompt nil :replace t)
39+
(ql:quickload "hyperdoc" :silent t)))
40+
(is (find-package :hyperdoc)))
3141

3242

3343

0 commit comments

Comments
 (0)