From 23277836c4985c304a1d3d72c07e6ceb270ba3b8 Mon Sep 17 00:00:00 2001 From: Paul Barker Date: Mon, 15 Jun 2020 19:10:14 +0200 Subject: [PATCH] tests: Check patches can still be applied after switching refspec Signed-off-by: Paul Barker Signed-off-by: Jan Kiszka --- tests/test_patch.py | 18 +++++++++++++++ tests/test_patch/test2.yml | 45 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 tests/test_patch/test2.yml diff --git a/tests/test_patch.py b/tests/test_patch.py index e463c42..fb7032d 100644 --- a/tests/test_patch.py +++ b/tests/test_patch.py @@ -39,3 +39,21 @@ def test_patch(tmpdir): assert os.stat(f)[stat.ST_MODE] & stat.S_IXUSR kas.kas(['shell', 'test.yml', '-c', 'true']) os.chdir(prev_dir) + +def test_patch_update(tmpdir): + """ + Test that patches are applied correctly after switching refspec from + a branch to a commit hash and vice-versa with both git and mercurial + repositories. + """ + tdir = str(tmpdir.mkdir('test_patch_update')) + shutil.rmtree(tdir, ignore_errors=True) + print(os.getcwd()) + shutil.copytree('tests/test_patch', tdir) + prev_dir = os.path.realpath(os.getcwd()) + os.chdir(tdir) + kas.kas(['shell', 'test.yml', '-c', 'true']) + kas.kas(['shell', 'test2.yml', '-c', 'true']) + for f in ['kas/tests/test_patch/hello.sh', 'hello/hello.sh']: + assert os.stat(f)[stat.ST_MODE] & stat.S_IXUSR + os.chdir(prev_dir) diff --git a/tests/test_patch/test2.yml b/tests/test_patch/test2.yml new file mode 100644 index 0000000..bba27a6 --- /dev/null +++ b/tests/test_patch/test2.yml @@ -0,0 +1,45 @@ +header: + version: 8 + +repos: + this: + + kas: + url: https://github.com/siemens/kas.git + refspec: master + patches: + plain: + repo: this + path: patches/kas-branch/003.patch + + kas-branch: + url: https://github.com/siemens/kas.git + refspec: 907816a5c4094b59a36aec12226e71c461c05b77 + patches: + plain: + repo: this + path: patches/kas/001.patch + quilt: + repo: this + path: patches/kas/quilt/ + + hello: + url: https://www.mercurial-scm.org/repo/hello/ + refspec: default + type: hg + patches: + plain: + repo: this + path: patches/hello/001.patch + quilt: + repo: this + path: patches/hello/quilt/ + + hello-branch: + url: https://www.mercurial-scm.org/repo/hello/ + refspec: 0a04b987be5a + type: hg + patches: + plain: + repo: this + path: patches/hello-branch/003.patch