summaryrefslogtreecommitdiff
path: root/guix/lint.scm
diff options
context:
space:
mode:
authorMaxime Devos <maximedevos@telenet.be>2021-05-09 14:35:57 +0200
committerMathieu Othacehe <othacehe@gnu.org>2021-06-06 18:49:12 +0200
commit82b0e27de109b38ed44f67434a96460c4a7f9217 (patch)
tree8e4a856ded82da528047fa7ef446fcbf4cb28e4d /guix/lint.scm
parente2ad110f4c2a54cecaa8fed3792ba2dbe5fa2af4 (diff)
downloadguix-patches-82b0e27de109b38ed44f67434a96460c4a7f9217.tar
guix-patches-82b0e27de109b38ed44f67434a96460c4a7f9217.tar.gz
lint: tests-true: Check if tests are enabled when cross-compiling.
* guix/lint.scm (check-tests-true): New linter. (%local-checkers)[tests-true]: Add it. * tests/lint.scm ("tests-true: #:tests? must not be set to #t") ("tests-true: absent #:tests? is acceptable") ("tests-true: #:tests? #f is acceptable") ("tests-true: #:tests? #t acceptable when compiling natively"): Test it. Signed-off-by: Mathieu Othacehe <othacehe@gnu.org>
Diffstat (limited to 'guix/lint.scm')
-rw-r--r--guix/lint.scm26
1 files changed, 26 insertions, 0 deletions
diff --git a/guix/lint.scm b/guix/lint.scm
index 41dd5d0633..5cd6db5842 100644
--- a/guix/lint.scm
+++ b/guix/lint.scm
@@ -12,6 +12,7 @@
;;; Copyright © 2020 Chris Marusich <cmmarusich@gmail.com>
;;; Copyright © 2020 Timothy Sample <samplet@ngyro.com>
;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -96,6 +97,7 @@
check-archival
check-profile-collisions
check-haskell-stackage
+ check-tests-true
lint-warning
lint-warning?
@@ -191,6 +193,26 @@
#:field 'name)))
(else '()))))
+(define (check-tests-true package)
+ "Check whether PACKAGE explicitly requests to run tests, which is
+superfluous when building natively and incorrect when cross-compiling."
+ (define (tests-explicitly-enabled?)
+ (apply (lambda* (#:key tests? #:allow-other-keys)
+ (eq? tests? #t))
+ (package-arguments package)))
+ (if (and (tests-explicitly-enabled?)
+ ;; Some packages, e.g. gnutls, set #:tests?
+ ;; differently depending on whether it is being
+ ;; cross-compiled.
+ (parameterize ((%current-target-system "aarch64-linux-gnu"))
+ (tests-explicitly-enabled?)))
+ (list (make-warning package
+ ;; TRANSLATORS: #:tests? and #t are Scheme constants
+ ;; and must not be translated.
+ (G_ "#:tests? must not be explicitly set to #t")
+ #:field 'arguments))
+ '()))
+
(define (properly-starts-sentence? s)
(string-match "^[(\"'`[:upper:][:digit:]]" s))
@@ -1525,6 +1547,10 @@ them for PACKAGE."
(description "Validate package names")
(check check-name))
(lint-checker
+ (name 'tests-true)
+ (description "Check if tests are explicitly enabled")
+ (check check-tests-true))
+ (lint-checker
(name 'description)
(description "Validate package descriptions")
(check check-description-style))