From patchwork Sun Jul 24 23:52:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Martincoski X-Patchwork-Id: 1660146 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=buildroot.org (client-ip=140.211.166.136; helo=smtp3.osuosl.org; envelope-from=buildroot-bounces@buildroot.org; receiver=) Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Lrg4805ryz9sGx for ; Mon, 25 Jul 2022 09:53:43 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id DD277611EA; Sun, 24 Jul 2022 23:53:41 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org DD277611EA X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id T7BARaBAUhjZ; Sun, 24 Jul 2022 23:53:41 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp3.osuosl.org (Postfix) with ESMTP id D028C60773; Sun, 24 Jul 2022 23:53:39 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org D028C60773 X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id 317121BF31C for ; Sun, 24 Jul 2022 23:53:38 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 17601416EE for ; Sun, 24 Jul 2022 23:53:38 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 17601416EE X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id PiU3Su0G40T7 for ; Sun, 24 Jul 2022 23:53:37 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org D9EC1416EA Received: from mail-oi1-x22f.google.com (mail-oi1-x22f.google.com [IPv6:2607:f8b0:4864:20::22f]) by smtp4.osuosl.org (Postfix) with ESMTPS id D9EC1416EA for ; Sun, 24 Jul 2022 23:53:36 +0000 (UTC) Received: by mail-oi1-x22f.google.com with SMTP id bb16so11709383oib.11 for ; Sun, 24 Jul 2022 16:53:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc; bh=JNJeNG3JJIF6Nnr6kqAGhMSWFs95Roxg+d1Et9+pmFY=; b=sz5ZgVVZiYscnxYo9P0q5+HmhF7xZiRmQhefjIpGuztUJr8reK7WGZ11L3SapnvqPx hNqpJx64vlFZZ3nMhTrkcN3xiGZUictRLgT+A/HgbAcviAP2750+pIYZPD3Ro5jh3uXg 5hW/pnIghSnOKg9cY6YQS8ziQDgN47oISpsC4AfpjFrsUq7lI8N1MeDKiLO+KIZe4PT8 lgi4qEpuQFGX96UNfzjxYjcVmOf5Rvm2DiOTmak6BFYAY/b0yTgAm9xMb4iRDYwHjrfn +FqIPXZILr55Pym+ZAGGwlndX5KjcR6a7EAiuY8fXkop1GLNfwgCCJoQ6Nc8HvSY8c6G dHug== X-Gm-Message-State: AJIora/Y7se/CYMQ3qa89h68kPLaop+PXe17xtgwe0zv/4otQs7cxix7 TyvJP6BhGZFDeRmM6o7vi0JYJm2y9ok= X-Google-Smtp-Source: AGRyM1uBGj6dM38T3KZeQ+PBxAA1bcyB9B1QDSaNF6nBoGumSOOqXPnqJQ944sz1DZ/BJjKpeZCf0w== X-Received: by 2002:aca:5e55:0:b0:33a:e055:38e with SMTP id s82-20020aca5e55000000b0033ae055038emr1263240oib.186.1658706814408; Sun, 24 Jul 2022 16:53:34 -0700 (PDT) Received: from localhost.localdomain ([191.187.223.18]) by smtp.gmail.com with ESMTPSA id k23-20020a4ad117000000b004359b581401sm4283268oor.25.2022.07.24.16.53.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Jul 2022 16:53:33 -0700 (PDT) From: Ricardo Martincoski To: buildroot@buildroot.org Date: Sun, 24 Jul 2022 20:52:59 -0300 Message-Id: <20220724235301.3708271-1-ricardo.martincoski@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc; bh=JNJeNG3JJIF6Nnr6kqAGhMSWFs95Roxg+d1Et9+pmFY=; b=AaD/IJqZuXyMPl8SQV3UCQPP2KCLQJwoLEplTR5tCWkH92g2oFLwKqPiEqY3k0hGqD GOh/lg3r7cr11FVF572acPDfjLd06VOX33k7xEE0v95J8uJdWWy7pELVr9Va72C2SGOD ZS6EC6J1lNAh5WP1E/Pl2m2LjTi3dsFB8u7jlyuIprubEQ+0GjP+yNgMoThSYK1YbIpn u7kj661x+pHjsK+xLADC7G2QhVlEAqgKQaNAQTeu5m2stL3Rb51iVGs4bLF0BH8qT7jH 1+A6M3Rv8RAYnQKvZRn7ylMN5K5nvEYvrhwecauAiO1xpT9WLrYpf5ewXdpxyC9VrtUG 5JBw== X-Mailman-Original-Authentication-Results: smtp4.osuosl.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=AaD/IJqZ Subject: [Buildroot] [PATCH 1/3] support/testing/tests: improve get-developers test X-BeenThere: buildroot@buildroot.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ricardo Martincoski Errors-To: buildroot-bounces@buildroot.org Sender: "buildroot" Change the test into a characterization test for all warnings and errors get-developers can return when parsing the DEVELOPERS files. It will be helpful when changing the behavior of get-developers to bail out on all syntax checking warnings. Signed-off-by: Ricardo Martincoski --- .../tests/utils/test_get_developers.py | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/support/testing/tests/utils/test_get_developers.py b/support/testing/tests/utils/test_get_developers.py index e4420bc6dc..12710fe8d3 100644 --- a/support/testing/tests/utils/test_get_developers.py +++ b/support/testing/tests/utils/test_get_developers.py @@ -47,31 +47,98 @@ class TestGetDevelopers(unittest.TestCase): # -v generating error, called from the main dir developers = b'text1\n' out, err, rc = call_get_developers("./utils/get-developers", ["-v"], self.WITH_EMPTY_PATH, topdir, developers) self.assertIn("Syntax error in DEVELOPERS file, line 0: 'text1'", err) self.assertEqual(rc, 1) self.assertEqual(len(out), 0) + self.assertEqual(len(err), 1) # -v generating error, called from path developers = b'text2\n' out, err, rc = call_get_developers("get-developers", ["-v"], self.WITH_UTILS_IN_PATH, topdir, developers) self.assertIn("Syntax error in DEVELOPERS file, line 0: 'text2'", err) self.assertEqual(rc, 1) self.assertEqual(len(out), 0) + self.assertEqual(len(err), 1) + + # -v generating error for file entry with no developer entry + developers = b'# comment\n' \ + b'\n' \ + b'F:\tutils/get-developers\n' \ + b'\n' \ + b'N:\tAuthor2 \n' \ + b'F:\tutils/get-developers\n' + out, err, rc = call_get_developers("get-developers", ["-v"], self.WITH_UTILS_IN_PATH, topdir, developers) + self.assertIn("Syntax error in DEVELOPERS file, line 1", err) + self.assertEqual(rc, 0) + self.assertEqual(len(out), 0) + self.assertEqual(len(err), 1) + + # -v generating error for developer entry with no file entries + developers = b'# comment\n' \ + b'# comment\n' \ + b'\n' \ + b'N:\tAuthor1 \n' \ + b'N:\tAuthor2 \n' \ + b'N:\tAuthor3 \n' \ + b'F:\tutils/get-developers\n' + out, err, rc = call_get_developers("get-developers", ["-v"], self.WITH_UTILS_IN_PATH, topdir, developers) + self.assertIn("Syntax error in DEVELOPERS file, line 1", err) + self.assertIn("Syntax error in DEVELOPERS file, line 2", err) + self.assertEqual(rc, 0) + self.assertEqual(len(out), 0) + self.assertEqual(len(err), 2) + + # -v not generating error for developer entry with empty list of file entries + developers = b'# comment\n' \ + b'# comment\n' \ + b'\n' \ + b'N:\tAuthor1 \n' \ + b'\n' \ + b'N:\tAuthor2 \n' \ + b'\n' \ + b'N:\tAuthor3 \n' \ + b'F:\tutils/get-developers\n' + out, err, rc = call_get_developers("get-developers", ["-v"], self.WITH_UTILS_IN_PATH, topdir, developers) + self.assertEqual(rc, 0) + self.assertEqual(len(out), 0) + self.assertEqual(len(err), 0) + + # -v generating warning for old file entry + developers = b'N:\tAuthor \n' \ + b'F:\tpath/that/does/not/exists/1\n' \ + b'F:\tpath/that/does/not/exists/2\n' + out, err, rc = call_get_developers("get-developers", ["-v"], self.WITH_UTILS_IN_PATH, topdir, developers) + self.assertIn("WARNING: 'path/that/does/not/exists/1' doesn't match any file", err) + self.assertIn("WARNING: 'path/that/does/not/exists/2' doesn't match any file", err) + self.assertEqual(rc, 0) + self.assertEqual(len(out), 0) + self.assertEqual(len(err), 2) # -c generating warning and printing lots of files with no developer developers = b'N:\tAuthor \n' \ b'F:\tpath/that/does/not/exists/1\n' \ b'F:\tpath/that/does/not/exists/2\n' out, err, rc = call_get_developers("./utils/get-developers", ["-c"], self.WITH_EMPTY_PATH, topdir, developers) self.assertIn("WARNING: 'path/that/does/not/exists/1' doesn't match any file", err) self.assertIn("WARNING: 'path/that/does/not/exists/2' doesn't match any file", err) self.assertEqual(rc, 0) self.assertGreater(len(out), 1000) + self.assertEqual(len(err), 2) + + # -c printing lots of files with no developer + developers = b'# comment\n' \ + b'\n' \ + b'N:\tAuthor \n' \ + b'F:\tutils/get-developers\n' + out, err, rc = call_get_developers("./utils/get-developers", ["-c"], self.WITH_EMPTY_PATH, topdir, developers) + self.assertEqual(rc, 0) + self.assertGreater(len(out), 1000) + self.assertEqual(len(err), 0) # -p lists more than one developer developers = b'N:\tdev1\n' \ b'F:\ttoolchain/\n' \ b'\n' \ b'N:\tdev2\n' \ b'F:\ttoolchain/\n' From patchwork Sun Jul 24 23:53:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Martincoski X-Patchwork-Id: 1660147 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=buildroot.org (client-ip=140.211.166.138; helo=smtp1.osuosl.org; envelope-from=buildroot-bounces@buildroot.org; receiver=) Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Lrg4P0mTWz9sGx for ; Mon, 25 Jul 2022 09:53:57 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 45D9C8315C; Sun, 24 Jul 2022 23:53:55 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 45D9C8315C X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id F-3sHe8sZKdZ; Sun, 24 Jul 2022 23:53:54 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp1.osuosl.org (Postfix) with ESMTP id 19281830C1; Sun, 24 Jul 2022 23:53:53 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 19281830C1 X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id C72121BF31C for ; Sun, 24 Jul 2022 23:53:39 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id ADBDF416F2 for ; Sun, 24 Jul 2022 23:53:39 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org ADBDF416F2 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id An4tEBi0HKbG for ; Sun, 24 Jul 2022 23:53:38 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 52326416EE Received: from mail-oo1-xc2e.google.com (mail-oo1-xc2e.google.com [IPv6:2607:f8b0:4864:20::c2e]) by smtp4.osuosl.org (Postfix) with ESMTPS id 52326416EE for ; Sun, 24 Jul 2022 23:53:38 +0000 (UTC) Received: by mail-oo1-xc2e.google.com with SMTP id r193-20020a4a37ca000000b0043578138958so1892449oor.4 for ; Sun, 24 Jul 2022 16:53:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=/nii/ZCoJr1PY0DBtUpvOsH52LRegYOkQB/s7AsOiBo=; b=bm+tRPEbSeq1llkWALzxxeaXdei18zfq3kBWZ6p/l4ZQ7wPQwp0/51dr14VD4tBS3W 85iSUFHPLXbwB3C7/MRSXYuQ/pvooixz+jawhRzH5zDJ5vrfPk2+1TDooAjIVgMi+clb zSNPb82BJicYuFRfvKh6JZZpiw7fwWvWVNdu5nkC5N+p/jqZTgET3GQLMCh2NZOSwBRC lh2W5DXtV8O+2lvknc1hF4m2tEiTi0XAH4oOGduxsPWCWW62JVr36/90nqS4W0IQ1kJd d2r2EIoeCSfCovVEq/QNjOjI41woVduia6V0IIOx4R2HYQ3rYqjsdKD41HIIFPhNOlS5 AR2w== X-Gm-Message-State: AJIora/rvZLBjdbhcQVcdMFauvfVKVlAe9jNhBeLgLPcRpH5pq+kPnl+ NPZDQBHWfpMCvVVxEpWa/WmnH5LxWaE= X-Google-Smtp-Source: AGRyM1uzhPQ3lKmewZhBKfVTgzvNUic7BZahCaMFV+UB48s6dWYafBOAoR5RqnQbh4PEu/qC3hoM/Q== X-Received: by 2002:a4a:49d2:0:b0:435:9edb:9e8 with SMTP id z201-20020a4a49d2000000b004359edb09e8mr3389950ooa.62.1658706817247; Sun, 24 Jul 2022 16:53:37 -0700 (PDT) Received: from localhost.localdomain ([191.187.223.18]) by smtp.gmail.com with ESMTPSA id k23-20020a4ad117000000b004359b581401sm4283268oor.25.2022.07.24.16.53.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Jul 2022 16:53:36 -0700 (PDT) From: Ricardo Martincoski To: buildroot@buildroot.org Date: Sun, 24 Jul 2022 20:53:00 -0300 Message-Id: <20220724235301.3708271-2-ricardo.martincoski@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220724235301.3708271-1-ricardo.martincoski@gmail.com> References: <20220724235301.3708271-1-ricardo.martincoski@gmail.com> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=/nii/ZCoJr1PY0DBtUpvOsH52LRegYOkQB/s7AsOiBo=; b=P9emWSH8uKojZBag/HFpQCCzJ3zHA6Re6hb0mvegrtNtdXLh6OI3f4iDhF+vYD4Ikr QnehjLcO9AHS/wwlOMZdoMIzAVKsWtyg5u3U/SlJqqW1zyk0d0T/kmPgOg12EcJbaLxd z4Z1ac35oDQwz68HX8a09PVxLQ0cNB5wyKvUaSyRAbkAa95oVcIJGIO5QQVJoX2Mu88M 3xTcpWNMCzCOydhihZg/h6k4c+9e2Cq9bUqXcTBgfl2QbdGKqW0AJLib2GsqqZ/Bw6Wv xMFEzNfsWBiLW0nwqOQBXDf63z6hxG8yLSzYDMhVnOPkyLDQPl0NPHPsMp0Brf+LUZUo uKPw== X-Mailman-Original-Authentication-Results: smtp4.osuosl.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=P9emWSH8 Subject: [Buildroot] [PATCH 2/3] utils/get-developers: bail out on parsing errors X-BeenThere: buildroot@buildroot.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Petazzoni , Ricardo Martincoski Errors-To: buildroot-bounces@buildroot.org Sender: "buildroot" Currently 4 types of parsing errors can be found: - developer entry with no file entry (error) - file entry with no developer (error) - entry for file that are not in the tree anymore (warning) - entry that is not a developer, a file or a comment (hard error) Currently only the last one ends the script with -v with error code. Make the warning an error. Suggested-by: Arnout Vandecappelle Make all errors into hard errors. Suggested-by: Thomas Petazzoni At same time standardize the error message, printing the line number that contains the error. Do not bail out in the first error found but instead print all errors found, in order to help the developer fixing the DEVELOPERS file. Signed-off-by: Ricardo Martincoski --- Cc: Arnout Vandecappelle Cc: Thomas Petazzoni NOTICE that when DEVELOPERS file has errors, pkg-stats will fail (with a DEVELOPERS file *modified* to have an error): Build package list ... Getting developers ... Syntax error in DEVELOPERS file, line 2: 'old_file' doesn't match any file Build defconfig list ... Traceback (most recent call last): File "support/scripts/pkg-stats", line 1289, in __main__() File "support/scripts/pkg-stats", line 1249, in __main__ d.set_developers(developers) File "support/scripts/pkg-stats", line 60, in set_developers self.developers = [ TypeError: 'NoneType' object is not iterable --- .../tests/utils/test_get_developers.py | 22 +++++++++---------- utils/getdeveloperlib.py | 7 +++++- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/support/testing/tests/utils/test_get_developers.py b/support/testing/tests/utils/test_get_developers.py index 12710fe8d3..d0c8e4d028 100644 --- a/support/testing/tests/utils/test_get_developers.py +++ b/support/testing/tests/utils/test_get_developers.py @@ -66,30 +66,30 @@ class TestGetDevelopers(unittest.TestCase): b'\n' \ b'F:\tutils/get-developers\n' \ b'\n' \ b'N:\tAuthor2 \n' \ b'F:\tutils/get-developers\n' out, err, rc = call_get_developers("get-developers", ["-v"], self.WITH_UTILS_IN_PATH, topdir, developers) self.assertIn("Syntax error in DEVELOPERS file, line 1", err) - self.assertEqual(rc, 0) + self.assertEqual(rc, 1) self.assertEqual(len(out), 0) self.assertEqual(len(err), 1) # -v generating error for developer entry with no file entries developers = b'# comment\n' \ b'# comment\n' \ b'\n' \ b'N:\tAuthor1 \n' \ b'N:\tAuthor2 \n' \ b'N:\tAuthor3 \n' \ b'F:\tutils/get-developers\n' out, err, rc = call_get_developers("get-developers", ["-v"], self.WITH_UTILS_IN_PATH, topdir, developers) self.assertIn("Syntax error in DEVELOPERS file, line 1", err) self.assertIn("Syntax error in DEVELOPERS file, line 2", err) - self.assertEqual(rc, 0) + self.assertEqual(rc, 1) self.assertEqual(len(out), 0) self.assertEqual(len(err), 2) # -v not generating error for developer entry with empty list of file entries developers = b'# comment\n' \ b'# comment\n' \ b'\n' \ @@ -100,34 +100,34 @@ class TestGetDevelopers(unittest.TestCase): b'N:\tAuthor3 \n' \ b'F:\tutils/get-developers\n' out, err, rc = call_get_developers("get-developers", ["-v"], self.WITH_UTILS_IN_PATH, topdir, developers) self.assertEqual(rc, 0) self.assertEqual(len(out), 0) self.assertEqual(len(err), 0) - # -v generating warning for old file entry + # -v generating error for old file entry developers = b'N:\tAuthor \n' \ b'F:\tpath/that/does/not/exists/1\n' \ b'F:\tpath/that/does/not/exists/2\n' out, err, rc = call_get_developers("get-developers", ["-v"], self.WITH_UTILS_IN_PATH, topdir, developers) - self.assertIn("WARNING: 'path/that/does/not/exists/1' doesn't match any file", err) - self.assertIn("WARNING: 'path/that/does/not/exists/2' doesn't match any file", err) - self.assertEqual(rc, 0) + self.assertIn("Syntax error in DEVELOPERS file, line 1: 'path/that/does/not/exists/1' doesn't match any file", err) + self.assertIn("Syntax error in DEVELOPERS file, line 2: 'path/that/does/not/exists/2' doesn't match any file", err) + self.assertEqual(rc, 1) self.assertEqual(len(out), 0) self.assertEqual(len(err), 2) - # -c generating warning and printing lots of files with no developer + # -c generating error for old file entry developers = b'N:\tAuthor \n' \ b'F:\tpath/that/does/not/exists/1\n' \ b'F:\tpath/that/does/not/exists/2\n' out, err, rc = call_get_developers("./utils/get-developers", ["-c"], self.WITH_EMPTY_PATH, topdir, developers) - self.assertIn("WARNING: 'path/that/does/not/exists/1' doesn't match any file", err) - self.assertIn("WARNING: 'path/that/does/not/exists/2' doesn't match any file", err) - self.assertEqual(rc, 0) - self.assertGreater(len(out), 1000) + self.assertIn("Syntax error in DEVELOPERS file, line 1: 'path/that/does/not/exists/1' doesn't match any file", err) + self.assertIn("Syntax error in DEVELOPERS file, line 2: 'path/that/does/not/exists/2' doesn't match any file", err) + self.assertEqual(rc, 1) + self.assertEqual(len(out), 0) self.assertEqual(len(err), 2) # -c printing lots of files with no developer developers = b'# comment\n' \ b'\n' \ b'N:\tAuthor \n' \ b'F:\tutils/get-developers\n' diff --git a/utils/getdeveloperlib.py b/utils/getdeveloperlib.py index 2a8d5c213c..f9f84ee8e1 100644 --- a/utils/getdeveloperlib.py +++ b/utils/getdeveloperlib.py @@ -225,34 +225,37 @@ def parse_developer_runtime_tests(fnames): return runtimes def parse_developers(filename=None): """Parse the DEVELOPERS file and return a list of Developer objects.""" developers = [] linen = 0 + errors = 0 global unittests unittests = list_unittests() developers_fname = filename or os.path.join(brpath, 'DEVELOPERS') with open(developers_fname, mode='r', encoding='utf_8') as f: files = [] name = None for line in f: line = line.strip() if line.startswith("#"): continue elif line.startswith("N:"): if name is not None or len(files) != 0: + errors += 1 print("Syntax error in DEVELOPERS file, line %d" % linen, file=sys.stderr) name = line[2:].strip() elif line.startswith("F:"): fname = line[2:].strip() dev_files = glob.glob(os.path.join(brpath, fname)) if len(dev_files) == 0: - print("WARNING: '%s' doesn't match any file" % fname, + errors += 1 + print("Syntax error in DEVELOPERS file, line %d: '%s' doesn't match any file" % (linen, fname), file=sys.stderr) for f in dev_files: dev_file = os.path.relpath(f, brpath) dev_file = dev_file.replace(os.sep, '/') # force unix sep if f[-1] == '/': # relpath removes the trailing / dev_file = dev_file + '/' files.append(dev_file) @@ -266,14 +269,16 @@ def parse_developers(filename=None): print("Syntax error in DEVELOPERS file, line %d: '%s'" % (linen, line), file=sys.stderr) return None linen += 1 # handle last developer if name is not None: developers.append(Developer(name, files)) + if errors > 0: + return None return developers def check_developers(developers, basepath=None): """Look at the list of files versioned in Buildroot, and returns the list of files that are not handled by any developer""" if basepath is None: From patchwork Sun Jul 24 23:53:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Martincoski X-Patchwork-Id: 1660148 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=buildroot.org (client-ip=2605:bc80:3010::138; helo=smtp1.osuosl.org; envelope-from=buildroot-bounces@buildroot.org; receiver=) Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Lrg4f5J0Wz9sGx for ; Mon, 25 Jul 2022 09:54:10 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id BF55183F25; Sun, 24 Jul 2022 23:54:08 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org BF55183F25 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id D9fhZcagOAkt; Sun, 24 Jul 2022 23:54:07 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp1.osuosl.org (Postfix) with ESMTP id 81AC783E93; Sun, 24 Jul 2022 23:54:06 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 81AC783E93 X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 0B3951BF31C for ; Sun, 24 Jul 2022 23:53:42 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id D85C5611E4 for ; Sun, 24 Jul 2022 23:53:41 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org D85C5611E4 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2ZaC0ND9uezs for ; Sun, 24 Jul 2022 23:53:41 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org E06BB60767 Received: from mail-ot1-x32a.google.com (mail-ot1-x32a.google.com [IPv6:2607:f8b0:4864:20::32a]) by smtp3.osuosl.org (Postfix) with ESMTPS id E06BB60767 for ; Sun, 24 Jul 2022 23:53:40 +0000 (UTC) Received: by mail-ot1-x32a.google.com with SMTP id y10-20020a9d634a000000b006167f7ce0c5so7610888otk.0 for ; Sun, 24 Jul 2022 16:53:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=mcRdom1IG3X+AjPXBhADIsBN3vAjJ2BA4PGqd+gXknU=; b=2hhQgdF312tIJK7YR/wA7wQsHUK31zRBDchOYTfCG2LSccmTUvacjvBrXNeXrmMlb9 UXbQQY12hqX++WJB4EuUIUlcipW1XdkMrGXpuEKy32wGZQKcWRNrL6sj/wzIwi5ee2Er PKGVrMsGcJTDynaY4ICCZyp6/CkASj52q83Hnb4Nw8TM/KRMTFRiKJTFcx+Qbh9w+pn7 Nz8jiQBrW2XEpUdB7GLomvPMhDGgmdXcP62q45ydeyTZzDtQmBUdwINm/pbHRWpdriv3 1MrCnryIwPZicOdTVsB0m1HDYlILSpAKqsoeOtryUC+rDCdaQPBKVukz0icKefTb7Dzs YmbQ== X-Gm-Message-State: AJIora9jK8pGReauz+wSRDOa5YAJgQdKv3MObGY3YgDy4e75hR3n+soM wipRpva+KIgUGrn/GIHubG7qFe6lqCA= X-Google-Smtp-Source: AGRyM1srVun1tW8e3Vo2Ym9SWsw2CJjb2xrWmKzymw9o/wemgvm8tMXndO9vZp1lhSE3Sdck98wLvQ== X-Received: by 2002:a9d:6ace:0:b0:61c:8270:a04a with SMTP id m14-20020a9d6ace000000b0061c8270a04amr3839403otq.134.1658706819916; Sun, 24 Jul 2022 16:53:39 -0700 (PDT) Received: from localhost.localdomain ([191.187.223.18]) by smtp.gmail.com with ESMTPSA id k23-20020a4ad117000000b004359b581401sm4283268oor.25.2022.07.24.16.53.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Jul 2022 16:53:38 -0700 (PDT) From: Ricardo Martincoski To: buildroot@buildroot.org Date: Sun, 24 Jul 2022 20:53:01 -0300 Message-Id: <20220724235301.3708271-3-ricardo.martincoski@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220724235301.3708271-1-ricardo.martincoski@gmail.com> References: <20220724235301.3708271-1-ricardo.martincoski@gmail.com> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=mcRdom1IG3X+AjPXBhADIsBN3vAjJ2BA4PGqd+gXknU=; b=iTdEWJybqqenZERxpDOszY/HscpbIIFTJMeADOjqmOu6pFO3dVSby/hFprE0iEWNpJ iYz7ibdxL3cjxQAxcHEjq5FJRqspDX6PnUQqY6BDiHaHH0N96xSxxwldu0FY3mtIPPLu o2JIj9uB7v+ljSLwJEAxgstldyyR079HmTFYiytfyEsATBlUVNF7NxKp3BxDiBcKIa66 baOqqmG5ev/ywMvuSZG4RHuBAU0XEPMNv8E6WlJu/acUuCOgtcfIFpnoeCGkbZ98kCJd adCQmuzty0CvyXPCJeMQK4LJGD8PL7zY7EndNXjohaF5FXlKGFikLkLuB+ih+vdjNP77 miWw== X-Mailman-Original-Authentication-Results: smtp3.osuosl.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=iTdEWJyb Subject: [Buildroot] [PATCH 3/3] utils/get-developers: print error for correct line X-BeenThere: buildroot@buildroot.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ricardo Martincoski Errors-To: buildroot-bounces@buildroot.org Sender: "buildroot" Start counting the line numbers in 1 instead of 0, in case an error must be printed. Both the error about a developer entry with no file entry and the error about a file entry with no developer entry actually belong to the non-empty line previous the one being analysed, so add a hint to the error message. Also count empty and comment lines, so a developer fixing the file can jump to the correct line (or the nearest one). Signed-off-by: Ricardo Martincoski --- .../testing/tests/utils/test_get_developers.py | 18 +++++++++--------- utils/getdeveloperlib.py | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/support/testing/tests/utils/test_get_developers.py b/support/testing/tests/utils/test_get_developers.py index d0c8e4d028..df216d3b02 100644 --- a/support/testing/tests/utils/test_get_developers.py +++ b/support/testing/tests/utils/test_get_developers.py @@ -44,51 +44,51 @@ class TestGetDevelopers(unittest.TestCase): self.assertIn("No action specified", out) self.assertEqual(rc, 0) self.assertEqual(len(err), 0) # -v generating error, called from the main dir developers = b'text1\n' out, err, rc = call_get_developers("./utils/get-developers", ["-v"], self.WITH_EMPTY_PATH, topdir, developers) - self.assertIn("Syntax error in DEVELOPERS file, line 0: 'text1'", err) + self.assertIn("Syntax error in DEVELOPERS file, line 1: 'text1'", err) self.assertEqual(rc, 1) self.assertEqual(len(out), 0) self.assertEqual(len(err), 1) # -v generating error, called from path developers = b'text2\n' out, err, rc = call_get_developers("get-developers", ["-v"], self.WITH_UTILS_IN_PATH, topdir, developers) - self.assertIn("Syntax error in DEVELOPERS file, line 0: 'text2'", err) + self.assertIn("Syntax error in DEVELOPERS file, line 1: 'text2'", err) self.assertEqual(rc, 1) self.assertEqual(len(out), 0) self.assertEqual(len(err), 1) # -v generating error for file entry with no developer entry developers = b'# comment\n' \ b'\n' \ b'F:\tutils/get-developers\n' \ b'\n' \ b'N:\tAuthor2 \n' \ b'F:\tutils/get-developers\n' out, err, rc = call_get_developers("get-developers", ["-v"], self.WITH_UTILS_IN_PATH, topdir, developers) - self.assertIn("Syntax error in DEVELOPERS file, line 1", err) + self.assertIn("Syntax error in DEVELOPERS file, just before line 5", err) self.assertEqual(rc, 1) self.assertEqual(len(out), 0) self.assertEqual(len(err), 1) # -v generating error for developer entry with no file entries developers = b'# comment\n' \ b'# comment\n' \ b'\n' \ b'N:\tAuthor1 \n' \ b'N:\tAuthor2 \n' \ b'N:\tAuthor3 \n' \ b'F:\tutils/get-developers\n' out, err, rc = call_get_developers("get-developers", ["-v"], self.WITH_UTILS_IN_PATH, topdir, developers) - self.assertIn("Syntax error in DEVELOPERS file, line 1", err) - self.assertIn("Syntax error in DEVELOPERS file, line 2", err) + self.assertIn("Syntax error in DEVELOPERS file, just before line 5", err) + self.assertIn("Syntax error in DEVELOPERS file, just before line 6", err) self.assertEqual(rc, 1) self.assertEqual(len(out), 0) self.assertEqual(len(err), 2) # -v not generating error for developer entry with empty list of file entries developers = b'# comment\n' \ b'# comment\n' \ @@ -105,27 +105,27 @@ class TestGetDevelopers(unittest.TestCase): self.assertEqual(len(err), 0) # -v generating error for old file entry developers = b'N:\tAuthor \n' \ b'F:\tpath/that/does/not/exists/1\n' \ b'F:\tpath/that/does/not/exists/2\n' out, err, rc = call_get_developers("get-developers", ["-v"], self.WITH_UTILS_IN_PATH, topdir, developers) - self.assertIn("Syntax error in DEVELOPERS file, line 1: 'path/that/does/not/exists/1' doesn't match any file", err) - self.assertIn("Syntax error in DEVELOPERS file, line 2: 'path/that/does/not/exists/2' doesn't match any file", err) + self.assertIn("Syntax error in DEVELOPERS file, line 2: 'path/that/does/not/exists/1' doesn't match any file", err) + self.assertIn("Syntax error in DEVELOPERS file, line 3: 'path/that/does/not/exists/2' doesn't match any file", err) self.assertEqual(rc, 1) self.assertEqual(len(out), 0) self.assertEqual(len(err), 2) # -c generating error for old file entry developers = b'N:\tAuthor \n' \ b'F:\tpath/that/does/not/exists/1\n' \ b'F:\tpath/that/does/not/exists/2\n' out, err, rc = call_get_developers("./utils/get-developers", ["-c"], self.WITH_EMPTY_PATH, topdir, developers) - self.assertIn("Syntax error in DEVELOPERS file, line 1: 'path/that/does/not/exists/1' doesn't match any file", err) - self.assertIn("Syntax error in DEVELOPERS file, line 2: 'path/that/does/not/exists/2' doesn't match any file", err) + self.assertIn("Syntax error in DEVELOPERS file, line 2: 'path/that/does/not/exists/1' doesn't match any file", err) + self.assertIn("Syntax error in DEVELOPERS file, line 3: 'path/that/does/not/exists/2' doesn't match any file", err) self.assertEqual(rc, 1) self.assertEqual(len(out), 0) self.assertEqual(len(err), 2) # -c printing lots of files with no developer developers = b'# comment\n' \ b'\n' \ diff --git a/utils/getdeveloperlib.py b/utils/getdeveloperlib.py index f9f84ee8e1..3383df3c9e 100644 --- a/utils/getdeveloperlib.py +++ b/utils/getdeveloperlib.py @@ -233,21 +233,22 @@ def parse_developers(filename=None): global unittests unittests = list_unittests() developers_fname = filename or os.path.join(brpath, 'DEVELOPERS') with open(developers_fname, mode='r', encoding='utf_8') as f: files = [] name = None for line in f: + linen += 1 line = line.strip() if line.startswith("#"): continue elif line.startswith("N:"): if name is not None or len(files) != 0: errors += 1 - print("Syntax error in DEVELOPERS file, line %d" % linen, + print("Syntax error in DEVELOPERS file, just before line %d" % linen, file=sys.stderr) name = line[2:].strip() elif line.startswith("F:"): fname = line[2:].strip() dev_files = glob.glob(os.path.join(brpath, fname)) if len(dev_files) == 0: errors += 1 @@ -265,15 +266,14 @@ def parse_developers(filename=None): developers.append(Developer(name, files)) files = [] name = None else: print("Syntax error in DEVELOPERS file, line %d: '%s'" % (linen, line), file=sys.stderr) return None - linen += 1 # handle last developer if name is not None: developers.append(Developer(name, files)) if errors > 0: return None return developers