diff --git a/profiler/test/Datadog.Profiler.IntegrationTests/Helpers/TestApplicationRunner.cs b/profiler/test/Datadog.Profiler.IntegrationTests/Helpers/TestApplicationRunner.cs index 8c4c7f3610ba..517269414679 100644 --- a/profiler/test/Datadog.Profiler.IntegrationTests/Helpers/TestApplicationRunner.cs +++ b/profiler/test/Datadog.Profiler.IntegrationTests/Helpers/TestApplicationRunner.cs @@ -235,9 +235,16 @@ private void RunTest(MockDatadogAgent agent) throw new XunitException("An error occured during the test. See the error output above."); } - Assert.True( - 0 == process.ExitCode, - $"Exit code of \"{Path.GetFileName(process.StartInfo?.FileName ?? string.Empty)}\" should be 0 instead of {process.ExitCode} (= 0x{process.ExitCode.ToString("X")})"); + if (process.ExitCode != 0) + { + _output.WriteLine($"[TestRunner] Process exited with code {process.ExitCode} (0x{process.ExitCode:X})"); + _output.WriteLine($"[TestRunner] Standard output:\n{standardOutput}"); + _output.WriteLine($"[TestRunner] Error output:\n{errorOutput}"); + + Assert.True( + false, + $"Exit code of \"{Path.GetFileName(process.StartInfo?.FileName ?? string.Empty)}\" should be 0 instead of {process.ExitCode} (= 0x{process.ExitCode:X})"); + } } private void SetEnvironmentVariables(StringDictionary environmentVariables, MockDatadogAgent agent) diff --git a/tracer/test/Datadog.Trace.Debugger.IntegrationTests/Helpers/DebuggerSampleProcessHelper.cs b/tracer/test/Datadog.Trace.Debugger.IntegrationTests/Helpers/DebuggerSampleProcessHelper.cs index 0a1920505228..5edcaba5add4 100644 --- a/tracer/test/Datadog.Trace.Debugger.IntegrationTests/Helpers/DebuggerSampleProcessHelper.cs +++ b/tracer/test/Datadog.Trace.Debugger.IntegrationTests/Helpers/DebuggerSampleProcessHelper.cs @@ -8,6 +8,7 @@ using System.Net; using System.Threading.Tasks; using Datadog.Trace.TestHelpers; +using Xunit.Abstractions; namespace Datadog.Trace.Debugger.IntegrationTests.Helpers { @@ -17,12 +18,14 @@ internal class DebuggerSampleProcessHelper : ProcessHelper private readonly string _stopUrl; private readonly string _runUrl; + private readonly ITestOutputHelper _output; - public DebuggerSampleProcessHelper(string baseUrl, Process process, Action onDataReceived = null) + public DebuggerSampleProcessHelper(string baseUrl, Process process, ITestOutputHelper output, Action onDataReceived = null) : base(process, onDataReceived) { _stopUrl = $"{baseUrl}{StopSuffix}"; _runUrl = baseUrl; + _output = output; } internal async Task StopSample() @@ -36,6 +39,13 @@ internal async Task StopSample() throw new InvalidOperationException($"The process did not exit after {timeout}ms"); } + if (Process.ExitCode != 0) + { + _output.WriteLine($"[DebuggerSampleProcessHelper] Process exited with code {Process.ExitCode} (0x{Process.ExitCode:X})"); + _output.WriteLine($"[DebuggerSampleProcessHelper] Standard output:\n{StandardOutput}"); + _output.WriteLine($"[DebuggerSampleProcessHelper] Error output:\n{ErrorOutput}"); + } + ExitCodeException.ThrowIfNonZero(Process.ExitCode); } diff --git a/tracer/test/Datadog.Trace.Debugger.IntegrationTests/Helpers/DebuggerTestHelper.cs b/tracer/test/Datadog.Trace.Debugger.IntegrationTests/Helpers/DebuggerTestHelper.cs index 641bebd24f32..9f079ae4e945 100644 --- a/tracer/test/Datadog.Trace.Debugger.IntegrationTests/Helpers/DebuggerTestHelper.cs +++ b/tracer/test/Datadog.Trace.Debugger.IntegrationTests/Helpers/DebuggerTestHelper.cs @@ -68,7 +68,7 @@ internal static async Task StartSample(TestHelper h var listenUrl = $"{localHost}:{listenPort}/"; var process = await helper.StartSample(agent, $"--test-name {testName} --listen-url {listenUrl}", string.Empty, aspNetCorePort: 5000); - var processHelper = new DebuggerSampleProcessHelper(listenUrl, process); + var processHelper = new DebuggerSampleProcessHelper(listenUrl, process, helper.GetOutput()); return processHelper; } diff --git a/tracer/test/Datadog.Trace.TestHelpers.AutoInstrumentation/TestHelper.cs b/tracer/test/Datadog.Trace.TestHelpers.AutoInstrumentation/TestHelper.cs index e902f1d01440..48746b626f95 100644 --- a/tracer/test/Datadog.Trace.TestHelpers.AutoInstrumentation/TestHelper.cs +++ b/tracer/test/Datadog.Trace.TestHelpers.AutoInstrumentation/TestHelper.cs @@ -71,6 +71,8 @@ protected TestHelper(EnvironmentHelper environmentHelper, ITestOutputHelper outp protected ITestOutputHelper Output { get; } + public ITestOutputHelper GetOutput() => Output; + public virtual void Dispose() { }