From a45a3415b3c81c365676e43d3a6c300436cdb500 Mon Sep 17 00:00:00 2001 From: joanvallve <jvallve@iri.upc.edu> Date: Mon, 8 Jul 2024 10:49:51 +0200 Subject: [PATCH] [skip ci] gtest_schema checking duplicated in specific folders --- test/gtest_schema.cpp | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/test/gtest_schema.cpp b/test/gtest_schema.cpp index 835ba1c..57d7f1e 100644 --- a/test/gtest_schema.cpp +++ b/test/gtest_schema.cpp @@ -121,18 +121,29 @@ TEST(Schema, validate_all_schemas) TEST(Schema, duplicated_schemas) { - std::set<std::string> schemas_found; + std::map<std::string, std::string> schemas_found; + unsigned int n_duplicated = 0; + std::vector<std::string> root_folders{plugin_dir + "/schema", plugin_dir + "/test"}; - for (auto const& entry : filesystem::recursive_directory_iterator(plugin_dir)) - { - if (filesystem::is_regular_file(entry) and entry.path().extension().string() == ".schema") + for (auto root_folder : root_folders) + for (auto const& entry : filesystem::recursive_directory_iterator(root_folder)) { - ASSERT_FALSE(schemas_found.count(entry.path().filename().string())); - schemas_found.insert(entry.path().filename().string()); + if (filesystem::is_regular_file(entry) and entry.path().extension().string() == ".schema") + { + bool duplicated = schemas_found.count(entry.path().filename().string()); + WOLF_ERROR_COND(duplicated, + "Found duplicated schema file:\n", + entry.path().string(), + "\n", + schemas_found[entry.path().filename().string()]) + schemas_found[entry.path().filename().string()] = entry.path().string(); + if (duplicated) n_duplicated++; + } } - } - - WOLF_INFO("Found ", schemas_found.size(), " schema files."); + ASSERT_EQ(n_duplicated, 0); + WOLF_INFO_COND(n_duplicated == 0, "Found ", schemas_found.size(), " schema files."); + WOLF_ERROR_COND( + n_duplicated != 0, "Found ", n_duplicated, " duplicated schemas in ", schemas_found.size(), " schema files."); } -- GitLab