From e42af1b049af653ef29add81a81f96cd08a7d1d4 Mon Sep 17 00:00:00 2001 From: Jakub Jirutka Date: Sun, 12 Mar 2017 22:11:01 +0100 Subject: community/lua-busted: move from testing --- community/lua-busted/APKBUILD | 82 ++++++++++++++++++++++++++++++++ community/lua-busted/fix-tests.patch | 92 ++++++++++++++++++++++++++++++++++++ community/lua-busted/use-cjson.patch | 8 ++++ 3 files changed, 182 insertions(+) create mode 100644 community/lua-busted/APKBUILD create mode 100644 community/lua-busted/fix-tests.patch create mode 100644 community/lua-busted/use-cjson.patch (limited to 'community/lua-busted') diff --git a/community/lua-busted/APKBUILD b/community/lua-busted/APKBUILD new file mode 100644 index 0000000000..dd6e7f1289 --- /dev/null +++ b/community/lua-busted/APKBUILD @@ -0,0 +1,82 @@ +# Contributor: Jakub Jirutka +# Maintainer: Jakub Jirutka +pkgname=lua-busted +_pkgname=busted +pkgver=2.0_rc12 +_pkgver=${pkgver/_/.}-1 +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="luajit" +subpackages="" +source="$pkgname-$pkgver.tar.gz::https://github.com/Olivine-Labs/$_pkgname/archive/v$_pkgver.tar.gz + fix-tests.patch + 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" + +_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 jit; 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 jit; 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" + + cd "$builddir" + + mkdir -p "$destdir" + cp -r busted/* "$destdir" || return 1 + + install -m 755 -D bin/busted-$lver "$subpkgdir"/usr/bin/busted-$lver +} + +sha512sums="0cb1f6a66110514dc3675b2e667cca676e6672e895b57ffba438e89a1e0a7f4f8f941cab54ead905758987be15e9885e1eeb82baabc9d18bf29ea56b832b89b1 lua-busted-2.0_rc12.tar.gz +c4ec5de43d76da18a7c723744d2930fc78224fe151fd80c141dbb08dce9f10ee94335684a794ad35c902285f40234899e0b12d1995825cb3d250c29ed82bdeec fix-tests.patch +6de3c1181a391956f6ea01994960a5de3292a377be1949556eb6cd11986267e3da707decef1838f42f0236af4b25ce4ce09217abe976caa0110840b69efcab43 use-cjson.patch" diff --git a/community/lua-busted/fix-tests.patch b/community/lua-busted/fix-tests.patch new file mode 100644 index 0000000000..365c9c48ce --- /dev/null +++ b/community/lua-busted/fix-tests.patch @@ -0,0 +1,92 @@ +From ed3f70805ac0e30bf14f6a5850e873329f5e337c Mon Sep 17 00:00:00 2001 +From: Oscar Lim +Date: Mon, 29 Aug 2016 11:54:59 -0700 +Subject: [PATCH] Fix failing tests after penlight upgrade + +This fixes failing unit tests after upgrading `penlight`. Apparently, +the new version of `penlight` uses `pl.List` internally when traversing +a directory. Hence, we cannot use `pl.List` in any of the insulation +tests. + +Alpine notes: + This patch is backported from upstream. +--- + spec/insulate-expose_spec.lua | 24 ++++++++++++------------ + 1 file changed, 12 insertions(+), 12 deletions(-) + +diff --git a/spec/insulate-expose_spec.lua b/spec/insulate-expose_spec.lua +index 0409a3d..bba84bd 100644 +--- a/spec/insulate-expose_spec.lua ++++ b/spec/insulate-expose_spec.lua +@@ -13,9 +13,9 @@ describe('Tests insulation', function() + + it('updates package.loaded', function() + assert.is_not_nil(pl) +- assert.is_not_nil(List) ++ assert.is_not_nil(Date) + assert.is_not_nil(package.loaded.pl) +- assert.is_not_nil(package.loaded['pl.List']) ++ assert.is_not_nil(package.loaded['pl.Date']) + end) + end) + +@@ -27,9 +27,9 @@ describe('Tests insulation', function() + + it('restores package.loaded', function() + assert.is_nil(pl) +- assert.is_nil(List) ++ assert.is_nil(Date) + assert.is_nil(package.loaded.pl) +- assert.is_nil(package.loaded['pl.List']) ++ assert.is_nil(package.loaded['pl.Date']) + end) + end) + end) +@@ -54,9 +54,9 @@ insulate('', function() + + it('updates package.loaded', function() + assert.is_not_nil(pl) +- assert.is_not_nil(List) ++ assert.is_not_nil(Date) + assert.is_not_nil(package.loaded.pl) +- assert.is_not_nil(package.loaded['pl.List']) ++ assert.is_not_nil(package.loaded['pl.Date']) + end) + end) + end) +@@ -74,9 +74,9 @@ insulate('', function() + + it('does not restore package.loaded', function() + assert.is_not_nil(pl) +- assert.is_not_nil(List) ++ assert.is_not_nil(Date) + assert.is_not_nil(package.loaded.pl) +- assert.is_not_nil(package.loaded['pl.List']) ++ assert.is_not_nil(package.loaded['pl.Date']) + end) + end) + end) +@@ -93,9 +93,9 @@ insulate('', function() + end) + + it('Tests package.loaded persists without insulate', function() +- assert.is_not_nil(List) ++ assert.is_not_nil(Date) + assert.is_not_nil(package.loaded.pl) +- assert.is_not_nil(package.loaded['pl.List']) ++ assert.is_not_nil(package.loaded['pl.Date']) + end) + end) + +@@ -107,9 +107,9 @@ describe('Tests after insulating an expose block', function() + + it('restores package.loaded', function() + assert.is_nil(pl) +- assert.is_nil(List) ++ assert.is_nil(Date) + assert.is_nil(package.loaded.pl) +- assert.is_nil(package.loaded['pl.List']) ++ assert.is_nil(package.loaded['pl.Date']) + end) + end) + diff --git a/community/lua-busted/use-cjson.patch b/community/lua-busted/use-cjson.patch new file mode 100644 index 0000000000..eba3d23c28 --- /dev/null +++ b/community/lua-busted/use-cjson.patch @@ -0,0 +1,8 @@ +--- a/busted/outputHandlers/json.lua ++++ b/busted/outputHandlers/json.lua +@@ -1,4 +1,4 @@ +-local json = require 'dkjson' ++local json = require 'cjson' + + return function(options) + local busted = require 'busted' -- cgit v1.2.3