Skip to content

Commit

Permalink
[CI system] Add features to test result xml (microsoft#8342)
Browse files Browse the repository at this point in the history
* Add features to test result xml
  • Loading branch information
Rastaban authored Sep 26, 2019
1 parent ad49c27 commit 2f4cb2d
Showing 1 changed file with 32 additions and 6 deletions.
38 changes: 32 additions & 6 deletions toolsrc/src/vcpkg/commands.ci.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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>)"
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit 2f4cb2d

Please sign in to comment.