From patchwork Fri May 19 12:13:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos O'Donell X-Patchwork-Id: 69684 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 344DF385702B for ; Fri, 19 May 2023 12:14:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 344DF385702B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1684498464; bh=gi5L6saSzdo66mZT90wD2OOp+YjQtyU0MFRWvBUbc60=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=vsZmwoJpnBUArmkD4O68DE62cHy24hGwU0Sjzidg329y1BQB69QHMKiwB6AQ7V2yL jyfWuF4BK6TfaDU7raP+8KTakwRCop8yRs7NjYgVOysfE41MSv5FdeDMx9vfWAT/cr AzH8DwgyxipDvaz2qJhMcHZ9l13JDo8iv/iIXJKc= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 4F5053858D28 for ; Fri, 19 May 2023 12:14:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4F5053858D28 Received: from mail-yw1-f199.google.com (mail-yw1-f199.google.com [209.85.128.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-427-ZxLIdNTYOaOGbofnl_dCTw-1; Fri, 19 May 2023 08:14:00 -0400 X-MC-Unique: ZxLIdNTYOaOGbofnl_dCTw-1 Received: by mail-yw1-f199.google.com with SMTP id 00721157ae682-561985d744fso16632027b3.1 for ; Fri, 19 May 2023 05:14:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684498439; x=1687090439; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gi5L6saSzdo66mZT90wD2OOp+YjQtyU0MFRWvBUbc60=; b=LHwdo8vNvtW/5lag42Mnsbyozxq2REacY9MKLaL1oeeyv8tui4P06VvSLQMt3jfbjk LqD3mQrZXCdZKf0b9JQDFJ0u02HRuznn/AjeDcrhSH/cfHEBxHjxutRYAGUIE2NJ9uBx xJARrqb3AWsv6x9cnvatbWNHWrta2A4pxPT1NGDNVc+gfu7yj7uyqnOLjJjcXSXDdjXN bscQJaAbbzvVoUfS+jnZkJ2pkyx1x2kFNX9Fc0jGg5v145eS09XVSfw5Ds0zDy+L2Ks/ MXuNJ8+tTlfZGjgrR/nMhr4tWAKDbPue7dH1oBbfh5FXV27Gx7YiiGgFpGqXnCF53K0p sLbg== X-Gm-Message-State: AC+VfDypJGJMH0EVTe1Q8bLZcxKtbHYnF6CbFluZBGImokzgOVFnsgej 6zZ0EfULTnP6uDc/gv+L55seU5RlzmCL1ZaSlhZRUOx40kLszvhNEKjzGzcyfrYppQmSGT9vIkr uXz1dLBqJdxPaEZDoypDDvWPpuCNh8fMtr+5n532x17/cdG11IcMNresP3sRAOMb7A8jCK8EA6R lHnQ== X-Received: by 2002:a81:994c:0:b0:552:ae41:50a2 with SMTP id q73-20020a81994c000000b00552ae4150a2mr1638524ywg.21.1684498439119; Fri, 19 May 2023 05:13:59 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4Ps1fSTlDahTmXOSt3M5BR21XnpiQqQ9GrWkeblXMW6/lICTLM8QG1LVe7+xXl+1hOuNJA3w== X-Received: by 2002:a81:994c:0:b0:552:ae41:50a2 with SMTP id q73-20020a81994c000000b00552ae4150a2mr1638494ywg.21.1684498438788; Fri, 19 May 2023 05:13:58 -0700 (PDT) Received: from DESKTOP-1DH6NSL.localdomain ([198.48.244.52]) by smtp.gmail.com with ESMTPSA id m129-20020a817187000000b0055a18d8479csm1110436ywc.21.2023.05.19.05.13.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 May 2023 05:13:58 -0700 (PDT) To: libc-alpha@sourceware.org, Noah Goldstein , Adhemerval Zanella , Florian Weimer Cc: Carlos O'Donell Subject: [PATCH 1/1] Add lint-makefiles Makefile linting test. Date: Fri, 19 May 2023 08:13:54 -0400 Message-Id: <20230519121354.704395-2-carlos@redhat.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230519121354.704395-1-carlos@redhat.com> References: <20230519121354.704395-1-carlos@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Carlos O'Donell via Libc-alpha From: Carlos O'Donell Reply-To: Carlos O'Donell Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" We add a `make check` test that lints all Makefiles in the source directory of the glibc build. This linting test ensures that the lines in all Makefiles will be sorted correctly as developers creates patches. The test adds ~3s to a test run. No regressions on x86_64 and i686. --- Makefile | 6 +++++ scripts/lint-makefiles.sh | 47 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 scripts/lint-makefiles.sh diff --git a/Makefile b/Makefile index 224c792185..93e5a60af9 100644 --- a/Makefile +++ b/Makefile @@ -564,6 +564,12 @@ $(objpfx)check-wrapper-headers.out: scripts/check-wrapper-headers.py $(headers) --generated $(common-generated) > $@; $(evaluate-test) endif # $(headers) +# Lint all Makefiles including this one to check for correctly sorted lines. +tests-special += $(objpfx)lint-makefiles.out +$(objpfx)lint-makefiles.out: scripts/lint-makefiles.sh + $(SHELL) $< "$(PYTHON)" "$(srcdir)" > $@ ; \ + $(evaluate-test) + define summarize-tests @grep -E -v '^(PASS|XFAIL):' $(objpfx)$1 || true @echo "Summary of test results$2:" diff --git a/scripts/lint-makefiles.sh b/scripts/lint-makefiles.sh new file mode 100644 index 0000000000..cf63a4ab9f --- /dev/null +++ b/scripts/lint-makefiles.sh @@ -0,0 +1,47 @@ +#!/bin/bash +# Copyright (C) 2023 Free Software Foundation, Inc. +# This file is part of the GNU C Library. + +# The GNU C Library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. + +# The GNU C Library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. + +# You should have received a copy of the GNU Lesser General Public +# License along with the GNU C Library; if not, see +# . + +# This script checks to see that all Makefiles in the source tree +# conform to the sorted variable rules as defined by: +# scripts/sort-makefile-lines.py. +# Any difference is an error and should be corrected e.g. the lines +# reordered to sort correctly. +# The intent with this check is to ensure that changes made by +# developers match the expected format for the project. + +set -e +export LC_ALL=C + +tmpfile="$(mktemp)" + +cleanup () { + rm -f -- "$tmpfile" +} + +trap cleanup 0 + +PYTHON=$1 +srcdir=$2 + +echo "Linting Makefiles:" +echo "Check: Are all lines sorted correctly?" +for mfile in `find "$srcdir" -name Makefile`; do + echo "$mfile" + $PYTHON "${srcdir}scripts/sort-makefile-lines.py" < "$mfile" > "$tmpfile" + diff -q "$mfile" "$tmpfile" +done