aboutsummaryrefslogtreecommitdiffstats
path: root/community/lua-busted/APKBUILD
blob: 71903a2cccd5fd6132d9c95683b106351a677bf7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=lua-busted
_pkgname=busted
pkgver=2.0.0
pkgrel=0
pkgdesc="Elegant Lua unit testing"
url="https://olivinelabs.com/busted/"
arch="noarch"
license="MIT"
# Note: We have replaced dkjson with lua-cjson.
depends="lua-cliargs lua-filesystem lua-system lua-cjson lua-say
	lua-luassert lua-term lua-penlight lua-mediator"
checkdepends=""
subpackages=""
source="$pkgname-$pkgver.tar.gz::https://github.com/Olivine-Labs/$_pkgname/archive/v$pkgver.tar.gz
	use-cjson.patch"
builddir="$srcdir/$_pkgname-$pkgver"
# tests fail on x86_64 because cl_standalone.lua output is different, i don't know why --kaniini
options="!check"

# luajit is not available for selected arches
case "$CARCH" in
	ppc64le | s390x) _luajit="";;
	*) checkdepends="$checkdepends luajit" _luajit="jit";;
esac

_luaversions="5.1 5.2 5.3"
for _v in $_luaversions; do
	subpackages="$subpackages lua$_v-${pkgname#lua-}:_subpackage"
	checkdepends="$checkdepends lua$_v"
done

prepare() {
	default_prepare || return 1

	cd "$builddir"

	local lver; for lver in $_luaversions $_luajit; do
		sed "s|/usr/bin/env lua|/usr/bin/lua$lver|" \
			bin/busted > bin/busted-$lver || return 1
	done
}

check() {
	cd "$builddir"

	mv bin/busted bin/busted.orig

	local lver; for lver in $_luaversions $_luajit; do
		# Some specs invokes bin/busted as subprocess, so we must
		# ensure that it will run on the correct Lua version.
		install -m 755 bin/busted-$lver bin/busted || return 1

		msg "Running tests on lua$lver..."
		lua$lver bin/busted spec || return 1
	done

	mv bin/busted.orig bin/busted
}

package() {
	cd "$builddir"

	# Executable with shebang `/usr/bin/env lua`.
	install -m 755 -D bin/busted "$pkgdir"/usr/bin/busted
}

_subpackage() {
	local lver="${subpkgname:3:3}"
	pkgdesc="$pkgdesc (for Lua $lver)"
	depends="lua$lver ${depends//lua-/lua$lver-}"
	install_if="$pkgname=$pkgver-r$pkgrel lua$lver"
	local destdir="$subpkgdir/usr/share/lua/$lver/$_pkgname"
	local rockdir="$subpkgdir/usr/lib/luarocks/rocks-$lver/$_pkgname/$pkgver-1"

	cd "$builddir"

	mkdir -p "$destdir"
	cp -r busted/* "$destdir" || return 1

	mkdir -p "$rockdir"
	echo 'rock_manifest = {}' > "$rockdir"/rock_manifest

	install -m 755 -D bin/busted-$lver "$subpkgdir"/usr/bin/busted-$lver
}

sha512sums="3151694b1fba1acc52e3bcfee0231008b14934e89da5885d7e063c6f023479c42040c42a8c0aa6ff1f8303ad6b2a70f0687c8a218830de7231007ef8748457bf  lua-busted-2.0.0.tar.gz
6de3c1181a391956f6ea01994960a5de3292a377be1949556eb6cd11986267e3da707decef1838f42f0236af4b25ce4ce09217abe976caa0110840b69efcab43  use-cjson.patch"