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: 1390766 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (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 4CMpLF6s4Cz9sPB for ; Fri, 30 Oct 2020 14:52:53 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (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 bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4CMpLF6Fl2zDqcK for ; Fri, 30 Oct 2020 14:52:53 +1100 (AEDT) X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=chromium.org (client-ip=2607:f8b0:4864:20::d44; helo=mail-io1-xd44.google.com; envelope-from=sjg@chromium.org; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: lists.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 mail-io1-xd44.google.com (mail-io1-xd44.google.com [IPv6:2607:f8b0:4864:20::d44]) (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 lists.ozlabs.org (Postfix) with ESMTPS id 4CMpCV6xlRzDqVd for ; Fri, 30 Oct 2020 14:47:02 +1100 (AEDT) Received: by mail-io1-xd44.google.com with SMTP id b15so6113170iod.13 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=iuicAr23ki96WsaI9+1k1apiTEp20Ygvyyqv9bxvFJbcqPHUfotbrksM56f/ILZVLD ruXNsj+vdoSUNRfeOwJkjhmPm7P2wN+mxTS364XzX9y40dUcDtaY2zZZMQsU5f1eavoB tJjzYnznCf5EkQBuzQG3nDyd5XluIL8h/SSkm3sP5iwOgtTxjXLMK5UKJwtkMpJNFRtZ YkiAjmRLbc4cjJQEKhzuhmFNe+e8eWpXx9//rYV7KKYbqjJa5E0VM/Q+ID8YcQ5DSt2v wm62MWIfwl04W4yk8NvJuH9LEqh6HXq2/hec4gvPUcwoeilCgUdJ1ZQmfuqHUJB3LDVA /+eA== X-Gm-Message-State: AOAM532HXpnJnlc0ICNrQuM6hEDfSSSCAxQs0zycZcWkTNCYCJgDHGpp dXGu677Tk1O5LvOCTmPL1JjR5A== 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 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: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: patchwork@lists.ozlabs.org, Simon Glass , Tom Rini Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" 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