-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
And provide a Makefile to generate the test data from gentoo.git. Signed-off-by: Matt Turner <[email protected]>
- Loading branch information
Showing
17 changed files
with
681 additions
and
0 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
pym/gentoolkit/merge_driver_ekeyword/test_merge_driver_ekeyword.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/usr/bin/python | ||
# Copyright 2024 Gentoo Authors | ||
# Distributed under the terms of the GNU General Public License v2 | ||
|
||
"""Unittests for merge_driver_ekeyword""" | ||
|
||
import itertools | ||
import os | ||
import pathlib | ||
import pytest | ||
import shutil | ||
import tempfile | ||
|
||
from gentoolkit.merge_driver_ekeyword import merge_driver_ekeyword | ||
|
||
|
||
TESTDIR = pathlib.Path(__file__).parent / "tests" | ||
TESTDIRS = [os.path.dirname(x) for x in TESTDIR.rglob("common-ancestor.ebuild")] | ||
TESTDATA = itertools.product(TESTDIRS, (False, True)) | ||
|
||
|
||
def file_contents(filename): | ||
with open(filename) as file: | ||
return file.readlines() | ||
|
||
|
||
@pytest.mark.parametrize("testdir,reverse", TESTDATA) | ||
def test_merge(testdir, reverse): | ||
with tempfile.TemporaryDirectory() as tmpdir: | ||
shutil.copytree(testdir, tmpdir, dirs_exist_ok=True) | ||
|
||
O = os.path.join(tmpdir, "common-ancestor.ebuild") | ||
if reverse: | ||
A = os.path.join(tmpdir, "B.ebuild") | ||
B = os.path.join(tmpdir, "A.ebuild") | ||
else: | ||
A = os.path.join(tmpdir, "A.ebuild") | ||
B = os.path.join(tmpdir, "B.ebuild") | ||
P = "expected.ebuild" | ||
expected = os.path.join(tmpdir, P) | ||
|
||
# A.ebuild and B.ebuild can be merged iff expected.ebuild exists. | ||
if os.path.exists(expected): | ||
assert 0 == merge_driver_ekeyword.main([O, A, B, P]) | ||
assert file_contents(expected) == file_contents(A) | ||
else: | ||
assert -1 == merge_driver_ekeyword.merge_keywords(O, A, B, P) | ||
assert -1 == merge_driver_ekeyword.merge_keywords(O, B, A, P) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
TESTS = \ | ||
single-KEYWORDS-conflict \ | ||
multiple-KEYWORDS-conflict \ | ||
conflict-near-KEYWORDS \ | ||
non-KEYWORDS-conflict \ | ||
$(NULL) | ||
|
||
.PHONY: $(TESTS) | ||
|
||
all: $(TESTS) | ||
|
||
GENTOO-is-set: | ||
@if [ -z "$(GENTOO)" ]; then \ | ||
echo GENTOO must be set to the path to gentoo.git; \ | ||
exit 1; \ | ||
fi | ||
|
||
single-KEYWORDS-conflict: GENTOO-is-set | ||
mkdir -p $@ | ||
git -C "$(GENTOO)" show 27aaf96d86ce53c80c967130a31cf0bec5a07c27:x11-apps/xconsole/xconsole-1.1.0.ebuild > $@/common-ancestor.ebuild | ||
sed -e 's/~arm ~arm64/arm ~arm64/' $@/common-ancestor.ebuild > $@/A.ebuild | ||
sed -e 's/~arm ~arm64/~arm arm64/' $@/common-ancestor.ebuild > $@/B.ebuild | ||
sed -e 's/~arm ~arm64/arm arm64/' $@/common-ancestor.ebuild > $@/expected.ebuild | ||
|
||
multiple-KEYWORDS-conflict: GENTOO-is-set | ||
mkdir -p $@ | ||
git -C "$(GENTOO)" show 27aaf96d86ce53c80c967130a31cf0bec5a07c27:x11-apps/xconsole/xconsole-1.1.0.ebuild > $@/common-ancestor.ebuild | ||
sed -e 's/~arm64/arm64/' -e 's/~ppc64/ppc64/' $@/common-ancestor.ebuild > $@/A.ebuild | ||
sed -e 's/~amd64/amd64/' -e 's/~sparc/sparc/' $@/common-ancestor.ebuild > $@/B.ebuild | ||
sed -e 's/~arm64/arm64/' -e 's/~ppc64/ppc64/' -e 's/~amd64/amd64/' -e 's/~sparc/sparc/' $@/common-ancestor.ebuild > $@/expected.ebuild | ||
|
||
conflict-near-KEYWORDS: GENTOO-is-set | ||
mkdir -p $@ | ||
git -C "$(GENTOO)" show 128496a4717fb4085ea09066b92f53ae47e0341a:sys-fs/squashfs-tools-ng/squashfs-tools-ng-1.3.0.ebuild > $@/common-ancestor.ebuild | ||
git -C "$(GENTOO)" show 2c5cd6c4e004dc5037761c4a7a64fe956cac4bc4:sys-fs/squashfs-tools-ng/squashfs-tools-ng-1.3.0.ebuild > $@/A.ebuild | ||
git -C "$(GENTOO)" show 84e655a1f462a58154b701b9b8077ebf3071e82f:sys-fs/squashfs-tools-ng/squashfs-tools-ng-1.3.0.ebuild > $@/B.ebuild | ||
git -C "$(GENTOO)" show 7579afbd4aa1f2356b8de3c2870df2c49ab68d5f:sys-fs/squashfs-tools-ng/squashfs-tools-ng-1.3.0.ebuild > $@/expected.ebuild | ||
|
||
non-KEYWORDS-conflict: GENTOO-is-set | ||
mkdir -p $@ | ||
git -C "$(GENTOO)" show f1689f39c7bc6245f7f4fc8083d41bc82f4621d9:media-gfx/eog-plugins/eog-plugins-44.0-r2.ebuild > $@/common-ancestor.ebuild | ||
sed -e 's/{9..11}/{9..12}/' $@/common-ancestor.ebuild > $@/A.ebuild | ||
sed -e 's/{9..11}/{10..11}/' $@/common-ancestor.ebuild > $@/B.ebuild | ||
# No expected.ebuild |
52 changes: 52 additions & 0 deletions
52
pym/gentoolkit/merge_driver_ekeyword/tests/conflict-near-KEYWORDS/A.ebuild
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Copyright 2019-2024 Gentoo Authors | ||
# Distributed under the terms of the GNU General Public License v2 | ||
|
||
EAPI=8 | ||
|
||
DESCRIPTION="A new set of tools for working with SquashFS images" | ||
HOMEPAGE="https://github.com/AgentD/squashfs-tools-ng" | ||
if [[ ${PV} = 9999* ]]; then | ||
inherit autotools git-r3 | ||
EGIT_REPO_URI="https://github.com/AgentD/${PN}.git" | ||
else | ||
KEYWORDS="~alpha amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86" | ||
SRC_URI="https://infraroot.at/pub/squashfs/${P}.tar.xz" | ||
fi | ||
|
||
LICENSE="LGPL-3+ BSD-2 MIT tools? ( GPL-3+ )" | ||
SLOT="0" | ||
IUSE="lz4 +lzma lzo selinux +tools zstd" | ||
|
||
DEPEND=" | ||
app-arch/bzip2:= | ||
sys-libs/zlib:= | ||
lz4? ( app-arch/lz4:= ) | ||
lzma? ( app-arch/xz-utils ) | ||
lzo? ( dev-libs/lzo:2 ) | ||
selinux? ( sys-libs/libselinux:= ) | ||
zstd? ( app-arch/zstd:= ) | ||
" | ||
RDEPEND="${DEPEND}" | ||
|
||
src_prepare() { | ||
default | ||
[[ ${PV} == "9999" ]] && eautoreconf | ||
} | ||
|
||
src_configure() { | ||
local myconf=( | ||
--disable-static | ||
$(use_with lz4) | ||
$(use_with lzo) | ||
$(use_with selinux) | ||
$(use_with tools) | ||
$(use_with lzma xz) | ||
$(use_with zstd) | ||
) | ||
econf "${myconf[@]}" | ||
} | ||
|
||
src_install() { | ||
default | ||
find "${D}" -name "*.la" -delete || die | ||
} |
57 changes: 57 additions & 0 deletions
57
pym/gentoolkit/merge_driver_ekeyword/tests/conflict-near-KEYWORDS/B.ebuild
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Copyright 2019-2024 Gentoo Authors | ||
# Distributed under the terms of the GNU General Public License v2 | ||
|
||
EAPI=8 | ||
|
||
DESCRIPTION="A new set of tools for working with SquashFS images" | ||
HOMEPAGE="https://github.com/AgentD/squashfs-tools-ng" | ||
if [[ ${PV} = 9999* ]]; then | ||
inherit autotools git-r3 | ||
EGIT_REPO_URI="https://github.com/AgentD/${PN}.git" | ||
else | ||
inherit libtool | ||
KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86" | ||
SRC_URI="https://infraroot.at/pub/squashfs/${P}.tar.xz" | ||
fi | ||
|
||
LICENSE="LGPL-3+ BSD-2 MIT tools? ( GPL-3+ )" | ||
SLOT="0" | ||
IUSE="lz4 +lzma lzo selinux +tools zstd" | ||
|
||
DEPEND=" | ||
app-arch/bzip2:= | ||
sys-libs/zlib:= | ||
lz4? ( app-arch/lz4:= ) | ||
lzma? ( app-arch/xz-utils ) | ||
lzo? ( dev-libs/lzo:2 ) | ||
selinux? ( sys-libs/libselinux:= ) | ||
zstd? ( app-arch/zstd:= ) | ||
" | ||
RDEPEND="${DEPEND}" | ||
|
||
src_prepare() { | ||
default | ||
if [[ ${PV} = "9999" ]]; then | ||
eautoreconf | ||
else | ||
elibtoolize | ||
fi | ||
} | ||
|
||
src_configure() { | ||
local myconf=( | ||
--disable-static | ||
$(use_with lz4) | ||
$(use_with lzo) | ||
$(use_with selinux) | ||
$(use_with tools) | ||
$(use_with lzma xz) | ||
$(use_with zstd) | ||
) | ||
econf "${myconf[@]}" | ||
} | ||
|
||
src_install() { | ||
default | ||
find "${D}" -name "*.la" -delete || die | ||
} |
52 changes: 52 additions & 0 deletions
52
pym/gentoolkit/merge_driver_ekeyword/tests/conflict-near-KEYWORDS/common-ancestor.ebuild
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Copyright 2019-2024 Gentoo Authors | ||
# Distributed under the terms of the GNU General Public License v2 | ||
|
||
EAPI=8 | ||
|
||
DESCRIPTION="A new set of tools for working with SquashFS images" | ||
HOMEPAGE="https://github.com/AgentD/squashfs-tools-ng" | ||
if [[ ${PV} = 9999* ]]; then | ||
inherit autotools git-r3 | ||
EGIT_REPO_URI="https://github.com/AgentD/${PN}.git" | ||
else | ||
KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86" | ||
SRC_URI="https://infraroot.at/pub/squashfs/${P}.tar.xz" | ||
fi | ||
|
||
LICENSE="LGPL-3+ BSD-2 MIT tools? ( GPL-3+ )" | ||
SLOT="0" | ||
IUSE="lz4 +lzma lzo selinux +tools zstd" | ||
|
||
DEPEND=" | ||
app-arch/bzip2:= | ||
sys-libs/zlib:= | ||
lz4? ( app-arch/lz4:= ) | ||
lzma? ( app-arch/xz-utils ) | ||
lzo? ( dev-libs/lzo:2 ) | ||
selinux? ( sys-libs/libselinux:= ) | ||
zstd? ( app-arch/zstd:= ) | ||
" | ||
RDEPEND="${DEPEND}" | ||
|
||
src_prepare() { | ||
default | ||
[[ ${PV} == "9999" ]] && eautoreconf | ||
} | ||
|
||
src_configure() { | ||
local myconf=( | ||
--disable-static | ||
$(use_with lz4) | ||
$(use_with lzo) | ||
$(use_with selinux) | ||
$(use_with tools) | ||
$(use_with lzma xz) | ||
$(use_with zstd) | ||
) | ||
econf "${myconf[@]}" | ||
} | ||
|
||
src_install() { | ||
default | ||
find "${D}" -name "*.la" -delete || die | ||
} |
57 changes: 57 additions & 0 deletions
57
pym/gentoolkit/merge_driver_ekeyword/tests/conflict-near-KEYWORDS/expected.ebuild
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Copyright 2019-2024 Gentoo Authors | ||
# Distributed under the terms of the GNU General Public License v2 | ||
|
||
EAPI=8 | ||
|
||
DESCRIPTION="A new set of tools for working with SquashFS images" | ||
HOMEPAGE="https://github.com/AgentD/squashfs-tools-ng" | ||
if [[ ${PV} = 9999* ]]; then | ||
inherit autotools git-r3 | ||
EGIT_REPO_URI="https://github.com/AgentD/${PN}.git" | ||
else | ||
inherit libtool | ||
KEYWORDS="~alpha amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86" | ||
SRC_URI="https://infraroot.at/pub/squashfs/${P}.tar.xz" | ||
fi | ||
|
||
LICENSE="LGPL-3+ BSD-2 MIT tools? ( GPL-3+ )" | ||
SLOT="0" | ||
IUSE="lz4 +lzma lzo selinux +tools zstd" | ||
|
||
DEPEND=" | ||
app-arch/bzip2:= | ||
sys-libs/zlib:= | ||
lz4? ( app-arch/lz4:= ) | ||
lzma? ( app-arch/xz-utils ) | ||
lzo? ( dev-libs/lzo:2 ) | ||
selinux? ( sys-libs/libselinux:= ) | ||
zstd? ( app-arch/zstd:= ) | ||
" | ||
RDEPEND="${DEPEND}" | ||
|
||
src_prepare() { | ||
default | ||
if [[ ${PV} = "9999" ]]; then | ||
eautoreconf | ||
else | ||
elibtoolize | ||
fi | ||
} | ||
|
||
src_configure() { | ||
local myconf=( | ||
--disable-static | ||
$(use_with lz4) | ||
$(use_with lzo) | ||
$(use_with selinux) | ||
$(use_with tools) | ||
$(use_with lzma xz) | ||
$(use_with zstd) | ||
) | ||
econf "${myconf[@]}" | ||
} | ||
|
||
src_install() { | ||
default | ||
find "${D}" -name "*.la" -delete || die | ||
} |
19 changes: 19 additions & 0 deletions
19
pym/gentoolkit/merge_driver_ekeyword/tests/multiple-KEYWORDS-conflict/A.ebuild
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Copyright 1999-2024 Gentoo Authors | ||
# Distributed under the terms of the GNU General Public License v2 | ||
|
||
EAPI=8 | ||
|
||
XORG_TARBALL_SUFFIX="xz" | ||
inherit xorg-3 | ||
|
||
DESCRIPTION="monitor system console messages with X" | ||
|
||
KEYWORDS="~alpha ~amd64 ~arm arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ppc64 ~riscv ~s390 ~sparc ~x86" | ||
|
||
RDEPEND=" | ||
x11-libs/libXaw | ||
x11-libs/libXmu | ||
x11-libs/libXt | ||
x11-libs/libX11" | ||
DEPEND="${RDEPEND} | ||
x11-base/xorg-proto" |
19 changes: 19 additions & 0 deletions
19
pym/gentoolkit/merge_driver_ekeyword/tests/multiple-KEYWORDS-conflict/B.ebuild
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Copyright 1999-2024 Gentoo Authors | ||
# Distributed under the terms of the GNU General Public License v2 | ||
|
||
EAPI=8 | ||
|
||
XORG_TARBALL_SUFFIX="xz" | ||
inherit xorg-3 | ||
|
||
DESCRIPTION="monitor system console messages with X" | ||
|
||
KEYWORDS="~alpha amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 sparc ~x86" | ||
|
||
RDEPEND=" | ||
x11-libs/libXaw | ||
x11-libs/libXmu | ||
x11-libs/libXt | ||
x11-libs/libX11" | ||
DEPEND="${RDEPEND} | ||
x11-base/xorg-proto" |
19 changes: 19 additions & 0 deletions
19
pym/gentoolkit/merge_driver_ekeyword/tests/multiple-KEYWORDS-conflict/common-ancestor.ebuild
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Copyright 1999-2024 Gentoo Authors | ||
# Distributed under the terms of the GNU General Public License v2 | ||
|
||
EAPI=8 | ||
|
||
XORG_TARBALL_SUFFIX="xz" | ||
inherit xorg-3 | ||
|
||
DESCRIPTION="monitor system console messages with X" | ||
|
||
KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86" | ||
|
||
RDEPEND=" | ||
x11-libs/libXaw | ||
x11-libs/libXmu | ||
x11-libs/libXt | ||
x11-libs/libX11" | ||
DEPEND="${RDEPEND} | ||
x11-base/xorg-proto" |
19 changes: 19 additions & 0 deletions
19
pym/gentoolkit/merge_driver_ekeyword/tests/multiple-KEYWORDS-conflict/expected.ebuild
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Copyright 1999-2024 Gentoo Authors | ||
# Distributed under the terms of the GNU General Public License v2 | ||
|
||
EAPI=8 | ||
|
||
XORG_TARBALL_SUFFIX="xz" | ||
inherit xorg-3 | ||
|
||
DESCRIPTION="monitor system console messages with X" | ||
|
||
KEYWORDS="~alpha amd64 ~arm arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ppc64 ~riscv ~s390 sparc ~x86" | ||
|
||
RDEPEND=" | ||
x11-libs/libXaw | ||
x11-libs/libXmu | ||
x11-libs/libXt | ||
x11-libs/libX11" | ||
DEPEND="${RDEPEND} | ||
x11-base/xorg-proto" |
Oops, something went wrong.