summaryrefslogtreecommitdiff
path: root/tests/lint.scm
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lint.scm')
-rw-r--r--tests/lint.scm88
1 files changed, 88 insertions, 0 deletions
diff --git a/tests/lint.scm b/tests/lint.scm
index 4ef400a9a0..82971db8f0 100644
--- a/tests/lint.scm
+++ b/tests/lint.scm
@@ -8,6 +8,7 @@
;;; Copyright © 2017 Efraim Flashner <efraim@flashner.co.il>
;;; Copyright © 2018, 2019 Arun Isaac <arunisaac@systemreboot.net>
;;; Copyright © 2020 Timothy Sample <samplet@ngyro.com>
+;;; Copyright © 2020 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
;;;
@@ -47,6 +48,7 @@
#:use-module (gnu packages glib)
#:use-module (gnu packages pkg-config)
#:use-module (gnu packages python-xyz)
+ #:use-module ((gnu packages bash) #:select (bash bash-minimal))
#:use-module (web uri)
#:use-module (web server)
#:use-module (web server http)
@@ -357,6 +359,92 @@
`(("python-setuptools" ,python-setuptools))))))
(check-inputs-should-not-be-an-input-at-all pkg))))
+(test-equal "explicit #:sh argument to 'wrap-program' is acceptable"
+ '()
+ (let* ((phases
+ ;; Loosely based on the "catfish" package
+ `(modify-phases %standard-phases
+ (add-after 'install 'wrap
+ (lambda* (#:key inputs outputs #:allow-other-keys)
+ (define catfish (string-append (assoc-ref outputs "out")
+ "/bin/catfish"))
+ (define hsab (string-append (assoc-ref inputs "hsab")
+ "/bin/hsab"))
+ (wrap-program catfish #:sh hsab
+ `("PYTHONPATH" = (,"blabla")))))))
+ (pkg (dummy-package "x" (arguments `(#:phases ,phases)))))
+ (check-wrapper-inputs pkg)))
+
+(test-equal
+ "'check-wrapper-inputs' detects 'wrap-program' without \"bash\" in inputs"
+ "\"bash-minimal\" should be in 'inputs' when 'wrap-program' is used"
+ (let* ((phases
+ `(modify-phases %standard-phases
+ (add-after 'install 'wrap
+ (lambda _
+ (wrap-program the-binary bla-bla)))))
+ (pkg (dummy-package "x" (arguments `(#:phases ,phases)))))
+ (single-lint-warning-message (check-wrapper-inputs pkg))))
+
+(test-equal
+ "'check-wrapper-inputs' detects 'wrap-qt-program' without \"bash\" in inputs"
+ "\"bash-minimal\" should be in 'inputs' when 'wrap-qt-program' is used"
+ (let* ((phases
+ `(modify-phases %standard-phases
+ (add-after 'install 'qtwrap
+ (lambda _
+ (wrap-qt-program the-binary bla-bla)))))
+ (pkg (dummy-package "x" (arguments `(#:phases ,phases)))))
+ (single-lint-warning-message (check-wrapper-inputs pkg))))
+
+(test-equal "\"bash\" in 'inputs' satisfies 'check-wrapper-inputs'"
+ '()
+ (let* ((phases
+ `(modify-phases %standard-phases
+ (add-after 'install 'wrap
+ (lambda _
+ (wrap-program the-binary bla-bla)))))
+ (pkg (dummy-package "x" (arguments `(#:phases ,phases))
+ (inputs `(("bash" ,bash))))))
+ (check-wrapper-inputs pkg)))
+
+(test-equal "\"bash-minimal\" in 'inputs' satisfies 'check-wrapper-inputs'"
+ '()
+ (let* ((phases
+ `(modify-phases %standard-phases
+ (add-after 'install 'wrap
+ (lambda _
+ (wrap-program THE-BINARY bla-bla)))))
+ (pkg (dummy-package "x" (arguments `(#:phases ,phases))
+ (inputs `(("bash-minimal" ,bash-minimal))))))
+ (check-wrapper-inputs pkg)))
+
+(test-equal "'cut' doesn't hide bad usages of 'wrap-program'"
+ "\"bash-minimal\" should be in 'inputs' when 'wrap-program' is used"
+ (let* ((phases
+ ;; Taken from the "straw-viewer" package
+ `(modify-phases %standard-phases
+ (add-after 'install 'wrap-program
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let* ((out (assoc-ref outputs "out"))
+ (bin-dir (string-append out "/bin/"))
+ (site-dir (string-append out "/lib/perl5/site_perl/"))
+ (lib-path (getenv "PERL5LIB")))
+ (for-each (cut wrap-program <>
+ `("PERL5LIB" ":" prefix
+ (,lib-path ,site-dir)))
+ (find-files bin-dir)))))))
+ (pkg (dummy-package "x" (arguments `(#:phases ,phases)))))
+ (single-lint-warning-message (check-wrapper-inputs pkg))))
+
+(test-equal "bogus phase specifications don't crash the linter"
+ "invalid phase clause"
+ (let* ((phases
+ `(modify-phases %standard-phases
+ (add-invalid)))
+ (pkg (dummy-package "x" (arguments `(#:phases ,phases)))))
+ (single-lint-warning-message (check-wrapper-inputs pkg))))
+
(test-equal "file patches: different file name -> warning"
"file names of patches should start with the package name"
(single-lint-warning-message