Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/workflows/ci.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -138,13 +138,25 @@ jobs:

- name: Run tests
run: |
xmake f -y -m debug
xmake test -y -v
timeout-minutes: 30

- name: Check test coverage (Linux)
if: contains(runner.os, 'linux')
uses: threeal/gcovr-action@1b53388d5f84b4f3afb1b9082782961dff911ba0

- name: Check memory leaks (macOS)
if: contains(runner.os, 'macos')
run: |
xmake check_leaks
timeout-minutes: 30
Comment thread
Miou-zora marked this conversation as resolved.

- name: Clear test artifacts
if: contains(runner.os, 'linux')
run: |
xmake clean -y

check_examples:
name: Build and test examples
needs: [check_repository_cleanliness, lint_code]
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/commit_norm_check.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,7 +15,9 @@ jobs:

steps:
- name: Set up Git repository
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Commit Norm Checker
run: |
Expand Down
4 changes: 2 additions & 2 deletions src/engine/xmake.lua
Original file line numberDiff line numberDiff line change
Expand Up@@ -49,9 +49,9 @@ for _, file in ipairs(os.files("tests/**.cpp")) do
add_packages("entt", "gtest", "glm", "fmt", "spdlog")
add_links("gtest")
add_tests("default")

add_deps("EngineSquaredCore")

add_files(file)
add_files("tests/main.cpp")
if is_mode("debug") then
Expand Down
74 changes: 74 additions & 0 deletions tools/xmake/check_leaks.lua
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
includes(os.scriptdir() .. "/groups.lua")

local TestGroupName = TEST_GROUP_NAME

local function check_leaks_macos(targets, leaks_tool, project, os)
local failing_targets = {}
for _, target in pairs(targets) do
local target_name = target:name()
local bin_path = path.join(os.projectdir(), target:targetdir(), "debug", target:filename())
Comment thread
Miou-zora marked this conversation as resolved.

if not os.isfile(bin_path) then
print("Executable not found for target: " .. target_name)
goto continue
end

print("Running leaks check on: " .. bin_path)
local return_value = os.execv(leaks_tool, {"--atExit", "--", bin_path}, {try = true, stdout = os.nuldev(), stderr = os.nuldev()})
if return_value ~= 0 then
table.insert(failing_targets, target_name)
end
::continue::
end
return failing_targets
end

task("check_leaks")
on_run(function ()
import("core.base.option")
import("core.project.project")
import("core.project.config")
import("lib.detect.find_program")

local targets = option.get("targets") or {}
if #targets == 0 then
-- If no targets specified, check all test targets
targets = {}
for _, target in pairs(project:targets()) do
local name = target:name()
local group = target:info().group
local kind = target:kind()
if kind == "binary" and group == TestGroupName then
table.insert(targets, target)
end
end
end
local failing_targets = {}
if os.host() == "macosx" then
local leaks_tool = find_program("leaks", { check = "--help" })
if not leaks_tool then
print("leaks tool not found!")
return
end
failing_targets = check_leaks_macos(targets, leaks_tool, project, os)
else
print("Memory leak checking is currently only implemented for macOS.")
end
if #failing_targets > 0 then
print("Targets with memory leaks found:")
for _, target in ipairs(failing_targets) do
print(" - " .. target)
end
else
print("No memory leaks found.")
end
Comment thread
Miou-zora marked this conversation as resolved.
end)

set_menu {
usage = "xmake check_leaks",
description = "Check for memory leaks",
options = {
{nil, "targets", "vs", nil, "Targets to check for leaks (default: all test targets)"}
}
}

3 changes: 3 additions & 0 deletions tools/xmake/groups.lua
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
TEST_GROUP_NAME = "UnitTests"
PLUGINS_GROUP_NAME = "Plugins"
UTILS_GROUP_NAME = "Utils"
4 changes: 0 additions & 4 deletions xmake.lua
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
---@diagnostic disable: undefined-global

TEST_GROUP_NAME = "UnitTests"
PLUGINS_GROUP_NAME = "Plugins"
UTILS_GROUP_NAME = "Utils"

includes("tools/xmake/*.lua")

add_rules("mode.debug", "mode.release")
Expand Down
Loading