From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6498671579909586944 X-Received: by 2002:aa7:c952:: with SMTP id h18mr35984674edt.269.1618326393687; Tue, 13 Apr 2021 08:06:33 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a05:6402:4c2:: with SMTP id n2ls3943122edw.2.gmail; Tue, 13 Apr 2021 08:06:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz4UIQj8N2+PHOaHwblRrRe5Cu7Z0GdYkIFvbNXK+kEohaRU3Hj6thuDHR0D9KtnEAEjgl5 X-Received: by 2002:aa7:dc0b:: with SMTP id b11mr35889906edu.124.1618326392795; Tue, 13 Apr 2021 08:06:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618326392; cv=none; d=google.com; s=arc-20160816; b=GewKKKm/NLDpNiQxl8cVaXlZwuKPHWZ/1COhu/oKvvMkUoshb/6AIxHUX2trnPz1QH 7ER/y87DgaO+Tsfig2gTi0kF7OMMvdDKy7A6iPvPZ4eWORHnbuonaFNmSoF0I85xZrsV 7DI/Ul3wL80haY/uZbRMC13k2PGi784WCdRqqmE1EecNQVxyypu/SSsoN7YPbW11WDBr dXR6/IK6YDys7jRBNipBXcfjgrU773ZkPVp0FXa4nq8UvZ+g94mAlolkY1nx4kEtnnbE Zyrko8DuRXj5AjX0J2eW2EHHkC7XMiJTt85gCO83/az4ktT9OYz63hjDZ06MVPvYhPTx 9mTA== 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=pISVF+c9b1J/nXrWAuW/NSbaUevBj1SThJbGe2I4i5c=; b=HoEY45vlCHN0JXXCajnvkQUaEHxZS3rkUGoywu7NyZz9Xbk6+bk3k5WZe1ba4qouZD dW7I8DH9cDbndVdL2czOPad7ZaxifmIUn78geQO0RNO6YGdnVlImwkUujl8EC+yeO1Ny 55lQUd/Vgl9BX1aKRBjPnIebYVF3W5E9csSiS2VJuSj6OCrAfe+p96WrptGaCkg0UNlP nlpxA2ACrc1F1iGu+fX3wKoO7zjyZc+PdUYa65AFvS1upBnubqVSfyXoC+wATUM3D4wo tXMCuPzRVepYm5rKaSiFfCPe+7GMZHx3ShDY8+LjOK7pUYeV9wwFFcFBLDl4H+kJ6mAR 9FXA== 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 c12si1122887eds.0.2021.04.13.08.06.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Apr 2021 08:06:32 -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 13DF6Wo5012254 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 13 Apr 2021 17:06:32 +0200 Received: from localhost.localdomain ([167.87.48.83]) by mail2.sbs.de (8.15.2/8.15.2) with ESMTP id 13DF2rM3021528; Tue, 13 Apr 2021 17:02:54 +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 v2 2/3] tests/fetch: deduplicate local git testing code Date: Tue, 13 Apr 2021 17:02:50 +0200 Message-Id: <20210413150251.1969-2-henning.schild@siemens.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210413150251.1969-1-henning.schild@siemens.com> References: <20210413150251.1969-1-henning.schild@siemens.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TUID: 5IvR3kvnE83g Purely cosmetic change that probably improves the code. Signed-off-by: Henning Schild --- lib/bb/tests/fetch.py | 33 +++++++-------------------------- 1 file changed, 7 insertions(+), 26 deletions(-) diff --git a/lib/bb/tests/fetch.py b/lib/bb/tests/fetch.py index ddf6e97439b5..76797473db8a 100644 --- a/lib/bb/tests/fetch.py +++ b/lib/bb/tests/fetch.py @@ -673,7 +673,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_') @@ -690,7 +690,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) @@ -699,31 +699,12 @@ 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 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() - # 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(self): + self.dummyGitTest("usehead=1") + + def test_local_gitfetch_usehead_withname(self): + self.dummyGitTest("usehead=1;name=newName") class FetcherNoNetworkTest(FetcherTest): def setUp(self): -- 2.26.3