From fafc017392f9e8f8ab9fe69173cc17b3403c6046 Mon Sep 17 00:00:00 2001 From: Henning Schild Date: Tue, 20 Aug 2019 16:58:59 +0200 Subject: [PATCH] tests: add a testcase for applying patches This adds a test where we clone a git and a hg repo and apply a single patch and later a quilt series on each of them. Signed-off-by: Henning Schild Signed-off-by: Jan Kiszka --- .travis.yml | 5 +++ tests/test_patch.py | 35 +++++++++++++++++++ tests/test_patch/oe-init-build-env | 3 ++ tests/test_patch/patches/hello/001.patch | 8 +++++ .../test_patch/patches/hello/quilt/001.patch | 8 +++++ .../test_patch/patches/hello/quilt/002.patch | 8 +++++ tests/test_patch/patches/hello/quilt/series | 4 +++ tests/test_patch/patches/kas/001.patch | 24 +++++++++++++ tests/test_patch/patches/kas/quilt/001.patch | 24 +++++++++++++ tests/test_patch/patches/kas/quilt/002.patch | 24 +++++++++++++ tests/test_patch/patches/kas/quilt/series | 4 +++ tests/test_patch/test.yml | 28 +++++++++++++++ 12 files changed, 175 insertions(+) create mode 100644 tests/test_patch.py create mode 100755 tests/test_patch/oe-init-build-env create mode 100644 tests/test_patch/patches/hello/001.patch create mode 100644 tests/test_patch/patches/hello/quilt/001.patch create mode 100644 tests/test_patch/patches/hello/quilt/002.patch create mode 100644 tests/test_patch/patches/hello/quilt/series create mode 100644 tests/test_patch/patches/kas/001.patch create mode 100644 tests/test_patch/patches/kas/quilt/001.patch create mode 100644 tests/test_patch/patches/kas/quilt/002.patch create mode 100644 tests/test_patch/patches/kas/quilt/series create mode 100644 tests/test_patch/test.yml diff --git a/.travis.yml b/.travis.yml index 46791ca..07c573f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,6 +10,11 @@ sudo: required services: - docker +addons: + apt: + packages: + - mercurial + install: # install kas to have all kas dependencies: - pip install . diff --git a/tests/test_patch.py b/tests/test_patch.py new file mode 100644 index 0000000..872e3b6 --- /dev/null +++ b/tests/test_patch.py @@ -0,0 +1,35 @@ +# kas - setup tool for bitbake based projects +# +# Copyright (c) Siemens AG, 2019 +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +import os +import shutil +from kas import kas + +import pytest # noqa: F401; flake8 'pytest' imported but unused + + +def test_patch(tmpdir): + tdir = str(tmpdir.mkdir('test_patch')) + shutil.rmtree(tdir, ignore_errors=True) + shutil.copytree('tests/test_patch', tdir) + os.chdir(tdir) + kas.kas(['shell', 'test.yml', '-c', 'true']) diff --git a/tests/test_patch/oe-init-build-env b/tests/test_patch/oe-init-build-env new file mode 100755 index 0000000..296ef78 --- /dev/null +++ b/tests/test_patch/oe-init-build-env @@ -0,0 +1,3 @@ +#!/bin/sh + +true diff --git a/tests/test_patch/patches/hello/001.patch b/tests/test_patch/patches/hello/001.patch new file mode 100644 index 0000000..0c5ef61 --- /dev/null +++ b/tests/test_patch/patches/hello/001.patch @@ -0,0 +1,8 @@ +diff --git a/Makefile b/Makefile +--- a/Makefile ++++ b/Makefile +@@ -1,1 +1,4 @@ + all: hello ++ ++clean: ++ rm -f hello diff --git a/tests/test_patch/patches/hello/quilt/001.patch b/tests/test_patch/patches/hello/quilt/001.patch new file mode 100644 index 0000000..98bcbdd --- /dev/null +++ b/tests/test_patch/patches/hello/quilt/001.patch @@ -0,0 +1,8 @@ +diff --git a/Makefile b/Makefile +--- a/Makefile ++++ b/Makefile +@@ -1,4 +1,1 @@ + all: hello +- +-clean: +- rm -f hello diff --git a/tests/test_patch/patches/hello/quilt/002.patch b/tests/test_patch/patches/hello/quilt/002.patch new file mode 100644 index 0000000..0c5ef61 --- /dev/null +++ b/tests/test_patch/patches/hello/quilt/002.patch @@ -0,0 +1,8 @@ +diff --git a/Makefile b/Makefile +--- a/Makefile ++++ b/Makefile +@@ -1,1 +1,4 @@ + all: hello ++ ++clean: ++ rm -f hello diff --git a/tests/test_patch/patches/hello/quilt/series b/tests/test_patch/patches/hello/quilt/series new file mode 100644 index 0000000..7ecf098 --- /dev/null +++ b/tests/test_patch/patches/hello/quilt/series @@ -0,0 +1,4 @@ +# test comment +# this is a revert of the other 001 we applied without quilt +001.patch # first patch +002.patch diff --git a/tests/test_patch/patches/kas/001.patch b/tests/test_patch/patches/kas/001.patch new file mode 100644 index 0000000..5611099 --- /dev/null +++ b/tests/test_patch/patches/kas/001.patch @@ -0,0 +1,24 @@ +diff --git a/CHANGELOG.md b/CHANGELOG.md +index 4b594e6..f1222ab 100644 +--- a/CHANGELOG.md ++++ b/CHANGELOG.md +@@ -1,6 +1,3 @@ +-1.0 +-- isar: Take qemu-user-static from buster and adjust binfmt setup +- + 0.20.1 + - kas-docker: Restore KAS_PREMIRRORS support + +diff --git a/kas/__version__.py b/kas/__version__.py +index 0ac2731..020cb6f 100644 +--- a/kas/__version__.py ++++ b/kas/__version__.py +@@ -25,7 +25,7 @@ + __license__ = 'MIT' + __copyright__ = 'Copyright (c) Siemens AG, 2017-2018' + +-__version__ = '1.0' ++__version__ = '0.20.1' + + # Please update docs/format-changelog.rst when changing the file version. + __file_version__ = 8 diff --git a/tests/test_patch/patches/kas/quilt/001.patch b/tests/test_patch/patches/kas/quilt/001.patch new file mode 100644 index 0000000..47ed4e1 --- /dev/null +++ b/tests/test_patch/patches/kas/quilt/001.patch @@ -0,0 +1,24 @@ +diff --git a/CHANGELOG.md b/CHANGELOG.md +index f1222ab..4b594e6 100644 +--- a/CHANGELOG.md ++++ b/CHANGELOG.md +@@ -1,3 +1,6 @@ ++1.0 ++- isar: Take qemu-user-static from buster and adjust binfmt setup ++ + 0.20.1 + - kas-docker: Restore KAS_PREMIRRORS support + +diff --git a/kas/__version__.py b/kas/__version__.py +index 020cb6f..0ac2731 100644 +--- a/kas/__version__.py ++++ b/kas/__version__.py +@@ -25,7 +25,7 @@ + __license__ = 'MIT' + __copyright__ = 'Copyright (c) Siemens AG, 2017-2018' + +-__version__ = '0.20.1' ++__version__ = '1.0' + + # Please update docs/format-changelog.rst when changing the file version. + __file_version__ = 8 diff --git a/tests/test_patch/patches/kas/quilt/002.patch b/tests/test_patch/patches/kas/quilt/002.patch new file mode 100644 index 0000000..5611099 --- /dev/null +++ b/tests/test_patch/patches/kas/quilt/002.patch @@ -0,0 +1,24 @@ +diff --git a/CHANGELOG.md b/CHANGELOG.md +index 4b594e6..f1222ab 100644 +--- a/CHANGELOG.md ++++ b/CHANGELOG.md +@@ -1,6 +1,3 @@ +-1.0 +-- isar: Take qemu-user-static from buster and adjust binfmt setup +- + 0.20.1 + - kas-docker: Restore KAS_PREMIRRORS support + +diff --git a/kas/__version__.py b/kas/__version__.py +index 0ac2731..020cb6f 100644 +--- a/kas/__version__.py ++++ b/kas/__version__.py +@@ -25,7 +25,7 @@ + __license__ = 'MIT' + __copyright__ = 'Copyright (c) Siemens AG, 2017-2018' + +-__version__ = '1.0' ++__version__ = '0.20.1' + + # Please update docs/format-changelog.rst when changing the file version. + __file_version__ = 8 diff --git a/tests/test_patch/patches/kas/quilt/series b/tests/test_patch/patches/kas/quilt/series new file mode 100644 index 0000000..7ecf098 --- /dev/null +++ b/tests/test_patch/patches/kas/quilt/series @@ -0,0 +1,4 @@ +# test comment +# this is a revert of the other 001 we applied without quilt +001.patch # first patch +002.patch diff --git a/tests/test_patch/test.yml b/tests/test_patch/test.yml new file mode 100644 index 0000000..b7008e6 --- /dev/null +++ b/tests/test_patch/test.yml @@ -0,0 +1,28 @@ +header: + version: 8 + +repos: + this: + + kas: + 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: 82e55d328c8c + type: hg + patches: + plain: + repo: this + path: patches/hello/001.patch + quilt: + repo: this + path: patches/hello/quilt/