Skip to content

Commit

Permalink
chore(helpers) fix for LuaJIT with 5.2 compat
Browse files Browse the repository at this point in the history
  • Loading branch information
thibaultcha committed May 18, 2018
1 parent a7b1229 commit b6fa84b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ busted:
prove:
@util/prove_ccm.sh $(CASSANDRA)
@t/reindex t/*
@prove
@prove -I.

test: busted prove

Expand Down
10 changes: 9 additions & 1 deletion spec/helpers.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
local unpack = rawget(table, "unpack") or unpack
local lua51 = _VERSION == "Lua 5.1"
local jit52 = (tostring(assert):match("builtin") ~= nil)
if jit52 then
jit52 = not loadstring("local goto = 1")
end

-- Borrowed from Penlight compat.lua
-- https://github.com/stevedonovan/Penlight/blob/master/lua/pl/compat.lua
local function exec(cmd, ignore)
local res1 = os.execute(cmd.." >/dev/null")
local ok
if _VERSION == "Lua 5.1" then
if lua51 and not jit52 then
res1 = res1 > 255 and res1 / 256 or res1
ok = res1 == 0
else
ok = not not res1
Expand Down

0 comments on commit b6fa84b

Please sign in to comment.