From patchwork Mon Oct 26 01:04:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1387376 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=85.214.62.61; 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=AhddS0np; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (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 4CKGtg1Sn5z9sT6 for ; Mon, 26 Oct 2020 12:08:42 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3DF9882524; Mon, 26 Oct 2020 02:05:57 +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="AhddS0np"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DF5D7824D0; Mon, 26 Oct 2020 02:05:21 +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-il1-x135.google.com (mail-il1-x135.google.com [IPv6:2607:f8b0:4864:20::135]) (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 DCBCC824C2 for ; Mon, 26 Oct 2020 02:05:18 +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-il1-x135.google.com with SMTP id a20so6720290ilk.13 for ; Sun, 25 Oct 2020 18:05:18 -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=JbHz5yIzduPGXYJvnWTGbaH8PS+IX+LSaUAM+ukUNz8=; b=AhddS0nppC+ogj6mC6nz+UKvhIdVFRKCq2OzwcQsRJgHJ5lbVKadZK8pWIgon+KEWl VTvzqXTDag6tppUvj8LKwU2GXNQ41f7DUCImxn5PprQ87UsD7/HHc1Use3tu7OtSUaY7 KdeYQyKkUCboG+2UyKXPTOZIQbBwiIjR88LGE= 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=JbHz5yIzduPGXYJvnWTGbaH8PS+IX+LSaUAM+ukUNz8=; b=AymFqnZjGsFRVb7fINUGAMJDLjlLx13qhlA0dKyxiifklAvfXl6EGxElIfD/VDk95N MA9w4PTZP5ZbpvepX+rcjHiQ8FAQIQjHMbtAyf1/droIqMMdZ+tK++KUccBdKM0glqCJ UDh66NI/laly4Zl4pzaBafpFIKBYKyAZz0fWgkJjazb5PeS5UQUONT5vl0RP8HYCDHBl jJ57oGNiSxEwXsTI8dHeaMqC+18CxdB39LGlsP3nDmhq0W24dtc96By2alMmensTzY20 VzKmW7rraOrti/lkIGnbIkWNyfvSzpgZHSduLoL552P+0jMC/h/DZr/uYs4pT3Gr3PVh /TpA== X-Gm-Message-State: AOAM53098QvimmnMidrTzMFb5uhMAU4MoeSFoFIxGT+tKPtmsqW8WY4q APHvh0l87W3pghtKGXDgJV714Uj/BIFshIys X-Google-Smtp-Source: ABdhPJwRERxXON9vRsmXMAJ7SwGdVxZ9Ea8n2Obu115svHzw0UjImGVmEEJerrFkvO/x+7TTijFkUA== X-Received: by 2002:a92:c60e:: with SMTP id p14mr2409108ilm.258.1603674317599; Sun, 25 Oct 2020 18:05:17 -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 a6sm5231162ili.11.2020.10.25.18.05.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Oct 2020 18:05:17 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Doug Anderson , patchwork@lists.ozlabs.org, Simon Glass Subject: [PATCH v2 18/30] patman: Add a test for PatchStream tags Date: Sun, 25 Oct 2020 19:04:30 -0600 Message-Id: <20201026010442.1606893-19-sjg@chromium.org> X-Mailer: git-send-email 2.29.0.rc2.309.g374f81d7ae-goog In-Reply-To: <20201026010442.1606893-1-sjg@chromium.org> References: <20201026010442.1606893-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 --- (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