Skip to content

Commit 2f4cb2d

Browse files
authored
[CI system] Add features to test result xml (#8342)
* Add features to test result xml
1 parent ad49c27 commit 2f4cb2d

File tree

1 file changed

+32
-6
lines changed

1 file changed

+32
-6
lines changed

toolsrc/src/vcpkg/commands.ci.cpp

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,10 @@ namespace vcpkg::Commands::CI
6060
void add_test_results(const std::string& spec,
6161
const Build::BuildResult& build_result,
6262
const Chrono::ElapsedTime& elapsed_time,
63-
const std::string& abi_tag)
63+
const std::string& abi_tag,
64+
const std::vector<std::string>& features)
6465
{
65-
m_collections.back().tests.push_back({spec, build_result, elapsed_time, abi_tag});
66+
m_collections.back().tests.push_back({spec, build_result, elapsed_time, abi_tag, features});
6667
}
6768

6869
// Starting a new test collection
@@ -98,6 +99,7 @@ namespace vcpkg::Commands::CI
9899
vcpkg::Build::BuildResult result;
99100
vcpkg::Chrono::ElapsedTime time;
100101
std::string abi_tag;
102+
std::vector<std::string> features;
101103
};
102104

103105
struct XunitCollection
@@ -166,9 +168,29 @@ namespace vcpkg::Commands::CI
166168
}
167169

168170
std::string traits_block;
169-
if (test.abi_tag != "") // only adding if there is a known abi tag
171+
if (test.abi_tag != "")
170172
{
171-
traits_block = Strings::format(R"(<traits><trait name="abi_tag" value="%s" /></traits>)", test.abi_tag);
173+
traits_block += Strings::format(R"(<trait name="abi_tag" value="%s" />)", test.abi_tag);
174+
}
175+
176+
if (!test.features.empty())
177+
{
178+
std::string feature_list;
179+
for (const auto& feature : test.features)
180+
{
181+
if (!feature_list.empty())
182+
{
183+
feature_list += ", ";
184+
}
185+
feature_list += feature;
186+
}
187+
188+
traits_block += Strings::format(R"(<trait name="features" value="%s" />)", feature_list);
189+
}
190+
191+
if (!traits_block.empty())
192+
{
193+
traits_block = "<traits>" + traits_block + "</traits>";
172194
}
173195

174196
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
458480
// Adding results for ports that were built or pulled from an archive
459481
for (auto&& result : summary.results)
460482
{
483+
auto& port_features = split_specs->features[result.spec];
461484
split_specs->known.erase(result.spec);
462485
xunitTestResults.add_test_results(result.spec.to_string(),
463486
result.build_result.code,
464487
result.timing,
465-
split_specs->abi_tag_map.at(result.spec));
488+
split_specs->abi_tag_map.at(result.spec),
489+
port_features);
466490
}
467491

468492
// Adding results for ports that were not built because they have known states
469493
for (auto&& port : split_specs->known)
470494
{
495+
auto& port_features = split_specs->features[port.first];
471496
xunitTestResults.add_test_results(port.first.to_string(),
472497
port.second,
473498
Chrono::ElapsedTime{},
474-
split_specs->abi_tag_map.at(port.first));
499+
split_specs->abi_tag_map.at(port.first),
500+
port_features);
475501
}
476502

477503
all_known_results.emplace_back(std::move(split_specs->known));

0 commit comments

Comments
 (0)