From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6498671579909586944 X-Received: by 2002:adf:ce90:: with SMTP id r16mr19442262wrn.354.1618382620464; Tue, 13 Apr 2021 23:43:40 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a05:600c:4101:: with SMTP id j1ls479704wmi.2.canary-gmail; Tue, 13 Apr 2021 23:43:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzl6geA6ojXM4nVpNMt6t/2+3ZLtF7tH5yYgMLsLr/F1ntf6YxRs09RtP5vFKF8yhZTQuYQ X-Received: by 2002:a7b:c8ce:: with SMTP id f14mr1339949wml.113.1618382619834; Tue, 13 Apr 2021 23:43:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618382619; cv=none; d=google.com; s=arc-20160816; b=CfaRMZwh1vWxxqHzXAUSg1Opc6vj017SrUosWNSAEk9CdTJ7MKrsmz5nldXaXc1Rid drikFdnavICE02bRyyZC/QNPiUd+eiaOr9UgUZ4WgJ1ymmMT0huoAbunoZDEjyQl7F4M j7uqCOXLbrjuE6yEmUoKMs7+w1Sa/Yq01d/XNtAJitvuXH1THDhXfaANavoqhWgQ+KMM cM8LM2qdh6N+IH0UPuk8cxWfSL4H9wumOu9B1YNrsRNf/7PHluDTFDYeJT7ZLs6JyrMV 31cbMTWGsGTukmWEfH0xYWKrHjro9UeASDygX+vE9oDEy7MhraAyb6NSi/h8Ex5BAUaX nZBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=GDd2oYN0bCBV0krbmmlrN/e2/ts8e9cV3SOFOmxLBdw=; b=NXfYtihW/1CYckoaJFe2mFor6uUmTfAmEl0mECQl8S2sRixQaFOQsPmGLdsDsFIqDg D0vEDrH/9SRNkGHXAea83ydLWerNhEnEVQcTQoFIhTLCh3mEmtULqNJ8SYrWJF/bjox5 ArzucosKH9YcZs8KLsvgaTXYePntETtHlq1SFMiY5VqQAYIf0xPPA3HJ9TsPO2VFMGy4 8NrG+X5mXTH8CB/vWCGn6Ivne9FTWQZbb9Yr5G+W6aU3t4SneIwx69j4gGaXvcsDXaEO GmKvAB5aRrSBF12RkivxAQYvXFujDkCC6+LXXq7K7KgeXuiH8Vb9TIDiYe07EKl7a/pW Ovvw== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of henning.schild@siemens.com designates 194.138.37.39 as permitted sender) smtp.mailfrom=henning.schild@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Return-Path: Received: from lizzard.sbs.de (lizzard.sbs.de. [194.138.37.39]) by gmr-mx.google.com with ESMTPS id f8si266567wmj.1.2021.04.13.23.43.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Apr 2021 23:43:39 -0700 (PDT) Received-SPF: pass (google.com: domain of henning.schild@siemens.com designates 194.138.37.39 as permitted sender) client-ip=194.138.37.39; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of henning.schild@siemens.com designates 194.138.37.39 as permitted sender) smtp.mailfrom=henning.schild@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Received: from mail2.sbs.de (mail2.sbs.de [192.129.41.66]) by lizzard.sbs.de (8.15.2/8.15.2) with ESMTPS id 13E6hd7K020749 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Apr 2021 08:43:39 +0200 Received: from localhost.localdomain ([167.87.7.134]) by mail2.sbs.de (8.15.2/8.15.2) with ESMTP id 13E6WjJv020955; Wed, 14 Apr 2021 08:32:45 +0200 From: Henning Schild To: bitbake-devel@lists.openembedded.org Cc: isar-users@googlegroups.com, Richard Purdie , Cedric Hombourger , Chris Larson , Henning Schild Subject: [PATCH v3 2/3] tests/fetch: deduplicate local git testing code Date: Wed, 14 Apr 2021 08:32:40 +0200 Message-Id: <20210414063241.18528-2-henning.schild@siemens.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210414063241.18528-1-henning.schild@siemens.com> References: <20210414063241.18528-1-henning.schild@siemens.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TUID: LYVVF8hnf9w0 Purely cosmetic change that probably improves the code. Signed-off-by: Henning Schild --- lib/bb/tests/fetch.py | 34 ++++++---------------------------- 1 file changed, 6 insertions(+), 28 deletions(-) diff --git a/lib/bb/tests/fetch.py b/lib/bb/tests/fetch.py index b921a952e493..ab02bc74ac15 100644 --- a/lib/bb/tests/fetch.py +++ b/lib/bb/tests/fetch.py @@ -674,7 +674,7 @@ class FetcherLocalTest(FetcherTest): with self.assertRaises(bb.fetch2.UnpackError): self.fetchUnpack(['file://a;subdir=/bin/sh']) - def test_local_gitfetch_usehead(self): + def dummyGitTest(self, suffix): # Create dummy local Git repo src_dir = tempfile.mkdtemp(dir=self.tempdir, prefix='gitfetch_localusehead_') @@ -693,7 +693,7 @@ class FetcherLocalTest(FetcherTest): # Fetch and check revision self.d.setVar("SRCREV", "AUTOINC") - url = "git://" + src_dir + ";protocol=file;usehead=1" + url = "git://" + src_dir + ";protocol=file;" + suffix fetcher = bb.fetch.Fetch([url], self.d) fetcher.download() fetcher.unpack(self.unpackdir) @@ -702,33 +702,11 @@ class FetcherLocalTest(FetcherTest): unpack_rev = stdout[0].strip() self.assertEqual(orig_rev, unpack_rev) - def test_local_gitfetch_usehead_withname(self): - # Create dummy local Git repo - src_dir = tempfile.mkdtemp(dir=self.tempdir, - prefix='gitfetch_localusehead_') - src_dir = os.path.abspath(src_dir) - bb.process.run("git init", cwd=src_dir) - bb.process.run("git config user.email 'you@example.com'", cwd=src_dir) - bb.process.run("git config user.name 'Your Name'", cwd=src_dir) - bb.process.run("git commit --allow-empty -m'Dummy commit'", - cwd=src_dir) - # Use other branch than master - bb.process.run("git checkout -b my-devel", cwd=src_dir) - bb.process.run("git commit --allow-empty -m'Dummy commit 2'", - cwd=src_dir) - stdout = bb.process.run("git rev-parse HEAD", cwd=src_dir) - orig_rev = stdout[0].strip() + def test_local_gitfetch_usehead(self): + self.dummyGitTest("usehead=1") - # Fetch and check revision - self.d.setVar("SRCREV", "AUTOINC") - url = "git://" + src_dir + ";protocol=file;usehead=1;name=newName" - fetcher = bb.fetch.Fetch([url], self.d) - fetcher.download() - fetcher.unpack(self.unpackdir) - stdout = bb.process.run("git rev-parse HEAD", - cwd=os.path.join(self.unpackdir, 'git')) - unpack_rev = stdout[0].strip() - self.assertEqual(orig_rev, unpack_rev) + def test_local_gitfetch_usehead_withname(self): + self.dummyGitTest("usehead=1;name=newName") class FetcherNoNetworkTest(FetcherTest): def setUp(self): -- 2.26.3