tests: verify subpkg dependencies don't influence main package

Subpackages can declare their own dependencies, but these should not
affect the main package.

Add a test that verifies this behaviour.
This commit is contained in:
Kevin Daudt 2021-01-11 21:54:56 +01:00 committed by Natanael Copa
parent 2ffb1294b1
commit cf6cd0231f
5 changed files with 69 additions and 1 deletions

View File

@ -1,17 +1,25 @@
load helpers
setup() {
export ABUILD="$PWD/../abuild"
export ABUILD_SHAREDIR="$PWD/.."
export ABUILD_CONF=/dev/null
tmpdir="$BATS_TMPDIR"/abuild
export REPODEST="$tmpdir"/packages
mkdir -p $tmpdir
export CLEANUP="srcdir bldroot pkgdir deps"
export WORKDIR="$tmpdir"/work
mkdir -p "$tmpdir" "$WORKDIR"
}
teardown() {
rm -rf "$tmpdir"
}
build_repo() {
:
}
@test "abuild: help text" {
$ABUILD -h
}
@ -128,3 +136,16 @@ teardown() {
run $ABUILD sanitycheck
[[ $output[1] == *WARNING*dbg* ]]
}
@test "abuild: verify main package does not inherit subpackage dependencies" {
cd testrepo/subpkg-dep-leak/
$ABUILD
pkg_field subpkg-dep-leak-1.0-r0 depend >"$WORKDIR"/actual_main_dependencies
pkg_field subpkg-dep-leak-subpkg-1.0-r0 depend >"$WORKDIR"/actual_subpkg_dependencies
diff main_dependencies "$WORKDIR"/actual_main_dependencies
diff subpkg_dependencies "$WORKDIR"/actual_subpkg_dependencies
false
}

15
tests/helpers.bash Normal file
View File

@ -0,0 +1,15 @@
pkg_field() {
local pkg=$1
local field=$2
tar xzf "$REPODEST"/testrepo/"$(arch)"/"$pkg".apk -O .PKGINFO |
awk "/^$field =/ { print \$3 }" |
sort
}
has_dependency() {
local pkg=$1
local dependency=$2
pkg_field "$pkg" depend | grep -qx "$dependency"
}

View File

@ -0,0 +1,29 @@
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
# test package
pkgname="subpkg-dep-leak"
pkgver="1.0"
pkgrel=0
pkgdesc="Dummy test package with subpackages and dependencies"
url="https://gitlab.alpinelinux.org/alpine/aports"
arch="noarch"
depends="tar scanelf"
license="MIT"
subpackages="$pkgname-subpkg"
prepare() {
mkdir -p "$builddir"
}
check() {
true
}
package() {
mkdir -p "$pkgdir"
}
subpkg() {
depends="sed"
mkdir -p "$subpkgdir"
}

View File

@ -0,0 +1,2 @@
scanelf
tar

View File

@ -0,0 +1 @@
sed