2022-06-15 11:31:57 +00:00
|
|
|
#!/usr/bin/env atf-sh
|
|
|
|
|
|
|
|
. $(atf_get_srcdir)/test_env.sh
|
|
|
|
init_tests \
|
|
|
|
abuild_help \
|
2022-06-15 11:34:54 +00:00
|
|
|
abuild_invalid_opt \
|
2022-06-15 12:27:04 +00:00
|
|
|
abuild_version \
|
2022-06-15 12:37:55 +00:00
|
|
|
abuild_simple_pkg_without_deps \
|
2022-06-15 15:27:53 +00:00
|
|
|
abuild_build_fail \
|
2022-06-15 16:20:34 +00:00
|
|
|
abuild_invalid_filename \
|
|
|
|
abuild_usr_lib64
|
2022-06-15 11:31:57 +00:00
|
|
|
|
|
|
|
export ABUILD_SHAREDIR=$(atf_get_srcdir)/..
|
2022-06-15 12:27:04 +00:00
|
|
|
export ABUILD_CONF=/dev/null
|
|
|
|
export GIT_CONFIG_GLOBAL="$(atf_get_srcdir)/testdata/gitconfig"
|
|
|
|
export REPODEST="$PWD"/packages
|
|
|
|
|
|
|
|
testrepo=$(atf_get_srcdir)/testrepo
|
|
|
|
|
|
|
|
# copy keys
|
|
|
|
cp -ra "$(atf_get_srcdir)"/testdata/.abuild "$PWD"
|
2022-06-15 11:31:57 +00:00
|
|
|
|
|
|
|
abuild_help_body() {
|
|
|
|
atf_check -s exit:0 \
|
|
|
|
-o match:"usage:" \
|
|
|
|
abuild -h
|
|
|
|
}
|
|
|
|
|
|
|
|
abuild_invalid_opt_body() {
|
|
|
|
atf_check -s exit:1 \
|
|
|
|
-e match:"usage:" \
|
|
|
|
abuild -@
|
|
|
|
}
|
2022-06-15 11:34:54 +00:00
|
|
|
|
|
|
|
abuild_version_body() {
|
|
|
|
atf_check -s exit:0 \
|
|
|
|
-o match:"abuild [0-9]+\.[0-9]+" \
|
|
|
|
abuild -V
|
|
|
|
}
|
|
|
|
|
2022-06-15 12:27:04 +00:00
|
|
|
abuild_simple_pkg_without_deps_body() {
|
|
|
|
cp -r "$testrepo"/pkg1 .
|
|
|
|
cd pkg1
|
|
|
|
atf_check -s exit:0 \
|
|
|
|
-e not-match:"WARNING" \
|
|
|
|
-e not-match:"fatal" \
|
|
|
|
abuild
|
|
|
|
}
|
|
|
|
|
2022-06-15 12:37:55 +00:00
|
|
|
abuild_build_fail_body() {
|
|
|
|
mkdir buildfail
|
|
|
|
cat >buildfail/APKBUILD <<-EOF
|
2022-06-15 15:27:53 +00:00
|
|
|
# Maintainer: Joe User <juser@example.com>
|
2022-06-15 12:37:55 +00:00
|
|
|
pkgname="buildfail"
|
|
|
|
pkgver="1.0"
|
|
|
|
pkgrel=0
|
|
|
|
pkgdesc="Dummy test package that fails to build"
|
|
|
|
url="https://gitlab.alpinelinux.org/alpine/aports"
|
|
|
|
arch="noarch"
|
|
|
|
license="MIT"
|
|
|
|
subpackages="\$pkgname-dev \$pkgname-doc"
|
|
|
|
source=""
|
|
|
|
prepare() {
|
|
|
|
mkdir -p "\$builddir"
|
|
|
|
}
|
|
|
|
build() {
|
|
|
|
false
|
|
|
|
}
|
|
|
|
package() {
|
|
|
|
true
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
cd buildfail
|
|
|
|
atf_check -s exit:1 \
|
|
|
|
-e match:"ERROR: buildfail: build failed" \
|
|
|
|
abuild
|
2022-06-15 15:27:53 +00:00
|
|
|
}
|
2022-06-15 12:37:55 +00:00
|
|
|
|
2022-06-15 15:27:53 +00:00
|
|
|
abuild_invalid_filename_body() {
|
|
|
|
mkdir invalid-filename
|
|
|
|
cd invalid-filename
|
|
|
|
cat >APKBUILD <<-EOF
|
|
|
|
# Maintainer: Joe User <juser@example.com>
|
|
|
|
pkgname="invalid-filename"
|
|
|
|
pkgver="1.0"
|
|
|
|
pkgrel=0
|
|
|
|
pkgdesc="Dummy test package that fails to build"
|
|
|
|
url="https://gitlab.alpinelinux.org/alpine/aports"
|
|
|
|
arch="noarch"
|
|
|
|
license="MIT"
|
|
|
|
prepare() {
|
|
|
|
mkdir -p "\$builddir"
|
|
|
|
}
|
|
|
|
build() {
|
|
|
|
touch $'bad\nfile'
|
|
|
|
}
|
|
|
|
check() {
|
|
|
|
true
|
|
|
|
}
|
|
|
|
package() {
|
|
|
|
mkdir -p "\$pkgdir"
|
|
|
|
cp -r * "\$pkgdir"/
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
atf_check -s exit:1 \
|
|
|
|
-e match:"ERROR:.*: Found filenames with newline" \
|
|
|
|
abuild
|
2022-06-15 12:37:55 +00:00
|
|
|
}
|
2022-06-15 15:27:53 +00:00
|
|
|
|
2022-06-15 16:20:34 +00:00
|
|
|
abuild_usr_lib64_body() {
|
|
|
|
mkdir lib64test
|
|
|
|
cd lib64test
|
|
|
|
cat >APKBUILD <<-EOF
|
|
|
|
# Maintainer: Joe User <juser@example.com>
|
|
|
|
pkgname="lib64test"
|
|
|
|
pkgver="1.0"
|
|
|
|
pkgrel=0
|
|
|
|
pkgdesc="Dummy test package"
|
|
|
|
url="https://gitlab.alpinelinux.org/alpine/aports"
|
|
|
|
arch="noarch"
|
|
|
|
license="MIT"
|
|
|
|
source=""
|
|
|
|
prepare() {
|
|
|
|
mkdir -p "\$builddir"
|
|
|
|
}
|
|
|
|
build() {
|
|
|
|
mkdir -p usr/lib64
|
|
|
|
}
|
|
|
|
check() {
|
|
|
|
true
|
|
|
|
}
|
|
|
|
|
|
|
|
package() {
|
|
|
|
mkdir -p "\$pkgdir"
|
|
|
|
cp -r * "\$pkgdir"/
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
atf_check -s exit:1 \
|
|
|
|
-e match:"ERROR:.*: Packages must not put anything under /usr/lib64" \
|
|
|
|
abuild
|
|
|
|
|
|
|
|
options=lib64 atf_check -s exit:0 \
|
|
|
|
-e match:"Build complete" \
|
|
|
|
abuild
|
|
|
|
}
|
|
|
|
|