Skip to content

Commit

Permalink
[Windows] Fix verification of test count in CI (#19697)
Browse files Browse the repository at this point in the history
* Test ignore

* Test off-by-one

* Test print out missing category

* Cleanup

---------

Co-authored-by: Mike Corsaro <mikecorsaro@microsoft.com>
  • Loading branch information
Foda and Mike Corsaro committed Jan 5, 2024
1 parent 4091224 commit c3221bf
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion eng/devices/windows.cake
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

0 comments on commit c3221bf

Please sign in to comment.