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:
authorvitek-karas <vitek.karas@microsoft.com>2020-07-21 17:48:17 +0300
committervitek-karas <vitek.karas@microsoft.com>2020-07-21 17:56:25 +0300
commit0f99d1cd4eb3018512fe79ac10fc6811e96f7d36 (patch)
treec7e84aab1f83687903109a7c1d38b38cd2a07f79 /test/Mono.Linker.Tests/TestCasesRunner/ResultChecker.cs
parent95c6b7b715b945a78beeedeade8f9908172aaa0b (diff)
Don't generate warning 2045 due to the attribute type members referencing the type itself
If an attribute is marked for removal of instances, but the linker keeps the attribute type for other reasons (for example because it's used from a copy assembly) then there will be several other references to the attribute type from the code within the attribute type itself. These warnings are useless and should not be generated. Other changes: * Moved link attribute tests into their own separate folder - they don't belong to DataFlow tests * The log verification logic now removes messages which where matched by LogContains attributes, so it's possible to validate that there are not other messages of the same kind by adding LogDoesntContain at the end
Diffstat (limited to 'test/Mono.Linker.Tests/TestCasesRunner/ResultChecker.cs')
-rw-r--r--test/Mono.Linker.Tests/TestCasesRunner/ResultChecker.cs21
1 files changed, 12 insertions, 9 deletions
diff --git a/test/Mono.Linker.Tests/TestCasesRunner/ResultChecker.cs b/test/Mono.Linker.Tests/TestCasesRunner/ResultChecker.cs
index acc48b9db..77fa07f28 100644
--- a/test/Mono.Linker.Tests/TestCasesRunner/ResultChecker.cs
+++ b/test/Mono.Linker.Tests/TestCasesRunner/ResultChecker.cs
@@ -594,19 +594,22 @@ namespace Mono.Linker.Tests.TestCasesRunner
void VerifyLoggedMessages (AssemblyDefinition original, LinkerTestLogger logger)
{
- string allMessages = string.Join (Environment.NewLine, logger.Messages.Select (mc => mc.Message));
-
foreach (var testType in original.AllDefinedTypes ()) {
foreach (var attr in testType.CustomAttributes.Concat (testType.AllMembers ().SelectMany (m => m.CustomAttributes))) {
if (attr.AttributeType.Resolve ().Name == nameof (LogContainsAttribute)) {
var expectedMessage = (string) attr.ConstructorArguments[0].Value;
- Assert.That (() => {
- if ((bool) attr.ConstructorArguments[1].Value)
- return logger.Messages.Any (mc => Regex.IsMatch (mc.Message, expectedMessage));
- return logger.Messages.Any (mc => mc.Message.Contains (expectedMessage));
- },
- $"Expected to find logged message matching `{expectedMessage}`, but no such message was found.{Environment.NewLine}Logged messages:{Environment.NewLine}{allMessages}");
+ List<LinkerTestLogger.MessageRecord> matchedMessages;
+ if ((bool) attr.ConstructorArguments[1].Value)
+ matchedMessages = logger.Messages.Where (mc => Regex.IsMatch (mc.Message, expectedMessage)).ToList ();
+ else
+ matchedMessages = logger.Messages.Where (mc => mc.Message.Contains (expectedMessage)).ToList (); ;
+ Assert.IsTrue (
+ matchedMessages.Count > 0,
+ $"Expected to find logged message matching `{expectedMessage}`, but no such message was found.{Environment.NewLine}Logged messages:{Environment.NewLine}{string.Join (Environment.NewLine, logger.Messages.Select (mc => mc.Message))}");
+
+ foreach (var matchedMessage in matchedMessages)
+ logger.Messages.Remove (matchedMessage);
}
if (attr.AttributeType.Resolve ().Name == nameof (LogDoesNotContainAttribute)) {
@@ -617,7 +620,7 @@ namespace Mono.Linker.Tests.TestCasesRunner
return !Regex.IsMatch (loggedMessage.Message, unexpectedMessage);
return !Regex.IsMatch (loggedMessage.Message, unexpectedMessage);
},
- $"Expected to not find logged message matching `{unexpectedMessage}`, but found:{Environment.NewLine}{loggedMessage.Message}{Environment.NewLine}Logged messages:{Environment.NewLine}{allMessages}");
+ $"Expected to not find logged message matching `{unexpectedMessage}`, but found:{Environment.NewLine}{loggedMessage.Message}{Environment.NewLine}Logged messages:{Environment.NewLine}{string.Join (Environment.NewLine, logger.Messages.Select (mc => mc.Message))}");
}
}
}