From 9cb6834fe07297ba79e7453978cf7e7d8d8c339a Mon Sep 17 00:00:00 2001 From: Philipp Janda Date: Mon, 18 Sep 2017 20:04:24 +0200 Subject: Add Travis-CI integration --- .travis.yml | 47 +++++++++++++++++++++++++++++++++++++++++++++++ README.md | 2 ++ tests/test.lua | 8 ++++---- tests/testmod.c | 10 +++++++--- 4 files changed, 60 insertions(+), 7 deletions(-) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..af458d8 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,47 @@ +language: c +compiler: gcc + +sudo: false + +env: + - LUA="lua=5.1" + - LUA="lua=5.1" EXTERNAL=true + - LUA="lua=5.1" COMPILER="g++" + - LUA="lua=5.1" EXTERNAL=true COMPILER="g++" + - LUA="luajit=@v2.1 --compat=none" + - LUA="luajit=@v2.1 --compat=none" EXTERNAL=true + - LUA="luajit=@v2.1 --compat=all" + - LUA="luajit=@v2.1 --compat=all" EXTERNAL=true + - LUA="lua=5.2" + - LUA="lua=5.2" EXTERNAL=true + - LUA="lua=5.2" COMPILER="g++" + - LUA="lua=5.2" EXTERNAL=true COMPILER="g++" + +branches: + only: + - master + +git: + depth: 3 + +notifications: + email: false + +before_install: + - pip install --user hererocks + - hererocks old --$LUA + - test -e old/bin/lua || (cd old/bin && ln -s luajit* lua) + - hererocks new --lua=5.3 + +install: + - export CC="${COMPILER:-gcc}" DEF="" SRC="" CFLAGS="-Wall -Wextra -Ic-api -O2 -fPIC" + - if [ "x${EXTERNAL:-}" = xtrue ]; then DEF="-DCOMPAT53_PREFIX=compat53" SRC="c-api/compat-5.3.c"; fi + - ${CC} ${CFLAGS} -Iold/include ${DEF} -shared -o old/testmod.so tests/testmod.c ${SRC} + - ${CC} ${CFLAGS} -Inew/include ${DEF} -shared -o new/testmod.so tests/testmod.c ${SRC} + - gcc ${CFLAGS} -Iold/include ${DEF} -shared -o old/compat53.so ltablib.c lutf8lib.c lstrlib.c ${SRC} + +script: + - (cd old && bin/lua ../tests/test.lua) > old.txt + - (cd new && bin/lua ../tests/test.lua) > new.txt + - diff old.txt new.txt || true + diff --git a/README.md b/README.md index 84ce918..b986584 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +[![Build Status](https://travis-ci.org/keplerproject/lua-compat-5.3.svg?branch=master)](https://travis-ci.org/keplerproject/lua-compat-5.3) + # lua-compat-5.3 Lua-5.3-style APIs for Lua 5.2 and 5.1. diff --git a/tests/test.lua b/tests/test.lua index 8fafdf3..2f6c7f6 100755 --- a/tests/test.lua +++ b/tests/test.lua @@ -40,7 +40,7 @@ local mode = "global" if arg[1] == "module" then mode = "module" end - +local self = arg[0] package.path = "../?.lua;../?/init.lua" package.cpath = "./?-"..V..".so;./?-"..V..".dll;./?.so;./?.dll" @@ -603,11 +603,11 @@ end ___'' do writefile("data.txt", "123 18.8 hello world\ni'm here\n") - for a,b in io.lines("test.lua", 2, "*l") do + for a,b in io.lines(self, 2, "*l") do print("io.lines()", a, b) break end - for l in io.lines("test.lua") do + for l in io.lines(self) do print("io.lines()", l) break end @@ -624,7 +624,7 @@ do for l in io.lines("no_such_file.txt") do print(l) end end)) if mode ~= "module" then - local f = assert(io.open("test.lua", "r")) + local f = assert(io.open(self, "r")) for a,b in f:lines(2, "*l") do print("file:lines()", a, b) break diff --git a/tests/testmod.c b/tests/testmod.c index 1034d20..a0d2e2a 100644 --- a/tests/testmod.c +++ b/tests/testmod.c @@ -1,7 +1,5 @@ #include #include -#include -#include #include "compat-5.3.h" @@ -12,7 +10,7 @@ static int test_isinteger (lua_State *L) { static int test_rotate (lua_State *L) { - int r = luaL_checkint(L, 1); + int r = (int)luaL_checkinteger(L, 1); int n = lua_gettop(L)-1; luaL_argcheck(L, (r < 0 ? -r : r) <= n, 1, "not enough arguments"); lua_rotate(L, 2, r); @@ -336,6 +334,9 @@ static const luaL_Reg more_funcs[] = { }; +#ifdef __cplusplus +extern "C" { +#endif int luaopen_testmod (lua_State *L) { int i = 1; luaL_newlib(L, funcs); @@ -344,4 +345,7 @@ int luaopen_testmod (lua_State *L) { luaL_setfuncs(L, more_funcs, NUP); return 1; } +#ifdef __cplusplus +} +#endif -- cgit v1.2.3-55-g6feb