add test for KAS_REPO_REF_DIR logic

This patch adds a test for cloning with KAS_REPO_REF_DIR.
It explicitly tests the case that two repos with a single upstream URI
are added and also tests mercurial.

Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
[Jan: ensure Python 3.5 compatibility]
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
This commit is contained in:
Felix Moessbauer 2023-01-05 08:50:23 +01:00 committed by Jan Kiszka
parent 3289ec2a7e
commit 1c2c859a4a

View File

@ -22,6 +22,7 @@
import glob
import os
import pathlib
import shutil
import json
import yaml
@ -62,6 +63,19 @@ def test_checkout(changedir, tmpdir):
assert not os.path.exists('build/sstate-cache')
def test_checkout_create_refs(changedir, tmpdir):
tpath = pathlib.Path(str(tmpdir.mkdir('test_commands')))
repo_cache = pathlib.Path(str(tmpdir.mkdir('repos')))
shutil.rmtree(str(tpath), ignore_errors=True)
shutil.copytree('tests/test_patch', str(tpath))
os.chdir(str(tpath))
os.environ['KAS_REPO_REF_DIR'] = str(repo_cache)
kas.kas(['checkout', 'test.yml'])
del os.environ['KAS_REPO_REF_DIR']
assert os.path.exists(str(repo_cache / 'github.com.siemens.kas.git'))
assert os.path.exists('kas/.git/objects/info/alternates')
def test_repo_includes(changedir, tmpdir):
tdir = str(tmpdir.mkdir('test_commands'))
shutil.rmtree(tdir, ignore_errors=True)