From 43fb2c012e4c8a6394e9177e48999bde4de1846a Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Thu, 7 Nov 2019 11:01:18 +0000 Subject: [PATCH] add basic tests using bats --- .gitignore | 2 ++ Makefile | 3 +++ tests/abuild.bats | 11 +++++++++++ tests/testrepo/pkg1/APKBUILD | 34 ++++++++++++++++++++++++++++++++++ 4 files changed, 50 insertions(+) create mode 100644 tests/abuild.bats create mode 100644 tests/testrepo/pkg1/APKBUILD diff --git a/.gitignore b/.gitignore index 64fc62f..a16fa23 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,5 @@ checkapk devbuild functions.sh newapkbuild +src +pkg diff --git a/Makefile b/Makefile index 9206787..3e95f81 100644 --- a/Makefile +++ b/Makefile @@ -93,6 +93,9 @@ help: @echo "$(P) makefile" @echo "usage: make install [ DESTDIR= ]" +check: $(USR_BIN_FILE) functions.sh + cd tests && bats *.bats + install: $(USR_BIN_FILES) $(SAMPLES) abuild.conf functions.sh install -d $(DESTDIR)/$(bindir) $(DESTDIR)/$(sysconfdir) \ $(DESTDIR)/$(datadir) $(DESTDIR)/$(mandir)/man1 \ diff --git a/tests/abuild.bats b/tests/abuild.bats new file mode 100644 index 0000000..159762d --- /dev/null +++ b/tests/abuild.bats @@ -0,0 +1,11 @@ +setup() { + export ABUILD=../abuild +} + +@test "help text" { + $ABUILD -h +} + +@test "version string" { + $ABUILD -V +} diff --git a/tests/testrepo/pkg1/APKBUILD b/tests/testrepo/pkg1/APKBUILD new file mode 100644 index 0000000..a87d7d0 --- /dev/null +++ b/tests/testrepo/pkg1/APKBUILD @@ -0,0 +1,34 @@ +# Maintainer: Natanael Copa + +# test package +pkgname="pkg1" +pkgver="1.0" +pkgrel=0 +pkgdesc="Dummy test package" +url="https://gitlab.alpinelinux.org/alpine/aports" +arch="noarch" +license="MIT" +subpackages="$pkgname-dev $pkgname-doc" +source="" +builddir="$srcdir/pkg1-1.0" + +prepare() { + mkdir -p "$builddir" +} + +build() { + mkdir -p usr/include usr/bin usr/share/man/man1 + touch usr/include/$pkgname.h + touch usr/bin/$pkgname + touch usr/share/man/man1/$pkgname.1 +} + +check() { + true +} + +package() { + mkdir -p "$pkgdir" + cp -r * "$pkgdir"/ +} +