From patchwork Fri Oct 30 03:46:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1390744 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=HrX0U6/H; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CMpHD2jTGz9sPB for ; Fri, 30 Oct 2020 14:50:16 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7E7CA8269B; Fri, 30 Oct 2020 04:47:37 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="HrX0U6/H"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 283CC8264E; Fri, 30 Oct 2020 04:47:07 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd44.google.com (mail-io1-xd44.google.com [IPv6:2607:f8b0:4864:20::d44]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 69A2C8264E for ; Fri, 30 Oct 2020 04:47:02 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd44.google.com with SMTP id p7so6137013ioo.6 for ; Thu, 29 Oct 2020 20:47:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8k1NUNDfLC/5Dalmq+nRLVIdH9AZUvf4ti76U+7M/24=; b=HrX0U6/HgzSUTtBNxtX8b99/Twy9S29SqNNPhJjX+A9GwjY3S1CpuWkByXT+kASGvB FqS50A1hdLtWH4yVwRHuSnYmchxJj7/FzJl1Kfc8h5/5ie6C6xmKQ/FCCXg7KIKUwLTr Hi8ruJ+ypf79t7i935WIHJYdWC8Z/1eJRCF2Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8k1NUNDfLC/5Dalmq+nRLVIdH9AZUvf4ti76U+7M/24=; b=KTkp6v86QOCQ+eXWoWl0adQlbaxBuBTF9wc/AmZOIM1fZY5sRthPfZ9QsBdJ3imVGw C/BCtFmJpT5xV2zz2gsZiveY1RoyAvUqvXk4Gm+MMUAEGskU8G+DlAKBQZYw61igC4nv BVPPdEteTJU4JX81GnmNtwFV8ukXJ65aWhrGVBKgTWD1qhiKI9naYdjfvHvBaDyekPJ+ 4FjS4FiSfe6M29H84AfIm5EMEI1PAieT01pEaW9f+tutncqIBwYQCfgVDGRs8QoYkr1l 2uLX/celgvfJJBMI8ZK0Y3ATvTnbPG3lUgf+PjbIlEZAXxgI7YrjsmlB0jG4FdOE8bUI ZcDg== X-Gm-Message-State: AOAM530ziD68AObkFNWLJh5NNcQGFudmreaYd88LsscLM1KQUKlt0UgK 4RTMyVNIYOfcoKvpfwxP0uMJxIZQF4qzDteb X-Google-Smtp-Source: ABdhPJzB4HBQ8Cxwj5gRtPqiwz62YeWD+ZJea+HtnqimvXshHb214Ey1ZObVIkvFZ4oi71BXRFpBiQ== X-Received: by 2002:a05:6602:1305:: with SMTP id h5mr412501iov.41.1604029621029; Thu, 29 Oct 2020 20:47:01 -0700 (PDT) Received: from localhost.localdomain (c-73-14-175-90.hsd1.co.comcast.net. [73.14.175.90]) by smtp.gmail.com with ESMTPSA id n28sm4858693ila.52.2020.10.29.20.47.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Oct 2020 20:47:00 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: patchwork@lists.ozlabs.org, Doug Anderson , Tom Rini , Simon Glass Subject: [PATCH v3 18/29] patman: Add a test for PatchStream tags Date: Thu, 29 Oct 2020 21:46:27 -0600 Message-Id: <20201030034638.2858999-19-sjg@chromium.org> X-Mailer: git-send-email 2.29.1.341.ge80a0c044ae-goog In-Reply-To: <20201030034638.2858999-1-sjg@chromium.org> References: <20201030034638.2858999-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean The current functional tests run most of patman. Add a smaller test that just checks tag handling with the PatchStream class. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- (no changes since v1) tools/patman/func_test.py | 26 +++++++++++++++++++++----- tools/patman/patchstream.py | 23 +++++++++++++++++++++++ 2 files changed, 44 insertions(+), 5 deletions(-) diff --git a/tools/patman/func_test.py b/tools/patman/func_test.py index 2290ba95e9d..2a0da8b3ccf 100644 --- a/tools/patman/func_test.py +++ b/tools/patman/func_test.py @@ -31,6 +31,9 @@ except ModuleNotFoundError: class TestFunctional(unittest.TestCase): """Functional tests for checking that patman behaves correctly""" + leb = (b'Lord Edmund Blackadd\xc3\xabr '. + decode('utf-8')) + def setUp(self): self.tmpdir = tempfile.mkdtemp(prefix='patman.') self.gitdir = os.path.join(self.tmpdir, 'git') @@ -177,8 +180,6 @@ class TestFunctional(unittest.TestCase): stefan = b'Stefan Br\xc3\xbcns '.decode('utf-8') rick = 'Richard III ' mel = b'Lord M\xc3\xablchett '.decode('utf-8') - leb = (b'Lond Edmund Blackadd\xc3\xabr +Reviewed-by: Mary Bloggs +Tested-by: %s +''' % self.leb + pstrm = PatchStream.process_text(text) + self.assertEqual(pstrm.commit.rtags, { + 'Reviewed-by': {'Mary Bloggs ', + 'Joe Bloggs '}, + 'Tested-by': {self.leb}}) diff --git a/tools/patman/patchstream.py b/tools/patman/patchstream.py index cf591b27573..d6f6ae92513 100644 --- a/tools/patman/patchstream.py +++ b/tools/patman/patchstream.py @@ -5,6 +5,7 @@ """Handles parsing a stream of commits/emails from 'git log' or other source""" import datetime +import io import math import os import re @@ -81,6 +82,28 @@ class PatchStream: self.state = STATE_MSG_HEADER # What state are we in? self.commit = None # Current commit + @staticmethod + def process_text(text, is_comment=False): + """Process some text through this class using a default Commit/Series + + Args: + text (str): Text to parse + is_comment (bool): True if this is a comment rather than a patch. + If True, PatchStream doesn't expect a patch subject at the + start, but jumps straight into the body + + Returns: + PatchStream: object with results + """ + pstrm = PatchStream(Series()) + pstrm.commit = commit.Commit(None) + infd = io.StringIO(text) + outfd = io.StringIO() + if is_comment: + pstrm.state = STATE_PATCH_HEADER + pstrm.process_stream(infd, outfd) + return pstrm + def _add_warn(self, warn): """Add a new warning to report to the user about the current commit