From 2f4cb2d5be72ab6f40a2a5fc68f8c03a5fa1e8fd Mon Sep 17 00:00:00 2001 From: Phil Christensen Date: Thu, 26 Sep 2019 11:10:26 -0700 Subject: [PATCH] [CI system] Add features to test result xml (#8342) * Add features to test result xml --- toolsrc/src/vcpkg/commands.ci.cpp | 38 ++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/toolsrc/src/vcpkg/commands.ci.cpp b/toolsrc/src/vcpkg/commands.ci.cpp index 6e0a71adf..419d65f03 100644 --- a/toolsrc/src/vcpkg/commands.ci.cpp +++ b/toolsrc/src/vcpkg/commands.ci.cpp @@ -60,9 +60,10 @@ namespace vcpkg::Commands::CI void add_test_results(const std::string& spec, const Build::BuildResult& build_result, const Chrono::ElapsedTime& elapsed_time, - const std::string& abi_tag) + const std::string& abi_tag, + const std::vector& features) { - m_collections.back().tests.push_back({spec, build_result, elapsed_time, abi_tag}); + m_collections.back().tests.push_back({spec, build_result, elapsed_time, abi_tag, features}); } // Starting a new test collection @@ -98,6 +99,7 @@ namespace vcpkg::Commands::CI vcpkg::Build::BuildResult result; vcpkg::Chrono::ElapsedTime time; std::string abi_tag; + std::vector features; }; struct XunitCollection @@ -166,9 +168,29 @@ namespace vcpkg::Commands::CI } std::string traits_block; - if (test.abi_tag != "") // only adding if there is a known abi tag + if (test.abi_tag != "") { - traits_block = Strings::format(R"()", test.abi_tag); + traits_block += Strings::format(R"()", test.abi_tag); + } + + if (!test.features.empty()) + { + std::string feature_list; + for (const auto& feature : test.features) + { + if (!feature_list.empty()) + { + feature_list += ", "; + } + feature_list += feature; + } + + traits_block += Strings::format(R"()", feature_list); + } + + if (!traits_block.empty()) + { + traits_block = "" + traits_block + ""; } m_xml += Strings::format(R"( %s%s)" @@ -458,20 +480,24 @@ namespace vcpkg::Commands::CI // Adding results for ports that were built or pulled from an archive for (auto&& result : summary.results) { + auto& port_features = split_specs->features[result.spec]; split_specs->known.erase(result.spec); xunitTestResults.add_test_results(result.spec.to_string(), result.build_result.code, result.timing, - split_specs->abi_tag_map.at(result.spec)); + split_specs->abi_tag_map.at(result.spec), + port_features); } // Adding results for ports that were not built because they have known states for (auto&& port : split_specs->known) { + auto& port_features = split_specs->features[port.first]; xunitTestResults.add_test_results(port.first.to_string(), port.second, Chrono::ElapsedTime{}, - split_specs->abi_tag_map.at(port.first)); + split_specs->abi_tag_map.at(port.first), + port_features); } all_known_results.emplace_back(std::move(split_specs->known));