From: Maxime Devos <maximedevos@telenet.be>
To: 48319@debbugs.gnu.org
Subject: [bug#48319] [PATCH] Check if #:tests? is unconditionally #t; not acceptable when cross-compiling
Date: Sun, 09 May 2021 14:35:57 +0200 [thread overview]
Message-ID: <ede44afaa1f52d80c0b6967524197fd0776b5ec2.camel@telenet.be> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 631 bytes --]
Hi guix,
This patch defines a linter detecting
(arguments `(#:tests? #t et cetera))
in package definitions. This is unlikely to work well when
cross-compiling (some exceptions apply, e.g. take a look
at the 'fennel' package). Also, it is simply unnecessary
when compiling natively.
Fortunately, I failed to find a package that fails to cross-compile
due to this particular reason. (They failed to cross-compile due to
other reasons, or the 'check' target did nothing.)
I didn't try all packages flagged by the new linter, though.
On top of 75af43162e58a0b3fdc804963809ecb801fb81b7.
Greetings,
Maxime.
[-- Attachment #1.2: 0001-lint-tests-true-Check-if-tests-are-enabled-when-cros.patch --]
[-- Type: text/x-patch, Size: 4225 bytes --]
From daf537fe6e99b308424cb89106d254efa9ff0781 Mon Sep 17 00:00:00 2001
From: Maxime Devos <maximedevos@telenet.be>
Date: Sun, 9 May 2021 14:08:12 +0200
Subject: [PATCH] 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? does not need to 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.
---
guix/lint.scm | 29 +++++++++++++++++++++++++++++
tests/lint.scm | 23 +++++++++++++++++++++++
2 files changed, 52 insertions(+)
diff --git a/guix/lint.scm b/guix/lint.scm
index 1bebfe03d3..d1cbc9d300 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.
;;;
@@ -95,6 +96,7 @@
check-archival
check-profile-collisions
check-haskell-stackage
+ check-tests-true
lint-warning
lint-warning?
@@ -190,6 +192,29 @@
#: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?)))
+ ;; Actually, #:tests? *should* not be (unconditionally) set to #t,
+ ;; but that wording would suggest that tests should be disabled,
+ ;; which is not the case.
+ (list (make-warning package
+ ;; TRANSLATORS: #:tests? and #t are Scheme constants
+ ;; and must not be translated.
+ (G_ "#:tests? does not need to be explicitly set to #t")
+ #:field 'arguments))
+ '()))
+
(define (properly-starts-sentence? s)
(string-match "^[(\"'`[:upper:][:digit:]]" s))
@@ -1481,6 +1506,10 @@ them for PACKAGE."
(name 'name)
(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")
diff --git a/tests/lint.scm b/tests/lint.scm
index a2c8665142..46830aad01 100644
--- a/tests/lint.scm
+++ b/tests/lint.scm
@@ -277,6 +277,29 @@
(let ((pkg (dummy-package "under_score")))
(check-name pkg))))
+(test-equal "tests-true: #:tests? does not need to be set to #t"
+ "#:tests? does not need to 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"
"'pkg-config' should probably be a native input"
(single-lint-warning-message
--
2.31.1
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]
next reply other threads:[~2021-05-09 16:49 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-09 12:35 Maxime Devos [this message]
2021-06-04 12:50 ` [bug#48319] [PATCH] Check if #:tests? is unconditionally #t; not acceptable when cross-compiling Mathieu Othacehe
2021-06-05 9:56 ` Maxime Devos
2021-06-06 16:51 ` bug#48319: " Mathieu Othacehe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ede44afaa1f52d80c0b6967524197fd0776b5ec2.camel@telenet.be \
--to=maximedevos@telenet.be \
--cc=48319@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).