diff options
Diffstat (limited to 'linker/Tests/TestCasesRunner/TestCaseMetadaProvider.cs')
-rw-r--r-- | linker/Tests/TestCasesRunner/TestCaseMetadaProvider.cs | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/linker/Tests/TestCasesRunner/TestCaseMetadaProvider.cs b/linker/Tests/TestCasesRunner/TestCaseMetadaProvider.cs index 8055cfccb..46b981793 100644 --- a/linker/Tests/TestCasesRunner/TestCaseMetadaProvider.cs +++ b/linker/Tests/TestCasesRunner/TestCaseMetadaProvider.cs @@ -73,6 +73,27 @@ namespace Mono.Linker.Tests.TestCasesRunner { } } + public virtual IEnumerable<SetupCompileInfo> GetSetupCompileAssembliesBefore () + { + return _testCaseTypeDefinition.CustomAttributes + .Where (attr => attr.AttributeType.Name == nameof (SetupCompileBeforeAttribute)) + .Select (CreateSetupCompileAssemblyInfo); + } + + public virtual IEnumerable<SetupCompileInfo> GetSetupCompileAssembliesAfter () + { + return _testCaseTypeDefinition.CustomAttributes + .Where (attr => attr.AttributeType.Name == nameof (SetupCompileAfterAttribute)) + .Select (CreateSetupCompileAssemblyInfo); + } + + public virtual IEnumerable<string> GetDefines () + { + return _testCaseTypeDefinition.CustomAttributes + .Where (attr => attr.AttributeType.Name == nameof (DefineAttribute)) + .Select (attr => (string) attr.ConstructorArguments.First ().Value); + } + T GetOptionAttributeValue<T> (string attributeName, T defaultValue) { var attribute = _testCaseTypeDefinition.CustomAttributes.FirstOrDefault (attr => attr.AttributeType.Name == attributeName); @@ -81,5 +102,18 @@ namespace Mono.Linker.Tests.TestCasesRunner { return defaultValue; } + + private SetupCompileInfo CreateSetupCompileAssemblyInfo (CustomAttribute attribute) + { + var ctorArguments = attribute.ConstructorArguments; + return new SetupCompileInfo + { + OutputName = (string) ctorArguments [0].Value, + SourceFiles = ((CustomAttributeArgument []) ctorArguments [1].Value).Select (arg => _testCase.SourceFile.Parent.Combine (arg.Value.ToString ())).ToArray (), + References = ((CustomAttributeArgument []) ctorArguments [2].Value)?.Select (arg => arg.Value.ToString ()).ToArray (), + Defines = ((CustomAttributeArgument []) ctorArguments [3].Value)?.Select (arg => arg.Value.ToString ()).ToArray (), + AddAsReference = ctorArguments.Count >= 5 ? (bool) ctorArguments [4].Value : true + }; + } } }
\ No newline at end of file |