Skip to content

Commit d65b723

Browse files
author
John Luo
authored
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 dotnet/extensions@08aa456
1 parent 3ab9051 commit d65b723

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

src/Testing/ref/Microsoft.AspNetCore.Testing.net46.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ public TestFileOutputContext(Microsoft.AspNetCore.Testing.TestContext parent) {
295295
public string TestName { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } }
296296
public static string GetAssemblyBaseDirectory(System.Reflection.Assembly assembly, string baseDirectory = null) { throw null; }
297297
public static string GetOutputDirectory(System.Reflection.Assembly assembly) { throw null; }
298+
public static bool GetPreserveExistingLogsInOutput(System.Reflection.Assembly assembly) { throw null; }
298299
public static string GetTestClassName(System.Type type) { throw null; }
299300
public static string GetTestMethodName(System.Reflection.MethodInfo method, object[] arguments) { throw null; }
300301
public string GetUniqueFileName(string prefix, string extension) { throw null; }
@@ -307,8 +308,9 @@ public static partial class TestMethodExtensions
307308
[System.AttributeUsageAttribute(System.AttributeTargets.Assembly, AllowMultiple=false, Inherited=true)]
308309
public partial class TestOutputDirectoryAttribute : System.Attribute
309310
{
310-
public TestOutputDirectoryAttribute(string targetFramework, string baseDirectory = null) { }
311+
public TestOutputDirectoryAttribute(string preserveExistingLogsInOutput, string targetFramework, string baseDirectory = null) { }
311312
public string BaseDirectory { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } }
313+
public bool PreserveExistingLogsInOutput { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } }
312314
public string TargetFramework { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } }
313315
}
314316
[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.")]

src/Testing/ref/Microsoft.AspNetCore.Testing.netstandard2.0.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ public TestFileOutputContext(Microsoft.AspNetCore.Testing.TestContext parent) {
295295
public string TestName { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } }
296296
public static string GetAssemblyBaseDirectory(System.Reflection.Assembly assembly, string baseDirectory = null) { throw null; }
297297
public static string GetOutputDirectory(System.Reflection.Assembly assembly) { throw null; }
298+
public static bool GetPreserveExistingLogsInOutput(System.Reflection.Assembly assembly) { throw null; }
298299
public static string GetTestClassName(System.Type type) { throw null; }
299300
public static string GetTestMethodName(System.Reflection.MethodInfo method, object[] arguments) { throw null; }
300301
public string GetUniqueFileName(string prefix, string extension) { throw null; }
@@ -307,8 +308,9 @@ public static partial class TestMethodExtensions
307308
[System.AttributeUsageAttribute(System.AttributeTargets.Assembly, AllowMultiple=false, Inherited=true)]
308309
public partial class TestOutputDirectoryAttribute : System.Attribute
309310
{
310-
public TestOutputDirectoryAttribute(string targetFramework, string baseDirectory = null) { }
311+
public TestOutputDirectoryAttribute(string preserveExistingLogsInOutput, string targetFramework, string baseDirectory = null) { }
311312
public string BaseDirectory { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } }
313+
public bool PreserveExistingLogsInOutput { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } }
312314
public string TargetFramework { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } }
313315
}
314316
[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.")]

src/Testing/src/TestFileOutputContext.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,12 @@ public static string GetAssemblyBaseDirectory(Assembly assembly, string baseDire
9393
return Path.Combine(baseDirectory, assembly.GetName().Name, attribute.TargetFramework);
9494
}
9595

96+
public static bool GetPreserveExistingLogsInOutput(Assembly assembly)
97+
{
98+
var attribute = assembly.GetCustomAttributes().OfType<TestOutputDirectoryAttribute>().FirstOrDefault();
99+
return attribute.PreserveExistingLogsInOutput;
100+
}
101+
96102
public static string GetTestClassName(Type type)
97103
{
98104
var shortNameAttribute =

src/Testing/src/TestOutputDirectoryAttribute.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ namespace Microsoft.AspNetCore.Testing
88
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false, Inherited = true)]
99
public class TestOutputDirectoryAttribute : Attribute
1010
{
11-
public TestOutputDirectoryAttribute(string targetFramework, string baseDirectory = null)
11+
public TestOutputDirectoryAttribute(string preserveExistingLogsInOutput, string targetFramework, string baseDirectory = null)
1212
{
1313
TargetFramework = targetFramework;
1414
BaseDirectory = baseDirectory;
15+
PreserveExistingLogsInOutput = bool.Parse(preserveExistingLogsInOutput);
1516
}
1617

1718
public string BaseDirectory { get; }
1819
public string TargetFramework { get; }
20+
public bool PreserveExistingLogsInOutput { get; }
1921
}
2022
}

0 commit comments

Comments
 (0)