diff options
author | Mike Voorhees <michaelv@unity3d.com> | 2017-10-23 17:24:45 +0300 |
---|---|---|
committer | Marek Safar <marek.safar@gmail.com> | 2017-10-23 20:50:50 +0300 |
commit | 75f6151c817268ee236139573e5117859e7925f8 (patch) | |
tree | 360e56fd163aadf114a3de071cbd4a5d7f9cad27 | |
parent | 772f0bd15fe39f697aee94eb2f1328b1db0a7190 (diff) |
Add ability to customize the name of the output assembly in tests
4 files changed, 22 insertions, 2 deletions
diff --git a/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupCompileAssemblyNameAttribute.cs b/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupCompileAssemblyNameAttribute.cs new file mode 100644 index 000000000..ceb0842eb --- /dev/null +++ b/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupCompileAssemblyNameAttribute.cs @@ -0,0 +1,12 @@ +using System; + +namespace Mono.Linker.Tests.Cases.Expectations.Metadata { + [AttributeUsage (AttributeTargets.Class, AllowMultiple = false)] + public class SetupCompileAssemblyNameAttribute : BaseMetadataAttribute { + public SetupCompileAssemblyNameAttribute (string outputName) + { + if (string.IsNullOrEmpty (outputName)) + throw new ArgumentNullException (nameof (outputName)); + } + } +}
\ No newline at end of file diff --git a/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Mono.Linker.Tests.Cases.Expectations.csproj b/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Mono.Linker.Tests.Cases.Expectations.csproj index 5c063734c..a33c18638 100644 --- a/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Mono.Linker.Tests.Cases.Expectations.csproj +++ b/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Mono.Linker.Tests.Cases.Expectations.csproj @@ -52,6 +52,7 @@ <Compile Include="Assertions\SkipPeVerifyAttribute.cs" /> <Compile Include="Metadata\BaseMetadataAttribute.cs" /> <Compile Include="Metadata\SetupCompileAfterAttribute.cs" /> + <Compile Include="Metadata\SetupCompileAssemblyNameAttribute.cs" /> <Compile Include="Metadata\SetupCompileBeforeAttribute.cs" /> <Compile Include="Metadata\DefineAttribute.cs" /> <Compile Include="Metadata\IncludeBlacklistStepAttribute.cs" /> diff --git a/linker/Tests/TestCasesRunner/TestCaseMetadaProvider.cs b/linker/Tests/TestCasesRunner/TestCaseMetadaProvider.cs index fbd5f0fe3..f26ad15f2 100644 --- a/linker/Tests/TestCasesRunner/TestCaseMetadaProvider.cs +++ b/linker/Tests/TestCasesRunner/TestCaseMetadaProvider.cs @@ -101,6 +101,11 @@ namespace Mono.Linker.Tests.TestCasesRunner { .Select (attr => (string) attr.ConstructorArguments.First ().Value); } + public virtual string GetAssemblyName () + { + return GetOptionAttributeValue (nameof (SetupCompileAssemblyNameAttribute), "test.exe"); + } + T GetOptionAttributeValue<T> (string attributeName, T defaultValue) { var attribute = _testCaseTypeDefinition.CustomAttributes.FirstOrDefault (attr => attr.AttributeType.Name == attributeName); diff --git a/linker/Tests/TestCasesRunner/TestRunner.cs b/linker/Tests/TestCasesRunner/TestRunner.cs index b9255435a..141241f93 100644 --- a/linker/Tests/TestCasesRunner/TestRunner.cs +++ b/linker/Tests/TestCasesRunner/TestRunner.cs @@ -40,11 +40,13 @@ namespace Mono.Linker.Tests.TestCasesRunner { var compiler = _factory.CreateCompiler (sandbox, metadataProvider); var sourceFiles = sandbox.SourceFiles.Select(s => s.ToString()).ToArray(); + var assemblyName = metadataProvider.GetAssemblyName (); + var references = metadataProvider.GetReferencedAssemblies(sandbox.InputDirectory); - var inputAssemblyPath = compiler.CompileTestIn (sandbox.InputDirectory, "test.exe", sourceFiles, references, null); + var inputAssemblyPath = compiler.CompileTestIn (sandbox.InputDirectory, assemblyName, sourceFiles, references, null); references = metadataProvider.GetReferencedAssemblies(sandbox.ExpectationsDirectory); - var expectationsAssemblyPath = compiler.CompileTestIn (sandbox.ExpectationsDirectory, "test.exe", sourceFiles, references, new [] { "INCLUDE_EXPECTATIONS" }); + var expectationsAssemblyPath = compiler.CompileTestIn (sandbox.ExpectationsDirectory, assemblyName, sourceFiles, references, new [] { "INCLUDE_EXPECTATIONS" }); return new ManagedCompilationResult (inputAssemblyPath, expectationsAssemblyPath); } /* |