diff options
| author | Alexis Lothoré <alexis.lothore@bootlin.com> | 2023-08-18 16:17:12 +0200 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-08-21 11:34:12 +0100 |
| commit | 95196108707bf4f20428202d312b974b2968913c (patch) | |
| tree | 3bc689f989e4ce6e1d717b51e3be7fd4329febb2 /meta/lib | |
| parent | e9cff55e73cce55456997ad277e8742ce9536601 (diff) | |
| download | poky-95196108707bf4f20428202d312b974b2968913c.tar.gz | |
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>
Diffstat (limited to 'meta/lib')
| -rw-r--r-- | meta/lib/oeqa/selftest/cases/gitarchivetests.py | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/meta/lib/oeqa/selftest/cases/gitarchivetests.py b/meta/lib/oeqa/selftest/cases/gitarchivetests.py index 4f7acd3311..11b88daab8 100644 --- a/meta/lib/oeqa/selftest/cases/gitarchivetests.py +++ b/meta/lib/oeqa/selftest/cases/gitarchivetests.py | |||
| @@ -10,6 +10,7 @@ basepath = os.path.abspath(os.path.dirname(__file__) + '/../../../../../') | |||
| 10 | lib_path = basepath + '/scripts/lib' | 10 | lib_path = basepath + '/scripts/lib' |
| 11 | sys.path = sys.path + [lib_path] | 11 | sys.path = sys.path + [lib_path] |
| 12 | import oeqa.utils.gitarchive as ga | 12 | import oeqa.utils.gitarchive as ga |
| 13 | from oeqa.utils.git import GitError | ||
| 13 | import tempfile | 14 | import tempfile |
| 14 | import shutil | 15 | import shutil |
| 15 | import scriptutils | 16 | import scriptutils |
| @@ -17,7 +18,7 @@ from oeqa.selftest.case import OESelftestTestCase | |||
| 17 | 18 | ||
| 18 | logger = scriptutils.logger_create('resulttool') | 19 | logger = scriptutils.logger_create('resulttool') |
| 19 | 20 | ||
| 20 | def create_fake_repository(commit, tag_list=[]): | 21 | def create_fake_repository(commit, tag_list=[], add_remote=True): |
| 21 | """ Create a testing git directory | 22 | """ Create a testing git directory |
| 22 | 23 | ||
| 23 | Initialize a simple git repository with one initial commit, and as many | 24 | Initialize a simple git repository with one initial commit, and as many |
| @@ -31,7 +32,8 @@ def create_fake_repository(commit, tag_list=[]): | |||
| 31 | fake_data_file = "fake_data.txt" | 32 | fake_data_file = "fake_data.txt" |
| 32 | tempdir = tempfile.mkdtemp(prefix='fake_results.') | 33 | tempdir = tempfile.mkdtemp(prefix='fake_results.') |
| 33 | repo = ga.init_git_repo(tempdir, False, False, logger) | 34 | repo = ga.init_git_repo(tempdir, False, False, logger) |
| 34 | repo.run_cmd(["remote", "add", "origin", "."]) | 35 | if add_remote: |
| 36 | repo.run_cmd(["remote", "add", "origin", "."]) | ||
| 35 | with open(os.path.join(tempdir, fake_data_file), "w") as fake_data: | 37 | with open(os.path.join(tempdir, fake_data_file), "w") as fake_data: |
| 36 | fake_data.write("Fake data") | 38 | fake_data.write("Fake data") |
| 37 | if commit: | 39 | if commit: |
| @@ -94,3 +96,32 @@ class GitArchiveTests(OESelftestTestCase): | |||
| 94 | self.assertEqual(len(revs[0].tags), 2) | 96 | self.assertEqual(len(revs[0].tags), 2) |
| 95 | self.assertEqual(revs[0].tags, ['main/10-g0f7d5df/0', 'main/10-g0f7d5df/1']) | 97 | self.assertEqual(revs[0].tags, ['main/10-g0f7d5df/0', 'main/10-g0f7d5df/1']) |
| 96 | delete_fake_repository(path) | 98 | delete_fake_repository(path) |
| 99 | |||
| 100 | def test_get_tags_without_valid_remote(self): | ||
| 101 | url = 'git://git.yoctoproject.org/poky' | ||
| 102 | path, git_obj = create_fake_repository(False, None, False) | ||
| 103 | |||
| 104 | tags = ga.get_tags(git_obj, pattern="yocto-*", url=url) | ||
| 105 | """Test for some well established tags (released tags)""" | ||
| 106 | self.assertIn("yocto-4.0", tags) | ||
| 107 | self.assertIn("yocto-4.1", tags) | ||
| 108 | self.assertIn("yocto-4.2", tags) | ||
| 109 | delete_fake_repository(path) | ||
| 110 | |||
| 111 | def test_get_tags_without_valid_remote_neither_url(self): | ||
| 112 | url = 'git://git.yoctoproject.org/poky' | ||
| 113 | path, git_obj = create_fake_repository(False, None, False) | ||
| 114 | |||
| 115 | """Test for some well established tags (released tags)""" | ||
| 116 | with self.assertRaises(GitError): | ||
| 117 | tags = ga.get_tags(git_obj, pattern="yocto-*") | ||
| 118 | delete_fake_repository(path) | ||
| 119 | |||
| 120 | def test_get_tags_without_valid_remote_and_wrong_url(self): | ||
| 121 | url = 'git://git.foo.org/bar' | ||
| 122 | path, git_obj = create_fake_repository(False, None, False) | ||
| 123 | |||
| 124 | """Test for some well established tags (released tags)""" | ||
| 125 | with self.assertRaises(GitError): | ||
| 126 | tags = ga.get_tags(git_obj, pattern="yocto-*", url=url) | ||
| 127 | delete_fake_repository(path) | ||
