diff --git a/sex-modules.scm b/sex-modules.scm index 8044d764..21acc869 100644 --- a/sex-modules.scm +++ b/sex-modules.scm @@ -20,10 +20,7 @@ load-persistent-module-paths check-public-interface module-dependencies - read-public-interface - - ;; for the tests - get-module-paths) + read-public-interface) (define +persistent-module-paths+ (list)) diff --git a/tests/module-path.scm b/tests/module-path.scm index fbce7880..e0781067 100644 --- a/tests/module-path.scm +++ b/tests/module-path.scm @@ -1,22 +1,38 @@ ;;; Where imports are looked for. SEX_MODULE_PATH is read once, at the ;;; start, from the directory sexc was started in. -(import (chicken pathname) +(import (chicken file) + (chicken pathname) (chicken process-context) + semen sex-modules) +(define (write-module dir name) + (create-directory dir #t) + (with-output-to-file (make-pathname dir name "sex") + (lambda () (display "(pub fn found () int)")))) + (test-group "module path" ;; make-absolute-pathname took `src' for a directory under the root, ;; and an import searched /src/ - (set-environment-variable! "SEX_MODULE_PATH" "src:/abs/lib") - (load-persistent-module-paths) - (test "a relative entry is from the working directory" - (make-absolute-pathname (current-directory) "src") - (second (get-module-paths))) - (test "an absolute one is as written" - "/abs/lib" - (third (get-module-paths))) + (let ((start (current-directory)) + (scratch (create-temporary-directory))) + (write-module (make-pathname scratch "src") "mp-relative") + (write-module (make-pathname scratch "lib") "mp-absolute") + (change-directory scratch) + (set-environment-variable! "SEX_MODULE_PATH" + (string-append "src:" (make-pathname scratch "lib"))) + (load-persistent-module-paths) + (change-directory start) - (set-environment-variable! "SEX_MODULE_PATH" "") - (load-persistent-module-paths) - (unset-environment-variable! "SEX_MODULE_PATH")) + (test "a relative entry is from the working directory" + '((pub fn found () int)) + (semen-process '((import mp-relative)))) + (test "an absolute one is as written" + '((pub fn found () int)) + (semen-process '((import mp-absolute)))) + + (set-environment-variable! "SEX_MODULE_PATH" "") + (load-persistent-module-paths) + (unset-environment-variable! "SEX_MODULE_PATH") + (delete-directory scratch #t)))