Skip to content

Commit c3221bf

Browse files
FodaMike Corsaro
and
Mike Corsaro
authored
[Windows] Fix verification of test count in CI (#19697)
* Test ignore * Test off-by-one * Test print out missing category * Cleanup --------- Co-authored-by: Mike Corsaro <mikecorsaro@microsoft.com>
1 parent 4091224 commit c3221bf

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

eng/devices/windows.cake

+16-1
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,8 @@ Task("Test")
322322
// and if the categories we expected to run match the test result files
323323
if (isControlsProjectTestRun)
324324
{
325-
var expectedCategoriesRanCount = System.IO.File.ReadAllLines(testsToRunFile).Length-1;
325+
var expectedCategories = System.IO.File.ReadAllLines(testsToRunFile);
326+
var expectedCategoriesRanCount = expectedCategories.Length;
326327
var actualResultFileCount = System.IO.Directory.GetFiles(testResultsPath, "TestResults-*.xml").Length;
327328

328329
while (actualResultFileCount < expectedCategoriesRanCount) {
@@ -344,6 +345,20 @@ Task("Test")
344345
// If it's less, throw an exception to fail the pipeline.
345346
if (actualResultFileCount < expectedCategoriesRanCount)
346347
{
348+
// Grab the category name from the file name
349+
// Ex: "TestResults-com_microsoft_maui_controls_devicetests_Frame.xml" -> "Frame"
350+
var actualFiles = System.IO.Directory.GetFiles(testResultsPath, "TestResults-*.xml");
351+
var actualCategories = actualFiles.Select(x => x.Substring(0, x.Length - 4) // Remove ".xml"
352+
.Split('_').Last()).ToList();
353+
354+
foreach (var category in expectedCategories)
355+
{
356+
if (!actualCategories.Contains(category))
357+
{
358+
Error($"Error: missing test file result for {category}");
359+
}
360+
}
361+
347362
throw new Exception($"Expected test result files: {expectedCategoriesRanCount}, actual files: {actualResultFileCount}, some process(es) might have crashed.");
348363
}
349364
}

0 commit comments

Comments
 (0)