From patchwork Sun May 9 12:35:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: M X-Patchwork-Id: 29186 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 7184D27BC82; Sun, 9 May 2021 17:49:20 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,T_DKIM_INVALID,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id E68ED27BC81 for ; Sun, 9 May 2021 17:49:19 +0100 (BST) Received: from localhost ([::1]:46912 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lfmcH-0001np-W9 for patchwork@mira.cbaines.net; Sun, 09 May 2021 12:49:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58346) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lfmc3-0001nf-L8 for guix-patches@gnu.org; Sun, 09 May 2021 12:49:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:44704) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lfmc1-0003ig-To for guix-patches@gnu.org; Sun, 09 May 2021 12:49:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lfmc1-0003h2-Sv for guix-patches@gnu.org; Sun, 09 May 2021 12:49:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#48319] [PATCH] Check if #:tests? is unconditionally #t; not acceptable when cross-compiling Resent-From: Maxime Devos Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 09 May 2021 16:49:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 48319 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 48319@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.162057892214185 (code B ref -1); Sun, 09 May 2021 16:49:01 +0000 Received: (at submit) by debbugs.gnu.org; 9 May 2021 16:48:42 +0000 Received: from localhost ([127.0.0.1]:56249 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lfmbi-0003gj-4E for submit@debbugs.gnu.org; Sun, 09 May 2021 12:48:42 -0400 Received: from lists.gnu.org ([209.51.188.17]:48506) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lfmbf-0003gd-Hf for submit@debbugs.gnu.org; Sun, 09 May 2021 12:48:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58268) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lfmbf-0001kv-9O for guix-patches@gnu.org; Sun, 09 May 2021 12:48:39 -0400 Received: from xavier.telenet-ops.be ([2a02:1800:120:4::f00:14]:44790) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lfmbd-0003UO-Dq for guix-patches@gnu.org; Sun, 09 May 2021 12:48:39 -0400 Received: from butterfly.local ([213.251.116.230]) by xavier.telenet-ops.be with bizsmtp id 2goa2500D4yL7Jl01goa7i; Sun, 09 May 2021 18:48:35 +0200 Message-ID: From: Maxime Devos Date: Sun, 09 May 2021 14:35:57 +0200 MIME-Version: 1.0 User-Agent: Evolution 3.34.2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telenet.be; s=r21; t=1620578915; bh=wtLVbe9ynG1dzCGv+6GFldr0BqFAV97rn5dIT8ldyHo=; h=Subject:From:To:Date; b=AGn/MgN1ArqRW4F5tssNzyd480z6Tu2OngtuV1XJHFiNHpFTzW8mRJyJGF5a41z6b 5yC3+dQsCNLZfEDxQUQRIb+nAV4HAvfHKAFeHLY/3mPOW94lZ6BEyR2hO7YhCYAhTc FtLNEDmMSYx320kcZrEQa3To73mhEjWoEqsZ2M+11PVxel+TURGQwoiWbxvn0Hh7BC PkrYvWI6is+J+T936DdM7Nr0PKVu9ihRfJyiaufqekSgP5azjHBaAWbBs1D5DVjgDl rh9ihUwL1zHkdbo5loj+9uajCTXlf2m9HJWuPh6eILRzik9TagV+yowiEKaDETqR3y 0pHKIRB/NJ4og== Received-SPF: pass client-ip=2a02:1800:120:4::f00:14; envelope-from=maximedevos@telenet.be; helo=xavier.telenet-ops.be X-Spam_score_int: -11 X-Spam_score: -1.2 X-Spam_bar: - X-Spam_report: (-1.2 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_03_06=1.592, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches 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. From daf537fe6e99b308424cb89106d254efa9ff0781 Mon Sep 17 00:00:00 2001 From: Maxime Devos 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 ;;; Copyright © 2020 Timothy Sample ;;; Copyright © 2021 Xinglu Chen +;;; Copyright © 2021 Maxime Devos ;;; ;;; 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