Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/linker.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Gocke <angocke@microsoft.com>2021-05-14 21:23:49 +0300
committerGitHub <noreply@github.com>2021-05-14 21:23:49 +0300
commit7a5c445a69359415b7ff18b91cd24472ef9509ff (patch)
treeea593653ccd799848952371eb210a3260942d121
parent82e3d7cf6256e9cf477ab011dba5812a1ccca49d (diff)
Try to re-enable RequiresCapability tests (#2029)
Stops looking for the first file in the `RequiresCapability` directory and instead looks at all the files.
-rw-r--r--test/ILLink.RoslynAnalyzer.Tests/LinkerTestCases.cs2
-rw-r--r--test/ILLink.RoslynAnalyzer.Tests/TestCaseUtils.cs47
2 files changed, 21 insertions, 28 deletions
diff --git a/test/ILLink.RoslynAnalyzer.Tests/LinkerTestCases.cs b/test/ILLink.RoslynAnalyzer.Tests/LinkerTestCases.cs
index 3eea37eaa..c26f6f9a4 100644
--- a/test/ILLink.RoslynAnalyzer.Tests/LinkerTestCases.cs
+++ b/test/ILLink.RoslynAnalyzer.Tests/LinkerTestCases.cs
@@ -13,7 +13,7 @@ namespace ILLink.RoslynAnalyzer.Tests
/// </summary>
public class LinkerTestCases : TestCaseUtils
{
- //[Theory]
+ [Theory]
[MemberData (nameof (GetTestData), parameters: nameof (RequiresCapability))]
public void RequiresCapability (MethodDeclarationSyntax m, List<AttributeSyntax> attrs)
{
diff --git a/test/ILLink.RoslynAnalyzer.Tests/TestCaseUtils.cs b/test/ILLink.RoslynAnalyzer.Tests/TestCaseUtils.cs
index ff7e06932..3228ccc96 100644
--- a/test/ILLink.RoslynAnalyzer.Tests/TestCaseUtils.cs
+++ b/test/ILLink.RoslynAnalyzer.Tests/TestCaseUtils.cs
@@ -14,40 +14,33 @@ using Xunit;
namespace ILLink.RoslynAnalyzer.Tests
{
- public class TestCaseUtils
+ public abstract class TestCaseUtils
{
public static IEnumerable<object[]> GetTestData (string testSuiteName)
{
- var testFile = File.ReadAllText (s_testFiles[testSuiteName][0]);
+ foreach (var testFile in s_testFiles[testSuiteName]) {
- var root = CSharpSyntaxTree.ParseText (testFile).GetRoot ();
+ var root = CSharpSyntaxTree.ParseText (File.ReadAllText (testFile)).GetRoot ();
- var attributes = root.DescendantNodes ()
- .OfType<AttributeSyntax> ()
- .Where (a => IsWellKnown (a));
-
- var methodsXattributes = root.DescendantNodes ()
- .OfType<MethodDeclarationSyntax> ()
- .Select (m => (m!, m.AttributeLists.SelectMany (
- al => al.Attributes.Where (a => IsWellKnown (a)))
- .ToList ()))
- .Where (mXattrs => mXattrs.Item2.Count > 0)
- .Distinct ()
- .ToList ();
-
- foreach (var (m, attrs) in methodsXattributes) {
- yield return new object[] { m, attrs };
- }
+ foreach (var node in root.DescendantNodes ()) {
+ if (node is MethodDeclarationSyntax m) {
+ var attrs = m.AttributeLists.SelectMany (al => al.Attributes.Where (IsWellKnown)).ToList ();
+ if (attrs.Count > 0) {
+ yield return new object[] { m, attrs };
+ }
+ }
+ }
- static bool IsWellKnown (AttributeSyntax attr)
- {
- switch (attr.Name.ToString ()) {
- case "ExpectedWarning":
- case "LogContains":
- case "LogDoesNotContain":
- return true;
+ static bool IsWellKnown (AttributeSyntax attr)
+ {
+ switch (attr.Name.ToString ()) {
+ case "ExpectedWarning":
+ case "LogContains":
+ case "LogDoesNotContain":
+ return true;
+ }
+ return false;
}
- return false;
}
}