Skip to content

Commit 98c4dc7

Browse files
committed
Check for complete result, including label
1 parent 93b9e99 commit 98c4dc7

File tree

3 files changed

+5
-34
lines changed

3 files changed

+5
-34
lines changed

recipe/test-reports.cake

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,11 @@ public class PackageTestReport
1717

1818
if (expectedResult != null)
1919
{
20-
ReportMissingFiles();
21-
2220
if (actualResult.OverallResult == null)
2321
Errors.Add(" The test-run element has no result attribute.");
2422
else if (expectedResult.OverallResult != actualResult.OverallResult)
2523
Errors.Add($" Expected: Overall Result = {expectedResult.OverallResult} But was: {actualResult.OverallResult}");
24+
2625
CheckCounter("Test Count", expectedResult.Total, actualResult.Total);
2726
CheckCounter("Passed", expectedResult.Passed, actualResult.Passed);
2827
CheckCounter("Failed", expectedResult.Failed, actualResult.Failed);
@@ -121,35 +120,6 @@ public class PackageTestReport
121120
writer.WriteLine(" WARNING: " + warning);
122121
}
123122

124-
// File level errors, like missing or mal-formatted files, need to be highlighted
125-
// because otherwise it's hard to detect the cause of the problem without debugging.
126-
// This method finds and reports that type of error.
127-
private void ReportMissingFiles()
128-
{
129-
// Start with all the top-level test suites. Note that files that
130-
// cannot be found show up as Unknown as do unsupported file types.
131-
var suites = Result.Xml.SelectNodes(
132-
"//test-suite[@type='Unknown'] | //test-suite[@type='Project'] | //test-suite[@type='Assembly']");
133-
134-
// If there is no top-level suite, it generally means the file format could not be interpreted
135-
if (suites.Count == 0)
136-
Errors.Add(" No top-level suites! Possible empty command-line or misformed project.");
137-
138-
foreach (XmlNode suite in suites)
139-
{
140-
// Narrow down to the specific failures we want
141-
string runState = GetAttribute(suite, "runstate");
142-
string suiteResult = GetAttribute(suite, "result");
143-
string label = GetAttribute(suite, "label");
144-
string site = suite.Attributes["site"]?.Value ?? "Test";
145-
if (runState == "NotRunnable" || suiteResult == "Failed" && site == "Test" && (label == "Invalid" || label == "Error"))
146-
{
147-
string message = suite.SelectSingleNode("reason/message")?.InnerText;
148-
Errors.Add($" {message}");
149-
}
150-
}
151-
}
152-
153123
private void CheckCounter(string label, int expected, int actual)
154124
{
155125
// If expected value of counter is negative, it means no check is needed

recipe/test-results.cake

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ public class ActualResult : TestResultSummary
5757
throw new Exception("Top-level <test-run> or <test-suite> element not found.");
5858

5959
OverallResult = GetAttribute(Xml, "result");
60+
var label = GetAttribute(Xml, "label");
61+
if (label != null)
62+
OverallResult += ":" + label;
6063
Total = IntAttribute(Xml, "total");
6164
Passed = IntAttribute(Xml, "passed");
6265
Failed = IntAttribute(Xml, "failed");
@@ -66,7 +69,7 @@ public class ActualResult : TestResultSummary
6669

6770
var assemblies = new List<ActualAssemblyResult>();
6871

69-
foreach (XmlNode node in Xml.SelectNodes("//test-suite[@type='Assembly']"))
72+
foreach (XmlNode node in Xml.SelectNodes("//test-suite[@type='Assembly'] | //test-suite[@type='Unknown']"))
7073
assemblies.Add(new ActualAssemblyResult(node));
7174

7275
Assemblies = assemblies.ToArray();

recipe/test-runners.cake

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,6 @@ public abstract class InstallableTestRunner : TestRunner
114114
Version = version;
115115
}
116116

117-
//private bool IsChocolateyPackage => PackageId.Contains('-'); // Hack!
118-
119117
protected FilePath ExecutableRelativePath { get; set; }
120118
protected bool IsDotNetTool { get; set; } = false;
121119

0 commit comments

Comments
 (0)