Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Windows] Fix verification of test count in CI #19697

Merged
merged 4 commits into from
Jan 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 16 additions & 1 deletion eng/devices/windows.cake
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,8 @@ Task("Test")
// and if the categories we expected to run match the test result files
if (isControlsProjectTestRun)
{
var expectedCategoriesRanCount = System.IO.File.ReadAllLines(testsToRunFile).Length-1;
var expectedCategories = System.IO.File.ReadAllLines(testsToRunFile);
var expectedCategoriesRanCount = expectedCategories.Length;
var actualResultFileCount = System.IO.Directory.GetFiles(testResultsPath, "TestResults-*.xml").Length;

while (actualResultFileCount < expectedCategoriesRanCount) {
Expand All @@ -344,6 +345,20 @@ Task("Test")
// If it's less, throw an exception to fail the pipeline.
if (actualResultFileCount < expectedCategoriesRanCount)
{
// Grab the category name from the file name
// Ex: "TestResults-com_microsoft_maui_controls_devicetests_Frame.xml" -> "Frame"
var actualFiles = System.IO.Directory.GetFiles(testResultsPath, "TestResults-*.xml");
var actualCategories = actualFiles.Select(x => x.Substring(0, x.Length - 4) // Remove ".xml"
.Split('_').Last()).ToList();

foreach (var category in expectedCategories)
{
if (!actualCategories.Contains(category))
{
Error($"Error: missing test file result for {category}");
}
}

throw new Exception($"Expected test result files: {expectedCategoriesRanCount}, actual files: {actualResultFileCount}, some process(es) might have crashed.");
}
}
Expand Down