Move tools in their own folder instead of Bigfoot Sources

This commit is contained in:
2026-09-02 23:32:44 +02:00
parent 9f034fed3c
commit 310d16b9ed
22 changed files with 14 additions and 13 deletions
+1
View File
@@ -0,0 +1 @@
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/SasquatchBaker)
+13
View File
@@ -0,0 +1,13 @@
get_filename_component(PackageName ${CMAKE_CURRENT_SOURCE_DIR} NAME)
project(${PackageName}Tests)
set(Dependencies)
set(BigfootDependencies
AssetsForTesting)
bigfoot_create_package_tests(
"${Dependencies}"
"${BigfootDependencies}"
"Tools")
bigfoot_create_bigfile("Tests/Tools")
@@ -0,0 +1,22 @@
// AUTO-GENERATED DO NOT TOUCH
/*********************************************************************
* \file BigFileInfo.generated.hpp
*
*********************************************************************/
#ifndef BIGFOOT_SASQUATCHBAKERTESTS_BIGFILEINFO_GENERATED_HPP
#define BIGFOOT_SASQUATCHBAKERTESTS_BIGFILEINFO_GENERATED_HPP
#include <EASTL/string_view.h>
#if defined BIGFOOT_TOOLMODE
namespace Bigfoot
{
/*
* BigFile location
*/
constexpr eastl::string_view BIGFILE_SASQUATCHBAKERTESTS_LOCATION {"./SasquatchBakerTests.db"};
} // namespace Bigfoot
#endif
#endif
@@ -0,0 +1,92 @@
/*********************************************************************
* \file SasquatchBaker.cpp
*
* \author Romain BOULLARD
* \date August 2026
*********************************************************************/
#include <SasquatchBaker/SasquatchBaker.hpp>
#include <Engine/Sasquatch/Sasquatch.hpp>
#include <System/File/File.hpp>
#include <AssetsForTesting/Asset/AssetA.hpp>
#include <AssetsForTesting/Asset/AssetB.hpp>
#include <SasquatchBakerTests/BigFileInfo_generated.hpp>
#include <gtest/gtest.h>
#include <cstring>
namespace Bigfoot
{
class SasquatchBakerFixture: public ::testing::Test
{
protected:
void SetUp() override
{
m_bigFile.Clear();
m_outputFile.Delete();
}
/*
* Packs an asset and saves it to the BigFile
*
* \param p_asset The asset to save
* \return The UUID the asset was saved under
*/
template<class ASSET>
UUID SaveAsset(ASSET& p_asset)
{
const eastl::vector<std::byte> flatbuffer = p_asset.Pack();
m_bigFile.SaveAssetFlatbuffer(p_asset.GetHeader().uuid, flatbuffer, p_asset.GetHardReferences(flatbuffer));
return p_asset.GetHeader().uuid;
}
static constexpr eastl::string_view SASQUATCH_SASQUATCHBAKERTESTS_LOCATION {"./SasquatchBakerTests.sasquatch"};
BigFile m_bigFile {File {BIGFILE_SASQUATCHBAKERTESTS_LOCATION}};
File m_outputFile {SASQUATCH_SASQUATCHBAKERTESTS_LOCATION};
};
/****************************************************************************************/
TEST_F(SasquatchBakerFixture, Bake_ShouldWriteAnEmptyFileWhenTheBigFileIsEmpty)
{
Bake(m_bigFile, m_outputFile);
Sasquatch sasquatch {m_outputFile};
const eastl::vector<std::byte> data = m_outputFile.Read(0, m_outputFile.GetSize());
ASSERT_EQ(m_outputFile.GetSize(), sizeof(SasquatchHeader));
EXPECT_EQ(sasquatch.GetHeader().m_magic, SasquatchHeader::MAGIC);
EXPECT_EQ(sasquatch.GetHeader().m_version, SasquatchHeader::VERSION);
EXPECT_EQ(sasquatch.GetHeader().m_assetCount, 0);
}
/****************************************************************************************/
TEST_F(SasquatchBakerFixture, Bake_ShouldWriteEveryAssetOfTheBigFile)
{
AssetA assetA;
assetA.SetName("hello");
SaveAsset(assetA);
AssetB assetB;
assetB.SetName("world");
assetB.GetAsset().ref_a = HardReference<AssetA> {assetA.GetHeader().uuid};
SaveAsset(assetB);
Bake(m_bigFile, m_outputFile);
Sasquatch sasquatch {m_outputFile};
EXPECT_EQ(sasquatch.GetHeader().m_magic, SasquatchHeader::MAGIC);
EXPECT_EQ(sasquatch.GetHeader().m_version, SasquatchHeader::VERSION);
EXPECT_EQ(sasquatch.GetHeader().m_assetCount, 2);
EXPECT_FALSE(sasquatch.GetAssetFlatbuffer(assetA.GetHeader().uuid).empty());
EXPECT_FALSE(sasquatch.GetAssetFlatbuffer(assetB.GetHeader().uuid).empty());
EXPECT_FALSE(sasquatch.GetAssetHardReferences(assetB.GetHeader().uuid).empty());
}
} // namespace Bigfoot
@@ -0,0 +1,21 @@
/*********************************************************************
* \file main.cpp
*
* \author Romain BOULLARD
* \date August 2026
*********************************************************************/
#include <Utils/Log/LogMacros.hpp>
#include <Utils/TargetMacros.h>
#include <gtest/gtest.h>
int main(int argc, char** argv)
{
testing::InitGoogleTest(&argc, argv);
GTEST_FLAG_SET(death_test_style, "threadsafe");
BIGFOOT_NOT_OPTIMIZED_ONLY(::Bigfoot::Singleton<::Bigfoot::Log>::Lifetime m_lifetime);
return RUN_ALL_TESTS();
}