Use a semaphore instead of sleeping in this test.

This commit is contained in:
Sam Tobin-Hochstadt 2015-11-05 16:30:46 -05:00
parent f126fd2356
commit 171e4fba41

View File

@ -16,6 +16,7 @@
(initialize-catalogs) (initialize-catalogs)
(define okay-to-start?-sema (make-semaphore)) (define okay-to-start?-sema (make-semaphore))
(define okay-to-respond?-sema (make-semaphore)) (define okay-to-respond?-sema (make-semaphore))
(define okay-to-quit?-sema (make-semaphore))
(thread (thread
(λ () (λ ()
(serve/servlet (pkg-index/basic (serve/servlet (pkg-index/basic
@ -28,7 +29,8 @@
#:command-line? #t #:command-line? #t
#:servlet-regexp #rx"" #:servlet-regexp #rx""
#:port 9967) #:port 9967)
(sleep 2))) (semaphore-wait okay-to-quit?-sema)
(semaphore-wait okay-to-quit?-sema)))
;; Step 2: Assign it as our server ;; Step 2: Assign it as our server
$ "raco pkg config --set catalogs http://localhost:9967" $ "raco pkg config --set catalogs http://localhost:9967"
@ -37,11 +39,13 @@
(thread (thread
(λ () (λ ()
(shelly-begin (shelly-begin
$ "raco pkg install pkg-test1"))) $ "raco pkg install pkg-test1")
(semaphore-post okay-to-quit?-sema)))
(semaphore-wait okay-to-start?-sema) (semaphore-wait okay-to-start?-sema)
;; Step 4: Start the installation request that will fail ;; Step 4: Start the installation request that will fail
$ "raco pkg install pkg-test1" =exit> 1 $ "raco pkg install pkg-test1" =exit> 1
;; Step 5: Free the other one ;; Step 5: Free the other one
(semaphore-post okay-to-respond?-sema)))) (semaphore-post okay-to-respond?-sema)
(semaphore-post okay-to-quit?-sema))))