Skip to content

Commit

Permalink
repl cov
Browse files Browse the repository at this point in the history
  • Loading branch information
zeroflag committed Feb 27, 2025
1 parent 325e92f commit 713a591
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 4 deletions.
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ test:
@echo "$(GREEN)All tests passed!$(NC)"

coverage:
export ENABLE_COV="true"; \
$(MAKE) -s test coverage="true" || exit 1; \

version:
Expand All @@ -89,7 +90,11 @@ bundle:
sed -i "s/^__VERSION__=.*$$/__VERSION__=\"$${version}\"/" $(BUNDLE); \

repl:
@lua $(EQUINOX)
@if [ "$$coverage" = "true" ]; then \
lua -lluacov $(EQUINOX); \
else \
lua $(EQUINOX); \
fi ; \

rockspec:
@$(GET_VERSION) ; \
Expand Down
7 changes: 6 additions & 1 deletion src/equinox_bundle.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3223,11 +3223,16 @@ function utils.startswith(str, prefix)
return string.sub(str, 1, #prefix) == prefix
end

function utils.module_available(name)
local ok, _ = pcall(require, name)
return ok
end

return utils
end
end

__VERSION__="0.1-378"
__VERSION__="0.1-391"

local Compiler = require("compiler")
local Optimizer = require("ast_optimizer")
Expand Down
5 changes: 5 additions & 0 deletions src/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,9 @@ function utils.startswith(str, prefix)
return string.sub(str, 1, #prefix) == prefix
end

function utils.module_available(name)
local ok, _ = pcall(require, name)
return ok
end

return utils
2 changes: 1 addition & 1 deletion src/version/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1-378
0.1-391
14 changes: 13 additions & 1 deletion tests/test_smoke.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
local command = 'echo "7 3 * dup + .\nbye" | make repl | grep "OK"'
local utils = require("utils")

local coverage = "false"
if os.getenv("ENABLE_COV") and
utils.module_available("luacov")
then
coverage = "true"
end

local command = string.format(
'echo "7 3 * dup + .\nbye" | make repl coverage="%s" | grep "OK"',
coverage
)

local handle = io.popen(command)
local result = handle:read("*a")
Expand Down

0 comments on commit 713a591

Please sign in to comment.