Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Net;
using System.Threading.Tasks;
using Datadog.Trace.TestHelpers;
using Xunit.Abstractions;

namespace Datadog.Trace.Debugger.IntegrationTests.Helpers
{
Expand All @@ -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<string> onDataReceived = null)
public DebuggerSampleProcessHelper(string baseUrl, Process process, ITestOutputHelper output, Action<string> onDataReceived = null)
: base(process, onDataReceived)
{
_stopUrl = $"{baseUrl}{StopSuffix}";
_runUrl = baseUrl;
_output = output;
}

internal async Task StopSample()
Expand All @@ -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})");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if _output is always non null? 🤔 If it is this is all good, otherwise we should maybe add a null check in the if block 🙂

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should never be null. If it is, something pretty weird is going on.

_output.WriteLine($"[DebuggerSampleProcessHelper] Standard output:\n{StandardOutput}");
_output.WriteLine($"[DebuggerSampleProcessHelper] Error output:\n{ErrorOutput}");
}

ExitCodeException.ThrowIfNonZero(Process.ExitCode);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ internal static async Task<DebuggerSampleProcessHelper> 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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ protected TestHelper(EnvironmentHelper environmentHelper, ITestOutputHelper outp

protected ITestOutputHelper Output { get; }

public ITestOutputHelper GetOutput() => Output;

public virtual void Dispose()
{
}
Expand Down
Loading