me
/
guix
Archived
1
0
Fork 0

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>
master
Maxime Devos 2021-05-09 14:35:57 +02:00 committed by Mathieu Othacehe
parent e2ad110f4c
commit 82b0e27de1
No known key found for this signature in database
GPG Key ID: 8354763531769CA6
2 changed files with 49 additions and 0 deletions

View File

@ -12,6 +12,7 @@
;;; Copyright © 2020 Chris Marusich <cmmarusich@gmail.com> ;;; Copyright © 2020 Chris Marusich <cmmarusich@gmail.com>
;;; Copyright © 2020 Timothy Sample <samplet@ngyro.com> ;;; Copyright © 2020 Timothy Sample <samplet@ngyro.com>
;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz> ;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -96,6 +97,7 @@
check-archival check-archival
check-profile-collisions check-profile-collisions
check-haskell-stackage check-haskell-stackage
check-tests-true
lint-warning lint-warning
lint-warning? lint-warning?
@ -191,6 +193,26 @@
#:field 'name))) #:field 'name)))
(else '())))) (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) (define (properly-starts-sentence? s)
(string-match "^[(\"'`[:upper:][:digit:]]" s)) (string-match "^[(\"'`[:upper:][:digit:]]" s))
@ -1524,6 +1546,10 @@ them for PACKAGE."
(name 'name) (name 'name)
(description "Validate package names") (description "Validate package names")
(check check-name)) (check check-name))
(lint-checker
(name 'tests-true)
(description "Check if tests are explicitly enabled")
(check check-tests-true))
(lint-checker (lint-checker
(name 'description) (name 'description)
(description "Validate package descriptions") (description "Validate package descriptions")

View File

@ -277,6 +277,29 @@
(let ((pkg (dummy-package "under_score"))) (let ((pkg (dummy-package "under_score")))
(check-name pkg)))) (check-name pkg))))
(test-equal "tests-true: #:tests? must not be set to #t"
"#:tests? must not be explicitly set to #t"
(single-lint-warning-message
(let ((pkg (dummy-package "x" (arguments '(#:tests? #t)))))
(check-tests-true pkg))))
(test-equal "tests-true: absent #:tests? is acceptable"
'()
(let ((pkg (dummy-package "x")))
(check-tests-true pkg)))
(test-equal "tests-true: #:tests? #f is acceptable"
'()
(let ((pkg (dummy-package "x" (arguments '(#:tests? #f)))))
(check-tests-true pkg)))
(test-equal "tests-true: #:tests? #t acceptable when compiling natively"
'()
(let ((pkg (dummy-package "x"
(arguments
`(#:tests? ,(not (%current-target-system)))))))
(check-tests-true pkg)))
(test-equal "inputs: pkg-config is probably a native input" (test-equal "inputs: pkg-config is probably a native input"
"'pkg-config' should probably be a native input" "'pkg-config' should probably be a native input"
(single-lint-warning-message (single-lint-warning-message