Preserve functional test logs on CI (dotnet/extensions#2819)

* Add option to preserve function test logs

* Upload test logs as artifacts

* Preserve binlogs

* Add target to ensure all functional test logs preserved
\n\nCommit migrated from 08aa4560e5
This commit is contained in:
John Luo 2020-01-06 11:40:44 -08:00 committed by GitHub
parent 3ab9051a11
commit d65b7239a6
4 changed files with 15 additions and 3 deletions

View File

@ -295,6 +295,7 @@ namespace Microsoft.AspNetCore.Testing
public string TestName { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } }
public static string GetAssemblyBaseDirectory(System.Reflection.Assembly assembly, string baseDirectory = null) { throw null; }
public static string GetOutputDirectory(System.Reflection.Assembly assembly) { throw null; }
public static bool GetPreserveExistingLogsInOutput(System.Reflection.Assembly assembly) { throw null; }
public static string GetTestClassName(System.Type type) { throw null; }
public static string GetTestMethodName(System.Reflection.MethodInfo method, object[] arguments) { throw null; }
public string GetUniqueFileName(string prefix, string extension) { throw null; }
@ -307,8 +308,9 @@ namespace Microsoft.AspNetCore.Testing
[System.AttributeUsageAttribute(System.AttributeTargets.Assembly, AllowMultiple=false, Inherited=true)]
public partial class TestOutputDirectoryAttribute : System.Attribute
{
public TestOutputDirectoryAttribute(string targetFramework, string baseDirectory = null) { }
public TestOutputDirectoryAttribute(string preserveExistingLogsInOutput, string targetFramework, string baseDirectory = null) { }
public string BaseDirectory { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } }
public bool PreserveExistingLogsInOutput { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } }
public string TargetFramework { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } }
}
[System.ObsoleteAttribute("This API is obsolete and the pattern its usage encouraged should not be used anymore. See https://github.com/aspnet/Extensions/issues/1697 for details.")]

View File

@ -295,6 +295,7 @@ namespace Microsoft.AspNetCore.Testing
public string TestName { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } }
public static string GetAssemblyBaseDirectory(System.Reflection.Assembly assembly, string baseDirectory = null) { throw null; }
public static string GetOutputDirectory(System.Reflection.Assembly assembly) { throw null; }
public static bool GetPreserveExistingLogsInOutput(System.Reflection.Assembly assembly) { throw null; }
public static string GetTestClassName(System.Type type) { throw null; }
public static string GetTestMethodName(System.Reflection.MethodInfo method, object[] arguments) { throw null; }
public string GetUniqueFileName(string prefix, string extension) { throw null; }
@ -307,8 +308,9 @@ namespace Microsoft.AspNetCore.Testing
[System.AttributeUsageAttribute(System.AttributeTargets.Assembly, AllowMultiple=false, Inherited=true)]
public partial class TestOutputDirectoryAttribute : System.Attribute
{
public TestOutputDirectoryAttribute(string targetFramework, string baseDirectory = null) { }
public TestOutputDirectoryAttribute(string preserveExistingLogsInOutput, string targetFramework, string baseDirectory = null) { }
public string BaseDirectory { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } }
public bool PreserveExistingLogsInOutput { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } }
public string TargetFramework { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } }
}
[System.ObsoleteAttribute("This API is obsolete and the pattern its usage encouraged should not be used anymore. See https://github.com/aspnet/Extensions/issues/1697 for details.")]

View File

@ -93,6 +93,12 @@ namespace Microsoft.AspNetCore.Testing
return Path.Combine(baseDirectory, assembly.GetName().Name, attribute.TargetFramework);
}
public static bool GetPreserveExistingLogsInOutput(Assembly assembly)
{
var attribute = assembly.GetCustomAttributes().OfType<TestOutputDirectoryAttribute>().FirstOrDefault();
return attribute.PreserveExistingLogsInOutput;
}
public static string GetTestClassName(Type type)
{
var shortNameAttribute =

View File

@ -8,13 +8,15 @@ namespace Microsoft.AspNetCore.Testing
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false, Inherited = true)]
public class TestOutputDirectoryAttribute : Attribute
{
public TestOutputDirectoryAttribute(string targetFramework, string baseDirectory = null)
public TestOutputDirectoryAttribute(string preserveExistingLogsInOutput, string targetFramework, string baseDirectory = null)
{
TargetFramework = targetFramework;
BaseDirectory = baseDirectory;
PreserveExistingLogsInOutput = bool.Parse(preserveExistingLogsInOutput);
}
public string BaseDirectory { get; }
public string TargetFramework { get; }
public bool PreserveExistingLogsInOutput { get; }
}
}