add PLTUSERHOME

The new `PLTUSERHOME` environment variable redirects all of the
user-specific paths reported by `find-system-path`.

Also, improve the tests for `raco exe` (particularly the bug
fixed in 6cb6f3fbf1) using `PLTUSERHOME`.

original commit: e4ce0d0331
This commit is contained in:
Matthew Flatt 2014-02-25 14:54:40 -07:00
parent 6aec40ebfb
commit ec06cc8428

View File

@ -53,7 +53,12 @@
(let ([plthome (getenv "PLTHOME")] (let ([plthome (getenv "PLTHOME")]
[collects (getenv "PLTCOLLECTS")] [collects (getenv "PLTCOLLECTS")]
[out (open-output-string)]) [out (open-output-string)])
(define temp-home-dir (make-temporary-file "racket-tmp-home~a" 'directory))
;; Try to hide usual collections: ;; Try to hide usual collections:
(parameterize ([current-environment-variables
(environment-variables-copy
(current-environment-variables))])
(putenv "PLTUSERHOME" (path->string temp-home-dir))
(when plthome (when plthome
(putenv "PLTHOME" (path->string (build-path (find-system-path 'temp-dir) "NOPE")))) (putenv "PLTHOME" (path->string (build-path (find-system-path 'temp-dir) "NOPE"))))
(when collects (when collects
@ -70,11 +75,8 @@
(test #t (test #t
path path
(parameterize ([current-output-port out]) (parameterize ([current-output-port out])
(system* path))))) (system* path))))))
(when plthome (delete-directory/files temp-home-dir)
(putenv "PLTHOME" plthome))
(when collects
(putenv "PLTCOLLECTS" collects))
(let ([stdout-file (build-path (find-system-path 'temp-dir) "stdout")]) (let ([stdout-file (build-path (find-system-path 'temp-dir) "stdout")])
(if (file-exists? stdout-file) (if (file-exists? stdout-file)
(test expect with-input-from-file stdout-file (test expect with-input-from-file stdout-file