mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-12-27 12:31:50 +00:00
chore: add simple iw3 system test
This commit is contained in:
@@ -11,6 +11,7 @@ end
|
||||
function Catch2Common:link(links)
|
||||
links:add(self:name())
|
||||
links:linkto(catch2)
|
||||
links:linkto(Utils)
|
||||
end
|
||||
|
||||
function Catch2Common:use()
|
||||
@@ -45,7 +46,9 @@ function Catch2Common:project()
|
||||
|
||||
self:include(includes)
|
||||
catch2:include(includes)
|
||||
Utils:include(includes)
|
||||
|
||||
links:linkto(catch2)
|
||||
links:linkto(Utils)
|
||||
links:linkall()
|
||||
end
|
||||
|
||||
@@ -24,4 +24,13 @@ namespace oat::paths
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
std::filesystem::path GetTempDirectory(const std::string& subDir)
|
||||
{
|
||||
auto result = fs::current_path() / "build" / ".tmp" / subDir;
|
||||
if (!fs::is_directory(result))
|
||||
fs::create_directories(result);
|
||||
|
||||
return result;
|
||||
}
|
||||
} // namespace oat::paths
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <string>
|
||||
|
||||
namespace oat::paths
|
||||
{
|
||||
std::filesystem::path GetSourceDirectory();
|
||||
std::filesystem::path GetTestDirectory();
|
||||
std::filesystem::path GetTempDirectory();
|
||||
std::filesystem::path GetTempDirectory(const std::string& subDir);
|
||||
} // namespace oat::paths
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#include "Utils/Logging/Log.h"
|
||||
|
||||
#include <catch2/catch_session.hpp>
|
||||
#include <filesystem>
|
||||
#include <format>
|
||||
@@ -7,6 +9,9 @@ namespace fs = std::filesystem;
|
||||
|
||||
int main(const int argc, char* argv[])
|
||||
{
|
||||
con::init();
|
||||
con::set_log_level(con::LogLevel::DEBUG);
|
||||
|
||||
const fs::path absoluteBinDir(fs::canonical(argv[0]).parent_path());
|
||||
|
||||
const auto expectedLibDir = absoluteBinDir.parent_path().parent_path();
|
||||
@@ -15,24 +20,24 @@ int main(const int argc, char* argv[])
|
||||
|
||||
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";
|
||||
con::error("Expected test binary to be in the folder it was compiled into (build/lib/?/tests) but was {}", absoluteBinDir.string());
|
||||
con::error("Please do not move test executable out of compilation folder");
|
||||
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";
|
||||
con::error("Expected source directory to exist in {}, but it did not", expectedSrcDir.string());
|
||||
con::error("Please do not move test executable out of compilation folder");
|
||||
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";
|
||||
con::error("Expected test directory to exist in {}, but it did not", expectedTestDir.string());
|
||||
con::error("Please do not move test executable out of compilation folder");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +44,8 @@ function SystemTests:project()
|
||||
ObjLoading:include(includes)
|
||||
ObjCompiling:include(includes)
|
||||
ObjWriting:include(includes)
|
||||
Linking:include(includes)
|
||||
Unlinking:include(includes)
|
||||
catch2:include(includes)
|
||||
|
||||
Raw:use()
|
||||
@@ -56,5 +58,7 @@ function SystemTests:project()
|
||||
links:linkto(ObjWriting)
|
||||
links:linkto(catch2)
|
||||
links:linkto(Catch2Common)
|
||||
links:linkto(Linking)
|
||||
links:linkto(Unlinking)
|
||||
links:linkall()
|
||||
end
|
||||
|
||||
45
test/SystemTests/Game/IW3/SimpleZoneIW3.cpp
Normal file
45
test/SystemTests/Game/IW3/SimpleZoneIW3.cpp
Normal file
@@ -0,0 +1,45 @@
|
||||
#include "Linker.h"
|
||||
#include "OatTestPaths.h"
|
||||
#include "SystemTestsPaths.h"
|
||||
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <format>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
using namespace std::literals;
|
||||
|
||||
namespace
|
||||
{
|
||||
TEST_CASE("Simple Zone(IW3)", "[iw3][system][simple]")
|
||||
{
|
||||
const auto assetSearchPath = oat::paths::GetSystemTestsDirectory() / "Game/IW3/simple";
|
||||
const auto sourceSearchPath = oat::paths::GetSystemTestsDirectory() / "Game/IW3/simple";
|
||||
const auto outputPath = oat::paths::GetTempDirectory("iw3_simple");
|
||||
|
||||
const char* argStrings[]{
|
||||
"SystemTests", // bin
|
||||
"--verbose",
|
||||
"--asset-search-path",
|
||||
assetSearchPath.c_str(),
|
||||
"--source-search-path",
|
||||
sourceSearchPath.c_str(),
|
||||
"--output-folder",
|
||||
outputPath.c_str(),
|
||||
"SimpleZoneIW3",
|
||||
};
|
||||
|
||||
LinkerArgs args;
|
||||
|
||||
bool shouldContinue = true;
|
||||
const auto couldParseArgs = args.ParseArgs(std::extent_v<decltype(argStrings)>, argStrings, shouldContinue);
|
||||
|
||||
REQUIRE(couldParseArgs);
|
||||
REQUIRE(shouldContinue);
|
||||
|
||||
const auto linker = Linker::Create(std::move(args));
|
||||
const auto linkerResult = linker->Start();
|
||||
|
||||
REQUIRE(linkerResult);
|
||||
}
|
||||
} // namespace
|
||||
1
test/SystemTests/Game/IW3/simple/SimpleZone.txt
Normal file
1
test/SystemTests/Game/IW3/simple/SimpleZone.txt
Normal file
@@ -0,0 +1 @@
|
||||
This is a simple zone.
|
||||
4
test/SystemTests/Game/IW3/simple/SimpleZoneIW3.zone
Normal file
4
test/SystemTests/Game/IW3/simple/SimpleZoneIW3.zone
Normal file
@@ -0,0 +1,4 @@
|
||||
>game,IW3
|
||||
|
||||
rawfile,SimpleZone.txt
|
||||
|
||||
15
test/SystemTests/SystemTestsPaths.cpp
Normal file
15
test/SystemTests/SystemTestsPaths.cpp
Normal file
@@ -0,0 +1,15 @@
|
||||
#include "SystemTestsPaths.h"
|
||||
|
||||
#include "OatTestPaths.h"
|
||||
|
||||
#include <filesystem>
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
namespace oat::paths
|
||||
{
|
||||
std::filesystem::path GetSystemTestsDirectory()
|
||||
{
|
||||
return GetTestDirectory() / "SystemTests";
|
||||
}
|
||||
} // namespace oat::paths
|
||||
8
test/SystemTests/SystemTestsPaths.h
Normal file
8
test/SystemTests/SystemTestsPaths.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
|
||||
namespace oat::paths
|
||||
{
|
||||
std::filesystem::path GetSystemTestsDirectory();
|
||||
} // namespace oat::paths
|
||||
Reference in New Issue
Block a user