Simplify probe-load-defaults

Though restart-case for a simple yes/no check is not needed,
we do want pathname defaults and logical-pathname translation
and rejection of wild names.
This commit is contained in:
Douglas Katzman 2024-07-31 22:12:18 +00:00
parent 075de28f8e
commit 99dc09695e
2 changed files with 17 additions and 12 deletions

View file

@ -337,18 +337,7 @@
fasl-existsp defaulted-fasl-pathname)
(flet ((probe (type &aux (candidate (make-pathname :type type
:defaults pathname)))
;; %query-file-system doesn't like LPNs. Maybe this should just
;; always call (%query-file-system (translate-logical-pathname))
;; since that works in either case. The right thing may be to translate
;; before calling PROBE-LOAD-DEFAULTS but I'm not sure, because the
;; translation of the name could differ by the type.
;; In no case should this function ask for truename of a physical
;; pathname on #+unix but maybe on #+win32 it has to, for reasons
;; that I don't know. If so, we can just turn this test into
;; (if (or #+win32 t (logical-pathname-p candidate)))
(values (if (logical-pathname-p candidate)
(probe-file candidate)
(sb-impl::%query-file-system candidate :existence nil))
(values (sb-impl::query-file-system candidate :existence nil)
candidate)))
(multiple-value-call #'values
(probe *load-source-default-type*) (probe *fasl-file-type*)))

16
tests/load.test.sh Normal file
View file

@ -0,0 +1,16 @@
#!/bin/sh
. ./subr.sh
use_test_subdirectory
set -e
mkdir subdir1
echo '(defvar *hi* "hi")' > subdir1/file1.lisp
run_sbcl <<EOF
(setq *default-pathname-defaults*
(merge-pathnames (make-pathname :directory '(:relative "subdir1"))))
(load "file1") ; should merge the dir and default the .lisp type
(assert (string= *hi* "hi"))
EOF
exit $EXIT_TEST_WIN