mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-19 15:52:53 +00:00
chore: check exact paths of test executable and provide temp dir
This commit is contained in:
parent
fc9e6ce14d
commit
ce3786f086
@ -170,6 +170,7 @@ group ""
|
|||||||
-- ========================
|
-- ========================
|
||||||
-- Tests
|
-- Tests
|
||||||
-- ========================
|
-- ========================
|
||||||
|
include "test/Catch2Common.lua"
|
||||||
include "test/ObjCommonTestUtils.lua"
|
include "test/ObjCommonTestUtils.lua"
|
||||||
include "test/ObjCommonTests.lua"
|
include "test/ObjCommonTests.lua"
|
||||||
include "test/ObjCompilingTests.lua"
|
include "test/ObjCompilingTests.lua"
|
||||||
@ -181,6 +182,7 @@ include "test/ZoneCommonTests.lua"
|
|||||||
|
|
||||||
-- Tests group: Unit test and other tests projects
|
-- Tests group: Unit test and other tests projects
|
||||||
group "Tests"
|
group "Tests"
|
||||||
|
Catch2Common:project()
|
||||||
ObjCommonTestUtils:project()
|
ObjCommonTestUtils:project()
|
||||||
ObjCommonTests:project()
|
ObjCommonTests:project()
|
||||||
ObjCompilingTests:project()
|
ObjCompilingTests:project()
|
||||||
|
51
test/Catch2Common.lua
Normal file
51
test/Catch2Common.lua
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
Catch2Common = {}
|
||||||
|
|
||||||
|
function Catch2Common:include(includes)
|
||||||
|
if includes:handle(self:name()) then
|
||||||
|
includedirs {
|
||||||
|
path.join(TestFolder(), "Catch2Common")
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function Catch2Common:link(links)
|
||||||
|
links:add(self:name())
|
||||||
|
links:linkto(catch2)
|
||||||
|
end
|
||||||
|
|
||||||
|
function Catch2Common:use()
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function Catch2Common:name()
|
||||||
|
return "Catch2Common"
|
||||||
|
end
|
||||||
|
|
||||||
|
function Catch2Common:project()
|
||||||
|
local folder = TestFolder()
|
||||||
|
local includes = Includes:create()
|
||||||
|
local links = Links:create()
|
||||||
|
|
||||||
|
project(self:name())
|
||||||
|
targetdir(TargetDirectoryTest)
|
||||||
|
location "%{wks.location}/test/%{prj.name}"
|
||||||
|
kind "StaticLib"
|
||||||
|
language "C++"
|
||||||
|
|
||||||
|
files {
|
||||||
|
path.join(folder, "Catch2Common/**.h"),
|
||||||
|
path.join(folder, "Catch2Common/**.cpp")
|
||||||
|
}
|
||||||
|
|
||||||
|
vpaths {
|
||||||
|
["*"] = {
|
||||||
|
path.join(folder, "Catch2Common")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
self:include(includes)
|
||||||
|
catch2:include(includes)
|
||||||
|
|
||||||
|
links:linkto(catch2)
|
||||||
|
links:linkall()
|
||||||
|
end
|
27
test/Catch2Common/OatTestPaths.cpp
Normal file
27
test/Catch2Common/OatTestPaths.cpp
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#include "OatTestPaths.h"
|
||||||
|
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
|
namespace oat::paths
|
||||||
|
{
|
||||||
|
std::filesystem::path GetSourceDirectory()
|
||||||
|
{
|
||||||
|
return fs::current_path() / "src";
|
||||||
|
}
|
||||||
|
|
||||||
|
std::filesystem::path GetTestDirectory()
|
||||||
|
{
|
||||||
|
return fs::current_path() / "test";
|
||||||
|
}
|
||||||
|
|
||||||
|
std::filesystem::path GetTempDirectory()
|
||||||
|
{
|
||||||
|
auto result = fs::current_path() / "build" / ".tmp";
|
||||||
|
if (!fs::is_directory(result))
|
||||||
|
fs::create_directories(result);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
} // namespace oat::paths
|
10
test/Catch2Common/OatTestPaths.h
Normal file
10
test/Catch2Common/OatTestPaths.h
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
|
namespace oat::paths
|
||||||
|
{
|
||||||
|
std::filesystem::path GetSourceDirectory();
|
||||||
|
std::filesystem::path GetTestDirectory();
|
||||||
|
std::filesystem::path GetTempDirectory();
|
||||||
|
} // namespace oat::paths
|
48
test/Catch2Common/main.cpp
Normal file
48
test/Catch2Common/main.cpp
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
#include <catch2/catch_session.hpp>
|
||||||
|
#include <filesystem>
|
||||||
|
#include <format>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
|
int main(const int argc, char* argv[])
|
||||||
|
{
|
||||||
|
const fs::path absoluteBinDir(fs::absolute(argv[0]).parent_path());
|
||||||
|
|
||||||
|
const auto expectedLibDir = absoluteBinDir.parent_path().parent_path();
|
||||||
|
const auto expectedBuildDir = expectedLibDir.parent_path();
|
||||||
|
const auto expectedRootDir = expectedBuildDir.parent_path();
|
||||||
|
|
||||||
|
if (absoluteBinDir.filename() != "tests" || expectedLibDir.filename() != "lib" || expectedBuildDir.filename() != "build")
|
||||||
|
{
|
||||||
|
std::cerr << std::format("Expected test binary to be in the folder it was compiled into (build/lib/?/tests) but was {}\n", absoluteBinDir.string());
|
||||||
|
std::cerr << "Please do not move test executable out of compilation folder\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto expectedSrcDir = expectedRootDir / "src";
|
||||||
|
if (!fs::is_directory(expectedSrcDir))
|
||||||
|
{
|
||||||
|
std::cerr << std::format("Expected source directory to exist in {}, but it did not\n", expectedSrcDir.string());
|
||||||
|
std::cerr << "Please do not move test executable out of compilation folder\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto expectedTestDir = expectedRootDir / "test";
|
||||||
|
if (!fs::is_directory(expectedTestDir))
|
||||||
|
{
|
||||||
|
std::cerr << std::format("Expected test directory to exist in {}, but it did not\n", expectedTestDir.string());
|
||||||
|
std::cerr << "Please do not move test executable out of compilation folder\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
fs::current_path(expectedRootDir);
|
||||||
|
|
||||||
|
const auto result = Catch::Session().run(argc, argv);
|
||||||
|
|
||||||
|
const auto tempDir = expectedBuildDir / ".tmp";
|
||||||
|
if (fs::is_directory(tempDir))
|
||||||
|
fs::remove_all(tempDir);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
@ -44,6 +44,7 @@ function ObjCommonTests:project()
|
|||||||
}
|
}
|
||||||
|
|
||||||
self:include(includes)
|
self:include(includes)
|
||||||
|
Catch2Common:include(includes)
|
||||||
ObjCommon:include(includes)
|
ObjCommon:include(includes)
|
||||||
ObjImage:include(includes)
|
ObjImage:include(includes)
|
||||||
catch2:include(includes)
|
catch2:include(includes)
|
||||||
@ -51,5 +52,6 @@ function ObjCommonTests:project()
|
|||||||
links:linkto(ObjCommon)
|
links:linkto(ObjCommon)
|
||||||
links:linkto(ObjImage)
|
links:linkto(ObjImage)
|
||||||
links:linkto(catch2)
|
links:linkto(catch2)
|
||||||
|
links:linkto(Catch2Common)
|
||||||
links:linkall()
|
links:linkall()
|
||||||
end
|
end
|
||||||
|
@ -43,6 +43,7 @@ function ObjCompilingTests:project()
|
|||||||
}
|
}
|
||||||
|
|
||||||
self:include(includes)
|
self:include(includes)
|
||||||
|
Catch2Common:include(includes)
|
||||||
ObjCommonTestUtils:include(includes)
|
ObjCommonTestUtils:include(includes)
|
||||||
ParserTestUtils:include(includes)
|
ParserTestUtils:include(includes)
|
||||||
ObjLoading:include(includes)
|
ObjLoading:include(includes)
|
||||||
@ -54,5 +55,6 @@ function ObjCompilingTests:project()
|
|||||||
links:linkto(ObjLoading)
|
links:linkto(ObjLoading)
|
||||||
links:linkto(ObjCompiling)
|
links:linkto(ObjCompiling)
|
||||||
links:linkto(catch2)
|
links:linkto(catch2)
|
||||||
|
links:linkto(Catch2Common)
|
||||||
links:linkall()
|
links:linkall()
|
||||||
end
|
end
|
||||||
|
@ -43,6 +43,7 @@ function ObjLoadingTests:project()
|
|||||||
}
|
}
|
||||||
|
|
||||||
self:include(includes)
|
self:include(includes)
|
||||||
|
Catch2Common:include(includes)
|
||||||
ObjCommonTestUtils:include(includes)
|
ObjCommonTestUtils:include(includes)
|
||||||
ParserTestUtils:include(includes)
|
ParserTestUtils:include(includes)
|
||||||
ObjLoading:include(includes)
|
ObjLoading:include(includes)
|
||||||
@ -52,5 +53,6 @@ function ObjLoadingTests:project()
|
|||||||
links:linkto(ParserTestUtils)
|
links:linkto(ParserTestUtils)
|
||||||
links:linkto(ObjLoading)
|
links:linkto(ObjLoading)
|
||||||
links:linkto(catch2)
|
links:linkto(catch2)
|
||||||
|
links:linkto(Catch2Common)
|
||||||
links:linkall()
|
links:linkall()
|
||||||
end
|
end
|
||||||
|
@ -43,6 +43,7 @@ function ParserTests:project()
|
|||||||
}
|
}
|
||||||
|
|
||||||
self:include(includes)
|
self:include(includes)
|
||||||
|
Catch2Common:include(includes)
|
||||||
ParserTestUtils:include(includes)
|
ParserTestUtils:include(includes)
|
||||||
Parser:include(includes)
|
Parser:include(includes)
|
||||||
catch2:include(includes)
|
catch2:include(includes)
|
||||||
@ -50,5 +51,6 @@ function ParserTests:project()
|
|||||||
links:linkto(ParserTestUtils)
|
links:linkto(ParserTestUtils)
|
||||||
links:linkto(Parser)
|
links:linkto(Parser)
|
||||||
links:linkto(catch2)
|
links:linkto(catch2)
|
||||||
|
links:linkto(Catch2Common)
|
||||||
links:linkall()
|
links:linkall()
|
||||||
end
|
end
|
||||||
|
@ -43,6 +43,7 @@ function ZoneCodeGeneratorLibTests:project()
|
|||||||
}
|
}
|
||||||
|
|
||||||
self:include(includes)
|
self:include(includes)
|
||||||
|
Catch2Common:include(includes)
|
||||||
ZoneCodeGeneratorLib:include(includes)
|
ZoneCodeGeneratorLib:include(includes)
|
||||||
ParserTestUtils:include(includes)
|
ParserTestUtils:include(includes)
|
||||||
catch2:include(includes)
|
catch2:include(includes)
|
||||||
@ -50,5 +51,6 @@ function ZoneCodeGeneratorLibTests:project()
|
|||||||
links:linkto(ZoneCodeGeneratorLib)
|
links:linkto(ZoneCodeGeneratorLib)
|
||||||
links:linkto(ParserTestUtils)
|
links:linkto(ParserTestUtils)
|
||||||
links:linkto(catch2)
|
links:linkto(catch2)
|
||||||
|
links:linkto(Catch2Common)
|
||||||
links:linkall()
|
links:linkall()
|
||||||
end
|
end
|
||||||
|
@ -45,6 +45,7 @@ function ZoneCommonTests:project()
|
|||||||
}
|
}
|
||||||
|
|
||||||
self:include(includes)
|
self:include(includes)
|
||||||
|
Catch2Common:include(includes)
|
||||||
ObjCommonTestUtils:include(includes)
|
ObjCommonTestUtils:include(includes)
|
||||||
ZoneCommon:include(includes)
|
ZoneCommon:include(includes)
|
||||||
catch2:include(includes)
|
catch2:include(includes)
|
||||||
@ -52,6 +53,7 @@ function ZoneCommonTests:project()
|
|||||||
links:linkto(ObjCommonTestUtils)
|
links:linkto(ObjCommonTestUtils)
|
||||||
links:linkto(ZoneCommon)
|
links:linkto(ZoneCommon)
|
||||||
links:linkto(catch2)
|
links:linkto(catch2)
|
||||||
|
links:linkto(Catch2Common)
|
||||||
links:linkall()
|
links:linkall()
|
||||||
|
|
||||||
ZoneCode:use()
|
ZoneCode:use()
|
||||||
|
1
thirdparty/catch2.lua
vendored
1
thirdparty/catch2.lua
vendored
@ -49,6 +49,7 @@ function catch2:project()
|
|||||||
|
|
||||||
defines {
|
defines {
|
||||||
"DO_NOT_USE_WMAIN",
|
"DO_NOT_USE_WMAIN",
|
||||||
|
"CATCH_AMALGAMATED_CUSTOM_MAIN",
|
||||||
"_CRT_SECURE_NO_WARNINGS"
|
"_CRT_SECURE_NO_WARNINGS"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user