Preserve functional test logs on CI (#2819)
* Add option to preserve function test logs * Upload test logs as artifacts * Preserve binlogs * Add target to ensure all functional test logs preserved
This commit is contained in:
parent
221985c254
commit
b6e5fd8671
|
|
@ -222,7 +222,7 @@ namespace Microsoft.Extensions.Logging.Testing
|
||||||
|
|
||||||
// Try to clear previous logs, continue if it fails.
|
// Try to clear previous logs, continue if it fails.
|
||||||
var assemblyBaseDirectory = TestFileOutputContext.GetAssemblyBaseDirectory(assembly);
|
var assemblyBaseDirectory = TestFileOutputContext.GetAssemblyBaseDirectory(assembly);
|
||||||
if (!string.IsNullOrEmpty(assemblyBaseDirectory))
|
if (!string.IsNullOrEmpty(assemblyBaseDirectory) && !TestFileOutputContext.GetPreserveExistingLogsInOutput(assembly))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,8 @@ namespace Microsoft.Extensions.Logging.Testing
|
||||||
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false)]
|
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false)]
|
||||||
public class TestFrameworkFileLoggerAttribute : TestOutputDirectoryAttribute
|
public class TestFrameworkFileLoggerAttribute : TestOutputDirectoryAttribute
|
||||||
{
|
{
|
||||||
public TestFrameworkFileLoggerAttribute(string tfm, string baseDirectory = null)
|
public TestFrameworkFileLoggerAttribute(string preserveExistingLogsInOutput, string tfm, string baseDirectory = null)
|
||||||
: base(tfm, baseDirectory)
|
: base(preserveExistingLogsInOutput, tfm, baseDirectory)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,11 @@
|
||||||
<Target Name="SetLoggingTestingAssemblyAttributes"
|
<Target Name="SetLoggingTestingAssemblyAttributes"
|
||||||
BeforeTargets="GetAssemblyAttributes"
|
BeforeTargets="GetAssemblyAttributes"
|
||||||
Condition="'$(GenerateLoggingTestingAssemblyAttributes)' != 'false'">
|
Condition="'$(GenerateLoggingTestingAssemblyAttributes)' != 'false'">
|
||||||
|
<PropertyGroup>
|
||||||
|
<PreserveExistingLogsInOutput Condition="'$(PreserveExistingLogsInOutput)' == '' AND '$(ContinuousIntegrationBuild)' == 'true'">true</PreserveExistingLogsInOutput>
|
||||||
|
<PreserveExistingLogsInOutput Condition="'$(PreserveExistingLogsInOutput)' == ''">false</PreserveExistingLogsInOutput>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<AssemblyAttribute Include="Xunit.TestFramework">
|
<AssemblyAttribute Include="Xunit.TestFramework">
|
||||||
<_Parameter1>Microsoft.AspNetCore.Testing.AspNetTestFramework</_Parameter1>
|
<_Parameter1>Microsoft.AspNetCore.Testing.AspNetTestFramework</_Parameter1>
|
||||||
|
|
@ -16,8 +21,9 @@
|
||||||
</AssemblyAttribute>
|
</AssemblyAttribute>
|
||||||
|
|
||||||
<AssemblyAttribute Include="Microsoft.Extensions.Logging.Testing.TestFrameworkFileLoggerAttribute">
|
<AssemblyAttribute Include="Microsoft.Extensions.Logging.Testing.TestFrameworkFileLoggerAttribute">
|
||||||
<_Parameter1>$(TargetFramework)</_Parameter1>
|
<_Parameter1>$(PreserveExistingLogsInOutput)</_Parameter1>
|
||||||
<_Parameter2 Condition="'$(LoggingTestingDisableFileLogging)' != 'true'">$(LoggingTestingFileLoggingDirectory)</_Parameter2>
|
<_Parameter2>$(TargetFramework)</_Parameter2>
|
||||||
|
<_Parameter3 Condition="'$(LoggingTestingDisableFileLogging)' != 'true'">$(LoggingTestingFileLoggingDirectory)</_Parameter3>
|
||||||
</AssemblyAttribute>
|
</AssemblyAttribute>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Target>
|
</Target>
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ using System.Reflection;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Testing;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
namespace Microsoft.Extensions.Logging.Testing.Tests
|
namespace Microsoft.Extensions.Logging.Testing.Tests
|
||||||
|
|
@ -18,6 +19,17 @@ namespace Microsoft.Extensions.Logging.Testing.Tests
|
||||||
private static readonly string ThisAssemblyName = ThisAssembly.GetName().Name;
|
private static readonly string ThisAssemblyName = ThisAssembly.GetName().Name;
|
||||||
private static readonly string TFM = new DirectoryInfo(AppContext.BaseDirectory).Name;
|
private static readonly string TFM = new DirectoryInfo(AppContext.BaseDirectory).Name;
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void FunctionalLogs_LogsPreservedFromNonFlakyRun()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
[Flaky("http://example.com", FlakyOn.All)]
|
||||||
|
public void FunctionalLogs_LogsPreservedFromFlakyRun()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ForAssembly_ReturnsSameInstanceForSameAssembly()
|
public void ForAssembly_ReturnsSameInstanceForSameAssembly()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue