Skip to content

Commit

Permalink
catch2 test setup
Browse files Browse the repository at this point in the history
  • Loading branch information
GlynLeine committed Dec 14, 2023
1 parent 08e5f36 commit 0f18a70
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 20 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@
[submodule "libraries/rythe/rythe-standard-library"]
path = libraries/rythe/rythe-standard-library
url = https://github.com/Rythe-Interactive/Rythe-Standard-Library.git
[submodule "libraries/third_party/catch2"]
path = libraries/third_party/catch2
url = https://github.com/catchorg/Catch2.git
1 change: 1 addition & 0 deletions libraries/third_party/catch2
Submodule catch2 added at 3acb8b
2 changes: 1 addition & 1 deletion modules/rythe/application
Submodule application updated 1 files
+2 −1 .rythe_project
2 changes: 1 addition & 1 deletion modules/rythe/audio
Submodule audio updated 1 files
+2 −1 .rythe_project
2 changes: 1 addition & 1 deletion modules/rythe/core
Submodule core updated from f5739b to 8f3044
2 changes: 1 addition & 1 deletion modules/rythe/graphics
Submodule graphics updated 1 files
+2 −1 .rythe_project
2 changes: 1 addition & 1 deletion modules/rythe/physics
Submodule physics updated 1 files
+2 −1 .rythe_project
12 changes: 9 additions & 3 deletions premake/rythe/filesystem.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
local fs = {}

function fs.exists(file)
local f = io.open(file, "rb")
if f then io.close(f) end
return f ~= nil
local ok, err, code = os.rename(file, file)
if not ok then
if code == 13 then
-- Permission denied, but it exists
return true
end
return false
end
return true
end

function fs.readLines(file)
Expand Down
56 changes: 45 additions & 11 deletions premake/rythe/projects.lua
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,18 @@ local function projectNameSuffix(projectType)
return ""
end

local function projectTypeFilesDir(projectType)
local function projectTypeFilesDir(projectType, namespace)
if projectType == "test" then
return "/tests/"
elseif projectType == "editor" then
return "/editor/"
end

return "/src/"
if namespace == "" or namespace == nil then
return "/src/"
end

return "/src/" .. namespace .. "/"
end

local function isProjectTypeMainType(projectType)
Expand Down Expand Up @@ -293,6 +297,10 @@ local function getDepsRecursive(project, projectType)
deps = {}
end

if projectType == "test" then
deps[#deps + 1] = "third_party/catch2"
end

local copy = deps

local set = {}
Expand All @@ -312,13 +320,32 @@ local function getDepsRecursive(project, projectType)
}

local path = project.location .. "/third_party/" .. thirdPartyProject.name
thirdPartyProject.files = {
path .. "/src/**",
path .. "/include/**"
}

depProject = loadProject(depId, thirdPartyProject, project.src, path, thirdPartyProject.name, "library")
depType = "library"
if not fs.exists(path .. "/") then
path = _WORKING_DIR .. "/libraries/third_party/" .. thirdPartyProject.name
end

if fs.exists(path .. "/") then
thirdPartyProject.files = {}

if fs.exists(path .. "/src/" .. thirdPartyProject.name .. "/") then
thirdPartyProject.files[#thirdPartyProject.files + 1] = path .. "/src/" .. thirdPartyProject.name .. "/**"
end

if fs.exists(path .. "/include/" .. thirdPartyProject.name .. "/") then
thirdPartyProject.files[#thirdPartyProject.files + 1] = path .. "/include/" .. thirdPartyProject.name .. "/**"
end

if utils.tableIsEmpty(thirdPartyProject.files) then
thirdPartyProject.files = {
path .. "/src/**",
path .. "/include/**"
}
end

depProject = loadProject(depId, thirdPartyProject, project.src, path, thirdPartyProject.name, "library")
depType = "library"
end
end

if depProject ~= nil then
Expand Down Expand Up @@ -391,7 +418,7 @@ function projects.submit(proj)
local depProject, depId, depType = findAssembly(assemblyId)

if depProject ~= nil then
externalIncludeDirs[#externalIncludeDirs + 1] = depProject.location .. "/" .. projectTypeFilesDir(depType)
externalIncludeDirs[#externalIncludeDirs + 1] = depProject.location .. "/" .. projectTypeFilesDir(depType, "")

depNames[#depNames + 1] = depProject.alias .. projectNameSuffix(depType)

Expand Down Expand Up @@ -423,10 +450,17 @@ function projects.submit(proj)
if string.find(pattern, "^(%.[/\\])") == nil then
filePatterns[#filePatterns + 1] = pattern
else
filePatterns[#filePatterns + 1] = proj.location .. projectTypeFilesDir(projectType) .. proj.namespace .. "/" .. string.sub(pattern, 3)
filePatterns[#filePatterns + 1] = proj.location .. projectTypeFilesDir(projectType, proj.namespace) .. string.sub(pattern, 3)
end
end

if projectType == "test" then
filePatterns[#filePatterns + 1] = _WORKING_DIR .. "/utils/test utils/**"

vpaths({ ["test utils"] = _WORKING_DIR .. "/utils/test utils/**" })
end

vpaths({ ["*"] = proj.location .. projectTypeFilesDir(projectType, proj.namespace) })
files(filePatterns)

if not utils.tableIsEmpty(proj.exclude_files) then
Expand All @@ -435,7 +469,7 @@ function projects.submit(proj)
if string.find(pattern, "^(%.[/\\])") == nil then
excludePatterns[#excludePatterns + 1] = pattern
else
excludePatterns[#excludePatterns + 1] = proj.location .. projectTypeFilesDir(projectType) .. proj.namespace .. "/" .. string.sub(pattern, 3)
excludePatterns[#excludePatterns + 1] = proj.location .. projectTypeFilesDir(projectType, proj.namespace) .. string.sub(pattern, 3)
end
end

Expand Down
Empty file added utils/test utils/main.cpp
Empty file.

0 comments on commit 0f18a70

Please sign in to comment.