[CI system] Add features to test result xml (#8342)

* Add features to test result xml
This commit is contained in:
Phil Christensen 2019-09-26 11:10:26 -07:00 committed by GitHub
parent ad49c27d4e
commit 2f4cb2d5be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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<std::string>& 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<std::string> 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"(<traits><trait name="abi_tag" value="%s" /></traits>)", test.abi_tag);
traits_block += Strings::format(R"(<trait name="abi_tag" value="%s" />)", 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"(<trait name="features" value="%s" />)", feature_list);
}
if (!traits_block.empty())
{
traits_block = "<traits>" + traits_block + "</traits>";
}
m_xml += Strings::format(R"( <test name="%s" method="%s" time="%lld" result="%s">%s%s</test>)"
@ -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));