From 0e19188a0b886dc4fbad90877bb0b953815ea3ce Mon Sep 17 00:00:00 2001 From: Michael Freno Date: Fri, 14 Nov 2025 23:17:43 -0500 Subject: [PATCH] made default --- testing/runAll.lua | 51 ++++++++++++++++++++++++++++-------- testing/run_with_coverage.sh | 39 --------------------------- 2 files changed, 40 insertions(+), 50 deletions(-) delete mode 100755 testing/run_with_coverage.sh diff --git a/testing/runAll.lua b/testing/runAll.lua index 9fea7cd..77732ac 100644 --- a/testing/runAll.lua +++ b/testing/runAll.lua @@ -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 - print("========================================") - print("Code coverage tracking enabled") - print("========================================") - else - print("Warning: luacov not found, coverage tracking disabled") - end +-- 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 + print("Warning: luacov not found, coverage tracking disabled") 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) diff --git a/testing/run_with_coverage.sh b/testing/run_with_coverage.sh deleted file mode 100755 index 09120e7..0000000 --- a/testing/run_with_coverage.sh +++ /dev/null @@ -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