From 1c2c859a4a7d71398ff23ed725603b4edf204a49 Mon Sep 17 00:00:00 2001 From: Felix Moessbauer Date: Thu, 5 Jan 2023 08:50:23 +0100 Subject: [PATCH] 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 [Jan: ensure Python 3.5 compatibility] Signed-off-by: Jan Kiszka --- tests/test_commands.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/test_commands.py b/tests/test_commands.py index 6f600b9..712a764 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -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)