diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2022-02-16 11:27:43 +0100 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2022-02-16 16:49:26 +0100 |
| commit | ca155a20aea25003b03ef5e0420c77e416d5f425 (patch) | |
| tree | 73a8756b3a89dbbf85fde19e935da19c90c88472 /tests/gexp.scm | |
| parent | 176354c2f887942a9bdb6ccbdb754094eacd06fa (diff) | |
gexp: Preserve source location for #~ and #$ read extensions.
Read hash extensions preserve source location info as source properties
on their result. However, in Guile 3.0.8, that location would be
dismissed, leading 'local-file' to fail to resolve file names relative
to the source directory.
Fixes <https://issues.guix.gnu.org/54003>.
Reported by Aleksandr Vityazev <avityazev@posteo.org>.
* guix/gexp.scm <eval-when> [read-syntax-redefined?, read-procedure]
[read-syntax*]: New variables.
[read-ungexp]: Adjust to expect either sexps or syntax objects.
[read-gexp]: Call 'read-procedure'.
* tests/gexp.scm ("local-file, relative file name, within gexp")
("local-file, relative file name, within gexp, compiled"): New tests.
Diffstat (limited to 'tests/gexp.scm')
| -rw-r--r-- | tests/gexp.scm | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/gexp.scm b/tests/gexp.scm index bcda516623a..33c0e4bf8c1 100644 --- a/tests/gexp.scm +++ b/tests/gexp.scm | |||
| @@ -28,6 +28,7 @@ | |||
| 28 | #:use-module (guix tests) | 28 | #:use-module (guix tests) |
| 29 | #:use-module ((guix build utils) #:select (with-directory-excursion)) | 29 | #:use-module ((guix build utils) #:select (with-directory-excursion)) |
| 30 | #:use-module ((guix utils) #:select (call-with-temporary-directory)) | 30 | #:use-module ((guix utils) #:select (call-with-temporary-directory)) |
| 31 | #:use-module ((guix ui) #:select (load*)) | ||
| 31 | #:use-module (gnu packages) | 32 | #:use-module (gnu packages) |
| 32 | #:use-module (gnu packages base) | 33 | #:use-module (gnu packages base) |
| 33 | #:use-module (gnu packages bootstrap) | 34 | #:use-module (gnu packages bootstrap) |
| @@ -222,6 +223,32 @@ | |||
| 222 | (let ((file (local-file (string-copy "../base32.scm")))) | 223 | (let ((file (local-file (string-copy "../base32.scm")))) |
| 223 | (local-file-absolute-file-name file))))) | 224 | (local-file-absolute-file-name file))))) |
| 224 | 225 | ||
| 226 | (test-assert "local-file, relative file name, within gexp" | ||
| 227 | (let* ((file (search-path %load-path "guix/base32.scm")) | ||
| 228 | (interned (add-to-store %store "base32.scm" #f "sha256" file))) | ||
| 229 | (equal? `(the file is ,interned) | ||
| 230 | (gexp->sexp* | ||
| 231 | #~(the file is #$(local-file "../guix/base32.scm")))))) | ||
| 232 | |||
| 233 | (test-assert "local-file, relative file name, within gexp, compiled" | ||
| 234 | ;; In Guile 3.0.8, everything read by the #~ and #$ read hash extensions | ||
| 235 | ;; would lack source location info, which in turn would lead | ||
| 236 | ;; (current-source-directory), called by 'local-file', to return #f, thereby | ||
| 237 | ;; breaking 'local-file' resolution. See | ||
| 238 | ;; <https://issues.guix.gnu.org/54003>. | ||
| 239 | (let ((file (tmpnam))) | ||
| 240 | (call-with-output-file file | ||
| 241 | (lambda (port) | ||
| 242 | (display (string-append "#~(this file is #$(local-file \"" | ||
| 243 | (basename file) "\" \"t.scm\"))") | ||
| 244 | port))) | ||
| 245 | |||
| 246 | (let* ((interned (add-to-store %store "t.scm" #f "sha256" file)) | ||
| 247 | (module (make-fresh-user-module))) | ||
| 248 | (module-use! module (resolve-interface '(guix gexp))) | ||
| 249 | (equal? `(this file is ,interned) | ||
| 250 | (gexp->sexp* (load* file module)))))) | ||
| 251 | |||
| 225 | (test-assertm "local-file, #:select?" | 252 | (test-assertm "local-file, #:select?" |
| 226 | (mlet* %store-monad ((select? -> (lambda (file stat) | 253 | (mlet* %store-monad ((select? -> (lambda (file stat) |
| 227 | (member (basename file) | 254 | (member (basename file) |
