tests: simplify subpkg-dep-leak

This commit is contained in:
Natanael Copa 2021-04-30 11:11:17 +02:00
parent cf6cd0231f
commit f23cf180c9
5 changed files with 30 additions and 59 deletions

View File

@ -1,4 +1,4 @@
load helpers
#/usr/bin/env bats
setup() {
export ABUILD="$PWD/../abuild"
@ -16,10 +16,6 @@ teardown() {
rm -rf "$tmpdir"
}
build_repo() {
:
}
@test "abuild: help text" {
$ABUILD -h
}
@ -138,14 +134,36 @@ build_repo() {
}
@test "abuild: verify main package does not inherit subpackage dependencies" {
cd testrepo/subpkg-dep-leak/
mkdir -p "$tmpdir"/testrepo/subpkg-dep-leak
cd "$tmpdir"/testrepo/subpkg-dep-leak
cat > APKBUILD <<-EOF
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
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"
options="!check"
$ABUILD
package() {
mkdir -p "\$pkgdir"
}
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
subpkg() {
depends="sed"
mkdir -p "\$subpkgdir"
}
EOF
$ABUILD clean unpack prepare build rootpkg
diff main_dependencies "$WORKDIR"/actual_main_dependencies
diff subpkg_dependencies "$WORKDIR"/actual_subpkg_dependencies
false
grep 'depend = tar' pkg/.control.subpkg-dep-leak/.PKGINFO
grep 'depend = scanelf' pkg/.control.subpkg-dep-leak/.PKGINFO
! grep 'depend = sed' pkg/.control.subpkg-dep-leak/.PKGINFO
grep 'depend = sed' pkg/.control.subpkg-dep-leak-subpkg/.PKGINFO
! grep 'depend = tar' pkg/.control.subpkg-dep-leak-subpkg/.PKGINFO
}

View File

@ -1,15 +0,0 @@
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

@ -1,29 +0,0 @@
# 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

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