made default
This commit is contained in:
@@ -1,16 +1,13 @@
|
||||
package.path = package.path .. ";./?.lua;./game/?.lua;./game/utils/?.lua;./game/components/?.lua;./game/systems/?.lua"
|
||||
|
||||
-- Enable code coverage tracking BEFORE loading any modules
|
||||
local coverage_enabled = os.getenv("COVERAGE") == "1"
|
||||
if coverage_enabled then
|
||||
local status, luacov = pcall(require, "luacov")
|
||||
if status then
|
||||
-- Always enable code coverage tracking BEFORE loading any modules
|
||||
local status, luacov = pcall(require, "luacov")
|
||||
if status then
|
||||
print("========================================")
|
||||
print("Code coverage tracking enabled")
|
||||
print("========================================")
|
||||
else
|
||||
else
|
||||
print("Warning: luacov not found, coverage tracking disabled")
|
||||
end
|
||||
end
|
||||
|
||||
-- Set global flag to prevent individual test files from running luaunit
|
||||
@@ -52,4 +49,36 @@ print("All tests completed")
|
||||
print("========================================")
|
||||
|
||||
local result = luaunit.LuaUnit.run()
|
||||
|
||||
-- Generate and display coverage report
|
||||
if status then
|
||||
print("\n========================================")
|
||||
print("Generating coverage report...")
|
||||
print("========================================")
|
||||
|
||||
-- Save coverage stats
|
||||
luacov.save_stats()
|
||||
|
||||
-- Run luacov command to generate report (silent)
|
||||
os.execute("luacov 2>/dev/null")
|
||||
|
||||
-- Read and display the summary section from the report
|
||||
local report_file = io.open("luacov.report.out", "r")
|
||||
if report_file then
|
||||
local content = report_file:read("*all")
|
||||
report_file:close()
|
||||
|
||||
-- Extract just the Summary section
|
||||
local summary = content:match("Summary\n=+\n(.-)$")
|
||||
if summary then
|
||||
print("\nSummary")
|
||||
print("==============================================================================")
|
||||
print(summary)
|
||||
end
|
||||
end
|
||||
|
||||
print("Full coverage report: luacov.report.out")
|
||||
print("========================================")
|
||||
end
|
||||
|
||||
os.exit(success and result or 1)
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Run tests with code coverage
|
||||
|
||||
# Set up LuaRocks path
|
||||
eval $(luarocks path)
|
||||
|
||||
# Clean up old coverage files
|
||||
rm -f luacov.stats.out luacov.report.out
|
||||
|
||||
# Run tests with coverage enabled
|
||||
COVERAGE=1 lua testing/runAll.lua
|
||||
|
||||
# Check if tests passed
|
||||
if [ $? -eq 0 ]; then
|
||||
echo ""
|
||||
echo "========================================"
|
||||
echo "Generating coverage report..."
|
||||
echo "========================================"
|
||||
|
||||
# Generate detailed report
|
||||
luacov
|
||||
|
||||
# Show summary
|
||||
echo ""
|
||||
echo "========================================"
|
||||
echo "Coverage Summary"
|
||||
echo "========================================"
|
||||
|
||||
# Extract and display summary information
|
||||
if [ -f luacov.report.out ]; then
|
||||
echo ""
|
||||
grep -A 100 "^Summary" luacov.report.out | head -30
|
||||
echo ""
|
||||
echo "Full report available in: luacov.report.out"
|
||||
fi
|
||||
else
|
||||
echo "Tests failed. Coverage report not generated."
|
||||
exit 1
|
||||
fi
|
||||
Reference in New Issue
Block a user