mirror of
git://git.yoctoproject.org/poky.git
synced 2025-07-19 11:59:01 +02:00
oeqa/selftest/gitarchive: add tests about tags lisiting when no remote is configured
Add specific tests on gitarchive for when tag listing is required but no remote is configured in target directory: it should either succeed if valid url is provided, or fail is url is not provided or wrong (From OE-Core rev: 5e9d84d82fde81d66550d8c694ea70f0911fa4f7) Signed-off-by: Alexis Lothoré <alexis.lothore@bootlin.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
parent
e9cff55e73
commit
9519610870
|
@ -10,6 +10,7 @@ basepath = os.path.abspath(os.path.dirname(__file__) + '/../../../../../')
|
||||||
lib_path = basepath + '/scripts/lib'
|
lib_path = basepath + '/scripts/lib'
|
||||||
sys.path = sys.path + [lib_path]
|
sys.path = sys.path + [lib_path]
|
||||||
import oeqa.utils.gitarchive as ga
|
import oeqa.utils.gitarchive as ga
|
||||||
|
from oeqa.utils.git import GitError
|
||||||
import tempfile
|
import tempfile
|
||||||
import shutil
|
import shutil
|
||||||
import scriptutils
|
import scriptutils
|
||||||
|
@ -17,7 +18,7 @@ from oeqa.selftest.case import OESelftestTestCase
|
||||||
|
|
||||||
logger = scriptutils.logger_create('resulttool')
|
logger = scriptutils.logger_create('resulttool')
|
||||||
|
|
||||||
def create_fake_repository(commit, tag_list=[]):
|
def create_fake_repository(commit, tag_list=[], add_remote=True):
|
||||||
""" Create a testing git directory
|
""" Create a testing git directory
|
||||||
|
|
||||||
Initialize a simple git repository with one initial commit, and as many
|
Initialize a simple git repository with one initial commit, and as many
|
||||||
|
@ -31,7 +32,8 @@ def create_fake_repository(commit, tag_list=[]):
|
||||||
fake_data_file = "fake_data.txt"
|
fake_data_file = "fake_data.txt"
|
||||||
tempdir = tempfile.mkdtemp(prefix='fake_results.')
|
tempdir = tempfile.mkdtemp(prefix='fake_results.')
|
||||||
repo = ga.init_git_repo(tempdir, False, False, logger)
|
repo = ga.init_git_repo(tempdir, False, False, logger)
|
||||||
repo.run_cmd(["remote", "add", "origin", "."])
|
if add_remote:
|
||||||
|
repo.run_cmd(["remote", "add", "origin", "."])
|
||||||
with open(os.path.join(tempdir, fake_data_file), "w") as fake_data:
|
with open(os.path.join(tempdir, fake_data_file), "w") as fake_data:
|
||||||
fake_data.write("Fake data")
|
fake_data.write("Fake data")
|
||||||
if commit:
|
if commit:
|
||||||
|
@ -94,3 +96,32 @@ class GitArchiveTests(OESelftestTestCase):
|
||||||
self.assertEqual(len(revs[0].tags), 2)
|
self.assertEqual(len(revs[0].tags), 2)
|
||||||
self.assertEqual(revs[0].tags, ['main/10-g0f7d5df/0', 'main/10-g0f7d5df/1'])
|
self.assertEqual(revs[0].tags, ['main/10-g0f7d5df/0', 'main/10-g0f7d5df/1'])
|
||||||
delete_fake_repository(path)
|
delete_fake_repository(path)
|
||||||
|
|
||||||
|
def test_get_tags_without_valid_remote(self):
|
||||||
|
url = 'git://git.yoctoproject.org/poky'
|
||||||
|
path, git_obj = create_fake_repository(False, None, False)
|
||||||
|
|
||||||
|
tags = ga.get_tags(git_obj, pattern="yocto-*", url=url)
|
||||||
|
"""Test for some well established tags (released tags)"""
|
||||||
|
self.assertIn("yocto-4.0", tags)
|
||||||
|
self.assertIn("yocto-4.1", tags)
|
||||||
|
self.assertIn("yocto-4.2", tags)
|
||||||
|
delete_fake_repository(path)
|
||||||
|
|
||||||
|
def test_get_tags_without_valid_remote_neither_url(self):
|
||||||
|
url = 'git://git.yoctoproject.org/poky'
|
||||||
|
path, git_obj = create_fake_repository(False, None, False)
|
||||||
|
|
||||||
|
"""Test for some well established tags (released tags)"""
|
||||||
|
with self.assertRaises(GitError):
|
||||||
|
tags = ga.get_tags(git_obj, pattern="yocto-*")
|
||||||
|
delete_fake_repository(path)
|
||||||
|
|
||||||
|
def test_get_tags_without_valid_remote_and_wrong_url(self):
|
||||||
|
url = 'git://git.foo.org/bar'
|
||||||
|
path, git_obj = create_fake_repository(False, None, False)
|
||||||
|
|
||||||
|
"""Test for some well established tags (released tags)"""
|
||||||
|
with self.assertRaises(GitError):
|
||||||
|
tags = ga.get_tags(git_obj, pattern="yocto-*", url=url)
|
||||||
|
delete_fake_repository(path)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user