Commit 9e6586f8 authored by Eric Timmons's avatar Eric Timmons
Browse files

Make it easier to run tests in a clean environment

parent 2950183a
......@@ -11,10 +11,11 @@
:description "Tests for CLPM"
:license "BSD-2-Clause"
:pathname "test/"
:depends-on (#:parachute #:hunchentoot)
:depends-on (#:parachute #:hunchentoot #:alexandria)
:serial t
((:file "package")
(:file "utils")
(:file "suite")
(:file "quicklisp-bundle")
(:file "tests")))
(cl:defpackage #:clpm-test
(:use #:cl)
(:local-nicknames (#:para #:parachute)))
(:local-nicknames (#:para #:parachute)
(#:alex #:alexandria)))
......@@ -2,11 +2,15 @@
(para:define-test quicklisp-bundle
(uiop:with-current-directory ((asdf:system-relative-pathname :clpm "test/quicklisp-bundle/"))
(uiop:run-program `(,*clpm* "bundle" "install" "-y" "--no-resolve")
:output :interactive
:error-output :interactive))
(uiop:run-program `(,*clpm* "bundle" "exec" "--" "sbcl" "--non-interactive" "--no-userinit" "--no-sysinit" "--eval" "(require :asdf)" "--eval" "(asdf:load-system :quicklisp-bundle)" "--quit")
:output :interactive
:error-output :interactive))))
(with-clpm-env ()
(clpm '("bundle" "install" "-y" "--no-resolve")
:output :interactive
:error-output :interactive)
(clpm '("bundle" "exec"
"sbcl" "--non-interactive" "--no-userinit" "--no-sysinit"
"--eval" "(require :asdf)"
"--eval" "(asdf:load-system :quicklisp-bundle)"
:output :interactive
:error-output :interactive))))
......@@ -2,3 +2,24 @@
(defvar *clpm* "clpm"
"How to run clpm")
(defvar *clpm-env* nil)
(defun clpm (command &key output error-output)
(apply 'uiop:run-program
(list* *clpm* command)
:output output :error-output error-output
(run-program-augment-env-args *clpm-env*)))
(defun call-with-clpm-env (thunk)
(with-temporary-directory (cache-dir :prefix "clpm-test-cache")
(with-temporary-directory (data-dir :prefix "clpm-test-data")
(let ((*clpm-env* (list (cons "CLPM_DATA_DIR" (uiop:native-namestring data-dir))
(cons "CLPM_CACHE_DIR" (uiop:native-namestring cache-dir)))))
(funcall thunk :cache-dir cache-dir :data-dir data-dir)))))
(defmacro with-clpm-env ((&key (cache-dir (gensym)) (data-dir (gensym)))
&body body)
`(call-with-clpm-env (lambda (&key ((:cache-dir ,cache-dir)) ((:data-dir ,data-dir)))
(declare (ignorable ,cache-dir ,data-dir))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment