From patchwork Tue Jan 24 17:30:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alexis_Lothor=C3=A9?= X-Patchwork-Id: 18554 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id E554FC61D97 for ; Tue, 24 Jan 2023 17:30:20 +0000 (UTC) Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [217.70.178.231]) by mx.groups.io with SMTP id smtpd.web11.21810.1674581412848687431 for ; Tue, 24 Jan 2023 09:30:13 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=JvUiWLH7; spf=pass (domain: bootlin.com, ip: 217.70.178.231, mailfrom: alexis.lothore@bootlin.com) Received: (Authenticated sender: alexis.lothore@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 18E8E100005; Tue, 24 Jan 2023 17:30:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1674581411; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=O27gm8E4iexRV+sgKCmhhPoxhI1GxmAMVzkX6zlAsDg=; b=JvUiWLH7CD44hz5wYOJCViNS+358oTIN5FGuuYDsl7wQ6ttUwCTlfbgOldBtED284NkA+R y4v8HNXIzS5aPwyctPlU6fvB08E6d80ewHxIhg9oge6JdqLl5T6FilEqwz3MPZ2gi/ed/o jOyZFmErzU00FclfCyelk/6aspXUaABPT6n0u2YJg9MEWOWpfGKazVHtUSfgQ7buTVzHd6 V2XOTVUWDMFQght392TSQjd9lO5fOjNODqPbrUAx1gL65DiI2mY1hx3eqlrCD5MVpEMjNf 3hV5u4otkYA8RLfP8RSOgAT1Vj5s1h0oaqMsVEISe6tDeorZyFYc/WZVF/bcaQ== From: =?utf-8?q?Alexis_Lothor=C3=A9?= To: yocto@lists.yoctoproject.org Cc: alexandre.belloni@bootlin.com, thomas.petazzoni@bootlin.com, =?utf-8?q?A?= =?utf-8?q?lexis_Lothor=C3=A9?= Subject: [autobuilder][PATCH v3 4/5] scripts/send_qa_email.py: add unit tests on previous version computation Date: Tue, 24 Jan 2023 18:30:16 +0100 Message-Id: <20230124173017.134017-5-alexis.lothore@bootlin.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230124173017.134017-1-alexis.lothore@bootlin.com> References: <20230124173017.134017-1-alexis.lothore@bootlin.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Tue, 24 Jan 2023 17:30:20 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto/message/59050 The "previous version" computation bring many edge cases depending on the version under release. Add a basic test suite to validate currently implemented computation strategy and to prevent mistakes when ediiting it in the future Signed-off-by: Alexis Lothoré --- scripts/test_send_qa_email.py | 56 +++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100755 scripts/test_send_qa_email.py diff --git a/scripts/test_send_qa_email.py b/scripts/test_send_qa_email.py new file mode 100755 index 0000000..41e895e --- /dev/null +++ b/scripts/test_send_qa_email.py @@ -0,0 +1,56 @@ +#!/usr/bin/env python3 +""" +Test suite for send_qa_email.py + +The suite needs a valid poky clone to run since it will +fetch and return revisions from remote repository. To run the suite, +set POKY_PATH environment variable accordingly: +`POKY_PATH=~/src/poky ./scripts/test_send_qa_email.py` +""" +import os +import sys +import unittest +import send_qa_email + + +class TestVersion(unittest.TestCase): + test_data_get_version = [ + {"input": {"version": "4.1.2"}, "expected": "yocto-4.1.1"}, + {"input": {"version": "4.1"}, "expected": "yocto-4.0"}, + {"input": {"version": "4.1.1"}, "expected": "yocto-4.1"}, + {"input": {"version": "4.1_M2"}, "expected": "4.1_M1"}, + {"input": {"version": "4.1_M1"}, "expected": "yocto-4.0"}, + {"input": {"version": "4.1.1.rc1"}, "expected": "yocto-4.1"}, + {"input": {"version": "4.1.2.rc1"}, "expected": "yocto-4.1.1"}, + {"input": {"version": "4.1_M3.rc1"}, "expected": "4.1_M2"}, + {"input": {"version": "4.1_M3.rc4"}, "expected": "4.1_M2"}, + {"input": {"version": "4.1_M1.rc1"}, "expected": "yocto-4.0"}, + {"input": {"version": "4.1_M1.rc4"}, "expected": "yocto-4.0"}, + {"input": {"version": "4.1.rc4"}, "expected": "yocto-4.0"} + ] + + test_data_get_sha1 = [ + {"input": "yocto-4.0", "expected": "00cfdde791a0176c134f31e5a09eff725e75b905"}, + {"input": "4.1_M1", "expected": "95066dde6861ee08fdb505ab3e0422156cc24fae"}, + ] + + def test_versions(self): + for data in self.test_data_get_version: + test_name = data["input"]["version"] + with self.subTest(f"Test {test_name} previous tag"): + self.assertEqual(send_qa_email.get_previous_tag(os.environ.get( + "POKY_PATH"), data["input"]["version"]), data["expected"]) + + def test_get_sha1(self): + for data in self.test_data_get_sha1: + test_name = data["input"] + with self.subTest(f"Test SHA1 from {test_name}"): + self.assertEqual(send_qa_email.get_sha1(os.environ.get( + "POKY_PATH"), data["input"]), data["expected"]) + + +if __name__ == '__main__': + if os.environ.get("POKY_PATH") is None: + print("Please set POKY_PATH to proper poky clone location before running tests") + sys.exit(1) + unittest.main()