diff --git a/CMakeLists.txt b/CMakeLists.txt index 71e5e02e..0ae71b34 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -114,14 +114,6 @@ else() set(LCI_LIBRARIES ${LCI_LIBRARIES} dl) endif() -ExternalProject_Add(testing-metadata - PREFIX "external" - GIT_REPOSITORY "https://github.com/loot/testing-metadata" - GIT_TAG "1.4.0" - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND "") - ExternalProject_Add(testing-plugins PREFIX "external" URL "https://github.com/Ortham/testing-plugins/archive/1.4.1.tar.gz" @@ -352,7 +344,6 @@ add_dependencies(libloot_internals_tests spdlog yaml-cpp GTest - testing-metadata testing-plugins) target_link_libraries(libloot_internals_tests PRIVATE ${ESPLUGIN_LIBRARIES} @@ -377,7 +368,7 @@ target_link_libraries(loot PRIVATE # Build API tests. add_executable(libloot_tests ${LIBLOOT_INTERFACE_TESTS_ALL_SOURCES}) -add_dependencies(libloot_tests loot GTest testing-metadata testing-plugins) +add_dependencies(libloot_tests loot GTest testing-plugins) target_link_libraries(libloot_tests PRIVATE loot ${GTEST_LIBRARIES}) ############################## @@ -537,38 +528,6 @@ endif() # Post-Build Steps ############################## -# Copy testing metadata -ExternalProject_Get_Property(testing-metadata SOURCE_DIR) -add_custom_command(TARGET libloot_internals_tests POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${SOURCE_DIR} - "$/testing-metadata") -add_custom_command(TARGET libloot_tests POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${SOURCE_DIR} - "$/testing-metadata") - -if(GIT_FOUND) - # Clone a mirror of the testing-metadata repository for faster tests. - # Remove the directory if it already exists before cloning, as the clone - # will fail if the target directory exists and is not empty. - # Tests will fail if this is not done. - - add_custom_command(TARGET libloot_internals_tests POST_BUILD - COMMAND ${CMAKE_COMMAND} -E remove_directory - "$/testing-metadata.git") - - add_custom_command(TARGET libloot_internals_tests POST_BUILD - COMMAND git clone --bare https://github.com/loot/testing-metadata.git "$/testing-metadata.git") - - add_custom_command(TARGET libloot_tests POST_BUILD - COMMAND ${CMAKE_COMMAND} -E remove_directory - "$/testing-metadata.git") - - add_custom_command(TARGET libloot_tests POST_BUILD - COMMAND git clone --bare https://github.com/loot/testing-metadata.git "$/testing-metadata.git") -endif() - # Copy testing plugins ExternalProject_Get_Property(testing-plugins SOURCE_DIR) add_custom_command(TARGET libloot_internals_tests POST_BUILD diff --git a/src/tests/api/interface/database_interface_test.h b/src/tests/api/interface/database_interface_test.h index e46af5d6..f567a416 100644 --- a/src/tests/api/interface/database_interface_test.h +++ b/src/tests/api/interface/database_interface_test.h @@ -35,9 +35,6 @@ protected: DatabaseInterfaceTest() : userlistPath_(localPath / "userlist.yaml"), minimalOutputPath_(localPath / "minimal.yml"), - url_("./testing-metadata.git"), - branch_("master"), - oldBranch_("old-branch"), generalUserlistMessage("A general userlist message.") {} void SetUp() override { @@ -109,9 +106,6 @@ protected: const std::filesystem::path userlistPath_; const std::filesystem::path minimalOutputPath_; - const std::string url_; - const std::string branch_; - const std::string oldBranch_; const std::string generalUserlistMessage; }; diff --git a/src/tests/api/internals/metadata_list_test.h b/src/tests/api/internals/metadata_list_test.h index 5f67951b..5054f158 100644 --- a/src/tests/api/internals/metadata_list_test.h +++ b/src/tests/api/internals/metadata_list_test.h @@ -35,10 +35,7 @@ protected: MetadataListTest() : metadataPath(metadataFilesPath / "masterlist.yaml"), savedMetadataPath(metadataFilesPath / "saved.masterlist.yaml"), - missingMetadataPath(metadataFilesPath / "missing-metadata.yaml"), - invalidMetadataPaths( - {metadataFilesPath / "invalid" / "non_map_root.yaml", - metadataFilesPath / "invalid" / "non_unique.yaml"}) {} + missingMetadataPath(metadataFilesPath / "missing-metadata.yaml") {} inline void SetUp() override { CommonGameTestFixture::SetUp(); @@ -46,24 +43,55 @@ protected: using std::filesystem::copy; using std::filesystem::exists; - auto sourceDirectory = getSourceMetadataFilesPath(); - - copy(sourceDirectory / "masterlist.yaml", metadataPath); + writeMasterlist(metadataPath); ASSERT_TRUE(exists(metadataPath)); - copyInvalidMetadataFile(sourceDirectory, "non_map_root.yaml"); - copyInvalidMetadataFile(sourceDirectory, "non_unique.yaml"); - ASSERT_FALSE(exists(savedMetadataPath)); ASSERT_FALSE(exists(missingMetadataPath)); } - void copyInvalidMetadataFile(const std::filesystem::path& sourceDirectory, - const std::string& file) { - std::filesystem::create_directories(metadataFilesPath / "invalid"); - std::filesystem::copy(sourceDirectory / "invalid" / file, - metadataFilesPath / "invalid" / file); - ASSERT_TRUE(std::filesystem::exists(metadataFilesPath / "invalid" / file)); + static void writeMasterlist(const std::filesystem::path& path) { + std::ofstream out(path); + out << R"(bash_tags: + - 'C.Climate' + - 'Relev' + +groups: + - name: group1 + after: + - group2 + - name: group2 + after: + - default + +globals: + - type: say + content: 'A global message.' + +plugins: + - name: 'Blank.esm' + priority: -100 + msg: + - type: warn + content: 'This is a warning.' + - type: say + content: 'This message should be removed when evaluating conditions.' + condition: 'active("Blank - Different.esm")' + + - name: 'Blank.+\.esp' + after: + - 'Blank.esm' + + - name: 'Blank.+(Different)?.*\.esp' + inc: + - 'Blank.esp' + + - name: 'Blank.esp' + group: group2 + dirty: + - crc: 0xDEADBEEF + util: utility)"; + out.close(); } static std::string PluginMetadataToString(const PluginMetadata& metadata) { @@ -74,7 +102,6 @@ protected: const std::filesystem::path savedMetadataPath; const std::filesystem::path groupMetadataPath; const std::filesystem::path missingMetadataPath; - const std::vector invalidMetadataPaths; }; // Pass an empty first argument, as it's a prefix for the test instantation, @@ -168,10 +195,46 @@ TEST_P(MetadataListTest, loadYamlParsingShouldSupportMergeKeys) { } TEST_P(MetadataListTest, loadShouldThrowIfAnInvalidMetadataFileIsGiven) { - MetadataList ml; - for (const auto& path : invalidMetadataPaths) { - EXPECT_THROW(ml.Load(path), FileAccessError); - } + MetadataList metadataList; + + std::ofstream out(metadataPath); + out << R"( - 'C.Climate' + - 'Relev' + +globals: + - type: say + content: 'A global message.' + +plugins: + - name: 'Blank.+\.esp' + after: + - 'Blank.esm')"; + out.close(); + + EXPECT_THROW(metadataList.Load(metadataPath), FileAccessError); + + out.open(metadataPath); + out << R"(globals: + - type: say + content: 'A global message.' + +plugins: + - name: 'Blank.esm' + priority: -100 + msg: + - type: warn + content: 'This is a warning.' + - type: say + content: 'This message should be removed when evaluating conditions.' + condition: 'active("Blank - Different.esm")' + + - name: 'Blank.esm' + msg: + - type: error + content: 'This plugin entry will cause a failure, as it is not the first exact entry.')"; + out.close(); + + EXPECT_THROW(metadataList.Load(metadataPath), FileAccessError); } TEST_P(MetadataListTest, diff --git a/src/tests/common_game_test_fixture.h b/src/tests/common_game_test_fixture.h index b474df4a..5b9dea93 100644 --- a/src/tests/common_game_test_fixture.h +++ b/src/tests/common_game_test_fixture.h @@ -264,10 +264,6 @@ protected: const uint32_t blankEsmCrc; - static std::filesystem::path getSourceMetadataFilesPath() { - return std::filesystem::absolute("./testing-metadata"); - } - private: std::filesystem::path getSourcePluginsPath() const { using std::filesystem::absolute;