diff options
author | Mateo Torres-Ruiz <mateoatr@users.noreply.github.com> | 2020-05-13 09:58:58 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-13 09:58:58 +0300 |
commit | df72dcfc27e27735c84c68507426a568799b66e9 (patch) | |
tree | d8f6b31389735e578d6fb960cb955fefa834962d /test/Mono.Linker.Tests/TestCasesRunner/ResultChecker.cs | |
parent | ffec224a2a69f0cde4c43d9c90090dcb294ca6c6 (diff) |
Use MessageContainer for logging errors (#1155)
* Log errors via MessageContainer
* Use LinkerErrorExceptions for all throws. Don't stop linker on first error found.
* Move FoundErrors to LinkContext and clean exceptions.
* Use same code for errors with same message.
* Fix test and whitespace formatting
* Update exit message
Co-authored-by: Marek Safar <marek.safar@gmail.com>
* Add error for unexpected scenarios.
* Print all inner exceptions.
* Update FeatureSubstitutionsInvalid test.
* Update docs/error-codes.md
Co-authored-by: Sven Boemer <sbomer@gmail.com>
* Print all inner exceptions in LinkerFatalErrorException
* Whitespace formatting
Co-authored-by: Marek Safar <marek.safar@gmail.com>
Co-authored-by: Sven Boemer <sbomer@gmail.com>
Diffstat (limited to 'test/Mono.Linker.Tests/TestCasesRunner/ResultChecker.cs')
-rw-r--r-- | test/Mono.Linker.Tests/TestCasesRunner/ResultChecker.cs | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/test/Mono.Linker.Tests/TestCasesRunner/ResultChecker.cs b/test/Mono.Linker.Tests/TestCasesRunner/ResultChecker.cs index 0fa22b3b1..bd5ec176d 100644 --- a/test/Mono.Linker.Tests/TestCasesRunner/ResultChecker.cs +++ b/test/Mono.Linker.Tests/TestCasesRunner/ResultChecker.cs @@ -42,27 +42,26 @@ namespace Mono.Linker.Tests.TestCasesRunner public virtual void Check (LinkedTestCaseResult linkResult) { - Assert.IsTrue (linkResult.OutputAssemblyPath.FileExists (), $"The linked output assembly was not found. Expected at {linkResult.OutputAssemblyPath}"); - InitializeResolvers (linkResult); try { var original = ResolveOriginalsAssembly (linkResult.ExpectationsAssemblyPath.FileNameWithoutExtension); - var linked = ResolveLinkedAssembly (linkResult.OutputAssemblyPath.FileNameWithoutExtension); + if (!HasAttribute (original, nameof (NoLinkedOutputAttribute))) { + Assert.IsTrue (linkResult.OutputAssemblyPath.FileExists (), $"The linked output assembly was not found. Expected at {linkResult.OutputAssemblyPath}"); + var linked = ResolveLinkedAssembly (linkResult.OutputAssemblyPath.FileNameWithoutExtension); - InitialChecking (linkResult, original, linked); + InitialChecking (linkResult, original, linked); - PerformOutputAssemblyChecks (original, linkResult.OutputAssemblyPath.Parent); - PerformOutputSymbolChecks (original, linkResult.OutputAssemblyPath.Parent); + PerformOutputAssemblyChecks (original, linkResult.OutputAssemblyPath.Parent); + PerformOutputSymbolChecks (original, linkResult.OutputAssemblyPath.Parent); - if (!original.MainModule.GetType (linkResult.TestCase.ReconstructedFullTypeName).CustomAttributes - .Any (attr => attr.AttributeType.Name == nameof (SkipKeptItemsValidationAttribute))) { - CreateAssemblyChecker (original, linked).Verify (); + if (!HasAttribute (original.MainModule.GetType (linkResult.TestCase.ReconstructedFullTypeName), nameof (SkipKeptItemsValidationAttribute))) { + CreateAssemblyChecker (original, linked).Verify (); + } } VerifyLinkingOfOtherAssemblies (original); - - AdditionalChecking (linkResult, original, linked); + AdditionalChecking (linkResult, original); } finally { _originalsResolver.Dispose (); _linkedResolver.Dispose (); @@ -162,7 +161,7 @@ namespace Mono.Linker.Tests.TestCasesRunner } } - protected virtual void AdditionalChecking (LinkedTestCaseResult linkResult, AssemblyDefinition original, AssemblyDefinition linked) + protected virtual void AdditionalChecking (LinkedTestCaseResult linkResult, AssemblyDefinition original) { VerifyLoggedMessages (original, linkResult.Logger); VerifyRecordedDependencies (original, linkResult.Customizations.DependencyRecorder); @@ -904,5 +903,17 @@ namespace Mono.Linker.Tests.TestCasesRunner { return attr.AttributeType.Resolve ().DerivesFrom (nameof (BaseInAssemblyAttribute)); } + + bool HasAttribute (ICustomAttributeProvider caProvider, string attributeName) + { + if (caProvider is AssemblyDefinition assembly && assembly.EntryPoint != null) + return assembly.EntryPoint.DeclaringType.CustomAttributes + .Any (attr => attr.AttributeType.Name == attributeName); + + if (caProvider is TypeDefinition type) + return type.CustomAttributes.Any (attr => attr.AttributeType.Name == attributeName); + + return false; + } } }
\ No newline at end of file |