diff options
| author | Ricardo Wurmus <rekado@elephly.net> | 2026-02-16 19:15:03 +0100 |
|---|---|---|
| committer | Andreas Enge <andreas@enge.fr> | 2026-03-07 11:57:24 +0100 |
| commit | ee0a9f27b903150c53b732f2dd9f6b1cf204bd78 (patch) | |
| tree | 43289d3549610dcd718fd52dab0248a75a62c4a1 | |
| parent | c2a92688a90f842353f540e2a441def10ed65130 (diff) | |
import/cran: Fix import of packages in single quotes.
* guix/import/cran.scm (import-pattern): Also match on single quotes.
(needed-vignettes-inputs-in-directory): Use EXTRACT-IMPORTS.
* tests/import/cran.scm: Add test.
Change-Id: Ie69027992519bd8d886860346f4a359514d8e822
| -rw-r--r-- | guix/import/cran.scm | 18 | ||||
| -rw-r--r-- | tests/import/cran.scm | 7 |
2 files changed, 12 insertions, 13 deletions
diff --git a/guix/import/cran.scm b/guix/import/cran.scm index a53e75a71b3..9c31f50e3e0 100644 --- a/guix/import/cran.scm +++ b/guix/import/cran.scm | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | ;;; GNU Guix --- Functional package management for GNU | 1 | ;;; GNU Guix --- Functional package management for GNU |
| 2 | ;;; Copyright © 2015-2025 Ricardo Wurmus <rekado@elephly.net> | 2 | ;;; Copyright © 2015-2026 Ricardo Wurmus <rekado@elephly.net> |
| 3 | ;;; Copyright © 2015-2017, 2019-2021, 2023 Ludovic Courtès <ludo@gnu.org> | 3 | ;;; Copyright © 2015-2017, 2019-2021, 2023 Ludovic Courtès <ludo@gnu.org> |
| 4 | ;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com> | 4 | ;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com> |
| 5 | ;;; Copyright © 2020 Martin Becze <mjbecze@riseup.net> | 5 | ;;; Copyright © 2020 Martin Becze <mjbecze@riseup.net> |
| @@ -570,7 +570,7 @@ referenced in build system files." | |||
| 570 | ;; Quiet imports | 570 | ;; Quiet imports |
| 571 | "(suppressPackageStartupMessages\\()?" | 571 | "(suppressPackageStartupMessages\\()?" |
| 572 | ;; the actual import statement. | 572 | ;; the actual import statement. |
| 573 | "(require|library|check_installed)\\(\"?([^, \")]+)" | 573 | "(require|library|check_installed)\\([\"']?([^, \"')]+)" |
| 574 | ;; Or perhaps... | 574 | ;; Or perhaps... |
| 575 | "|" | 575 | "|" |
| 576 | ;; ...direct namespace access. | 576 | ;; ...direct namespace access. |
| @@ -654,16 +654,10 @@ in vignette files in the directory DIR." | |||
| 654 | (cond | 654 | (cond |
| 655 | ((eof-object? line) packages) | 655 | ((eof-object? line) packages) |
| 656 | (else | 656 | (else |
| 657 | (loop | 657 | (loop (extract-imports line |
| 658 | (fold (lambda (match acc) | 658 | #:initial-set packages |
| 659 | (let ((imported (match:substring match 4))) | 659 | #:ignored-names (cons package-directory-name |
| 660 | (if (or (not imported) | 660 | default-r-packages)))))))))) |
| 661 | (string=? imported package-directory-name) | ||
| 662 | (member imported default-r-packages)) | ||
| 663 | acc | ||
| 664 | (set-insert imported acc)))) | ||
| 665 | packages | ||
| 666 | (list-matches import-pattern line)))))))))) | ||
| 667 | (set) | 661 | (set) |
| 668 | (append-map (lambda (directory) | 662 | (append-map (lambda (directory) |
| 669 | (find-files directory "\\.Rnw")) | 663 | (find-files directory "\\.Rnw")) |
diff --git a/tests/import/cran.scm b/tests/import/cran.scm index 0b6303370ae..19fd580931c 100644 --- a/tests/import/cran.scm +++ b/tests/import/cran.scm | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | ;;; GNU Guix --- Functional package management for GNU | 1 | ;;; GNU Guix --- Functional package management for GNU |
| 2 | ;;; Copyright © 2015, 2025 Ricardo Wurmus <rekado@elephly.net> | 2 | ;;; Copyright © 2015, 2025-2026 Ricardo Wurmus <rekado@elephly.net> |
| 3 | ;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com> | 3 | ;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com> |
| 4 | ;;; | 4 | ;;; |
| 5 | ;;; This file is part of GNU Guix. | 5 | ;;; This file is part of GNU Guix. |
| @@ -98,6 +98,11 @@ Date/Publication: 2015-07-14 14:15:16 | |||
| 98 | (set->list ((@ (guix import cran) extract-imports) | 98 | (set->list ((@ (guix import cran) extract-imports) |
| 99 | "\"hello::world\", \"this is not data.table::some_procedure(), actually\""))) | 99 | "\"hello::world\", \"this is not data.table::some_procedure(), actually\""))) |
| 100 | 100 | ||
| 101 | (test-equal "extract-imports: extracts text inside single quotes" | ||
| 102 | (list "FDb.InfiniumMethylation.hg19") | ||
| 103 | (set->list ((@ (guix import cran) extract-imports) | ||
| 104 | "suppressPackageStartupMessages(require('FDb.InfiniumMethylation.hg19'))"))) | ||
| 105 | |||
| 101 | (test-equal "extract-imports: ignores other colon separated things" | 106 | (test-equal "extract-imports: ignores other colon separated things" |
| 102 | (list) | 107 | (list) |
| 103 | (set->list ((@ (guix import cran) extract-imports) | 108 | (set->list ((@ (guix import cran) extract-imports) |
