mirror of
https://github.com/gentoo-mirror/gentoo.git
synced 2026-08-24 18:58:08 -07:00
dev-lua/compat53: add 0.15.1 w/ a basic testsuite
the testsuite from upstream cannot be used as it is select a few tests for basic operations use pushd/popd Signed-off-by: Nicolas PARLANT <nicolas.parlant@parhuet.fr> Part-of: https://codeberg.org/gentoo/gentoo/pulls/1468 Merges: https://codeberg.org/gentoo/gentoo/pulls/1468 Signed-off-by: Sam James <sam@gentoo.org>
This commit is contained in:
committed by
Sam James
parent
97033a8ce2
commit
08a94ce433
@@ -1 +1,2 @@
|
||||
DIST lua-compat-5.3-0.14.4.tar.gz 61925 BLAKE2B af3032e082b77cd9e3e9f9b8bdee1feb17235b0578dd098d77e9330887623df88ebf8b3a39f72e030a0ad1144695b02261fc4c73e273a70364b93dcccd5e6b46 SHA512 0e6bd10513cab6053df7a911ba117c2dd5b5409e75bfe0890ee2ec0122893aa70fc1dc88b10a65553dd1069a038e3c7295dccc2de5c10338eccc718029d3f7b5
|
||||
DIST lua-compat-5.3-0.15.1.tar.gz 63106 BLAKE2B 82f39f74ed3dc8b609900cfb8bcc33ca0a2d3c53f70617b9bdf4b56f7a1e16519cd483afa258230e43d1f96425c16032e986987570e0b66327f90cebdd8f3b08 SHA512 6b17213321a08268228a97180e08289b85d6554b25cac89f7b7f72e79be0169af233fade87718b4a68485e0357dcb34245e660222e5c9d06254b0f3b64ef19cd
|
||||
|
||||
82
dev-lua/compat53/compat53-0.15.1.ebuild
Normal file
82
dev-lua/compat53/compat53-0.15.1.ebuild
Normal file
@@ -0,0 +1,82 @@
|
||||
# Copyright 2024-2026 Gentoo Authors
|
||||
# Distributed under the terms of the GNU General Public License v2
|
||||
|
||||
EAPI=8
|
||||
|
||||
LUA_COMPAT=( lua5-{1..4} luajit )
|
||||
inherit edo lua toolchain-funcs
|
||||
|
||||
MY_PN="lua-${PN/53/-5.3}"
|
||||
MY_P="${MY_PN}-${PV}"
|
||||
|
||||
DESCRIPTION="Compatibility module providing Lua-5.3-style APIs for Lua 5.2 and 5.1"
|
||||
HOMEPAGE="https://github.com/lunarmodules/lua-compat-5.3/"
|
||||
SRC_URI="https://github.com/lunarmodules/${MY_PN}/archive/v${PV}.tar.gz -> ${MY_P}.tar.gz"
|
||||
S="${WORKDIR}/${MY_P}"
|
||||
|
||||
LICENSE="MIT"
|
||||
SLOT="0"
|
||||
KEYWORDS="~amd64 ~arm ~arm64 ~hppa ~ppc ~ppc64 ~sparc ~x86"
|
||||
|
||||
REQUIRED_USE="${LUA_REQUIRED_USE}"
|
||||
|
||||
DEPEND="${LUA_DEPS}"
|
||||
RDEPEND="
|
||||
${DEPEND}
|
||||
!<dev-lua/luarocks-3.12.2-r1
|
||||
"
|
||||
|
||||
src_prepare() {
|
||||
default
|
||||
# change to name of compat53.'module' calls
|
||||
# this is required, see rockspecs
|
||||
mv lbitlib.c bitlib.c || die
|
||||
mv liolib.c io.c || die
|
||||
mv lstrlib.c string.c || die
|
||||
mv ltablib.c table.c || die
|
||||
mv lutf8lib.c utf8.c || die
|
||||
lua_copy_sources
|
||||
}
|
||||
|
||||
lua_src_compile() {
|
||||
pushd >/dev/null "${BUILD_DIR}" || die
|
||||
local u=""
|
||||
for u in *.c; do
|
||||
edo $(tc-getCC) -shared -fPIC \
|
||||
${CPPFLAGS} \
|
||||
${CFLAGS} $(lua_get_CFLAGS) \
|
||||
${SOFLAGS} \
|
||||
${LDFLAGS} $(lua_get_LIBS) \
|
||||
-o compat53/"${u/.c/.so}" ${u} c-api/compat-5.3.c
|
||||
done
|
||||
popd >/dev/null || die
|
||||
}
|
||||
|
||||
src_compile() {
|
||||
lua_foreach_impl lua_src_compile
|
||||
}
|
||||
|
||||
lua_src_test() {
|
||||
pushd >/dev/null "${BUILD_DIR}" || die
|
||||
${LUA} "${FILESDIR}"/basic_testsuite.lua || die
|
||||
popd >/dev/null || die
|
||||
}
|
||||
|
||||
src_test() {
|
||||
lua_foreach_impl lua_src_test
|
||||
}
|
||||
|
||||
lua_src_install() {
|
||||
pushd >/dev/null "${BUILD_DIR}"/compat53 || die
|
||||
insinto $(lua_get_lmod_dir)/${PN}
|
||||
doins *.lua
|
||||
exeinto $(lua_get_cmod_dir)/${PN}
|
||||
doexe *.so
|
||||
popd >/dev/null || die
|
||||
}
|
||||
|
||||
src_install() {
|
||||
lua_foreach_impl lua_src_install
|
||||
doheader c-api/*
|
||||
einstalldocs
|
||||
}
|
||||
72
dev-lua/compat53/files/basic_testsuite.lua
Normal file
72
dev-lua/compat53/files/basic_testsuite.lua
Normal file
@@ -0,0 +1,72 @@
|
||||
-- the use of tests/test.lua is done by comparing the output between 5.1 and 5.3
|
||||
-- it's not adapted for our case, select a few for basic operations
|
||||
|
||||
package.path = "./?.lua;./?/init.lua"
|
||||
package.cpath = "./?.so"
|
||||
|
||||
require("compat53")
|
||||
|
||||
local failures = 0
|
||||
local function test(name, f)
|
||||
print("testing " .. name .. "...")
|
||||
local ok, err = pcall(require, "compat53." .. name)
|
||||
if not ok then
|
||||
failures = failures + 1
|
||||
print("FAIL: " .. err)
|
||||
return
|
||||
end
|
||||
|
||||
ok, err = pcall(f)
|
||||
if ok then
|
||||
print(name .. "... OK")
|
||||
else
|
||||
failures = failures + 1
|
||||
print("FAIL: " .. err)
|
||||
end
|
||||
end
|
||||
|
||||
test("utf8", function()
|
||||
local unpack = table.unpack or unpack
|
||||
local function utf8rt(s)
|
||||
local t = { utf8.codepoint(s, 1, #s) }
|
||||
local ps, cs = {}, {}
|
||||
for p,c in utf8.codes(s) do
|
||||
ps[#ps+1], cs[#cs+1] = p, c
|
||||
end
|
||||
print("utf8.codes", unpack(ps))
|
||||
print("utf8.codes", unpack(cs))
|
||||
print("utf8.codepoint", unpack(t))
|
||||
print("utf8.len", utf8.len(s), #t, #s)
|
||||
print("utf8.char", utf8.char(unpack(t)))
|
||||
end
|
||||
utf8rt("äöüßÄÖÜ")
|
||||
utf8rt("abcdefg")
|
||||
local s = "äöüßÄÖÜ"
|
||||
print("utf8.offset", utf8.offset(s, 1, 1))
|
||||
print("utf8.offset", utf8.offset(s, 2, 1))
|
||||
print("utf8.offset", utf8.offset(s, 3, 1))
|
||||
print("utf8.offset", pcall(utf8.offset, s, 3, 2))
|
||||
print("utf8.offset", utf8.offset(s, 3, 3))
|
||||
print("utf8.offset", utf8.offset(s, -1, 7))
|
||||
print("utf8.offset", utf8.offset(s, -2, 7))
|
||||
print("utf8.offset", utf8.offset(s, -3, 7))
|
||||
print("utf8.offset", utf8.offset(s, -1))
|
||||
end)
|
||||
|
||||
test("string", function()
|
||||
local format = "bBhHlLjJdc3z"
|
||||
local s = string.pack(format, -128, 255, -32768, 65535, -2147483648, 4294967295, -32768, 65536, 1.25, "abc", "defgh")
|
||||
print("string.unpack", string.unpack(format, s))
|
||||
end)
|
||||
|
||||
test("table", function()
|
||||
local t = table.pack("a", nil, "b", nil)
|
||||
print("table.(un)pack()", t.n, table.unpack(t, 1, t.n))
|
||||
end)
|
||||
|
||||
if failures == 0 then
|
||||
print("tests PASSED")
|
||||
else
|
||||
print("tests FAILED (" .. failures .. " failures)")
|
||||
os.exit(1)
|
||||
end
|
||||
Reference in New Issue
Block a user