look up a module on SEX_MODULE_PATH through an import in its test

The test read the search list off get-module-paths, exported for it
alone; importing a module from each entry checks what the list is for.
This commit is contained in:
2026-10-20 11:48:45 +03:00
parent 4758802810
commit 6198c51e88
2 changed files with 29 additions and 16 deletions

View File

@@ -20,10 +20,7 @@
load-persistent-module-paths load-persistent-module-paths
check-public-interface check-public-interface
module-dependencies module-dependencies
read-public-interface read-public-interface)
;; for the tests
get-module-paths)
(define +persistent-module-paths+ (list)) (define +persistent-module-paths+ (list))

View File

@@ -1,22 +1,38 @@
;;; Where imports are looked for. SEX_MODULE_PATH is read once, at the ;;; Where imports are looked for. SEX_MODULE_PATH is read once, at the
;;; start, from the directory sexc was started in. ;;; start, from the directory sexc was started in.
(import (chicken pathname) (import (chicken file)
(chicken pathname)
(chicken process-context) (chicken process-context)
semen
sex-modules) 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" (test-group "module path"
;; make-absolute-pathname took `src' for a directory under the root, ;; make-absolute-pathname took `src' for a directory under the root,
;; and an import searched /src/ ;; and an import searched /src/
(set-environment-variable! "SEX_MODULE_PATH" "src:/abs/lib") (let ((start (current-directory))
(load-persistent-module-paths) (scratch (create-temporary-directory)))
(test "a relative entry is from the working directory" (write-module (make-pathname scratch "src") "mp-relative")
(make-absolute-pathname (current-directory) "src") (write-module (make-pathname scratch "lib") "mp-absolute")
(second (get-module-paths))) (change-directory scratch)
(test "an absolute one is as written" (set-environment-variable! "SEX_MODULE_PATH"
"/abs/lib" (string-append "src:" (make-pathname scratch "lib")))
(third (get-module-paths))) (load-persistent-module-paths)
(change-directory start)
(set-environment-variable! "SEX_MODULE_PATH" "") (test "a relative entry is from the working directory"
(load-persistent-module-paths) '((pub fn found () int))
(unset-environment-variable! "SEX_MODULE_PATH")) (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)))