Skip to content

Commit

Permalink
Fix integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewlock committed Jan 3, 2025
1 parent 97c36fb commit 6f6e684
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,14 @@ public async Task InstrumentsDotNetTest()
public async Task WhenUsingRelativeTracerHome_InstrumentsApp()
{
SetEnvironmentVariable("DD_INTERNAL_WAIT_FOR_DEBUGGER_ATTACH", "1");
var path = Path.GetRelativePath(EnvironmentHelper.GetSampleApplicationOutputDirectory(), EnvironmentHelper.MonitoringHome);
// the working dir when we run the app is the _test_ project, not the app itself, so we need to be relative to that
// This is a perfect example of why we don't recommend using relative paths for these variables
var workingDir = Environment.CurrentDirectory;
var monitoringHome = EnvironmentHelper.MonitoringHome;
var path = PathUtil.GetRelativePath(workingDir, monitoringHome);
var effectivePath = Path.GetFullPath(Path.Combine(workingDir, path));
Output.WriteLine($"Using DD_DOTNET_TRACER_HOME={path} with workingDir={workingDir} and monitoringHome={monitoringHome}, giving an effective path of {effectivePath}");
SetEnvironmentVariable("DD_DOTNET_TRACER_HOME", path);
Output.WriteLine("Using DD_DOTNET_TRACER_HOME " + path);
using var agent = EnvironmentHelper.GetMockAgent(useTelemetry: true);
using var processResult = await RunSampleAndWaitForExit(agent, "traces 1");
agent.Spans.Should().NotBeEmpty();
Expand All @@ -152,7 +157,7 @@ public async Task WhenUsingPathWithDotsInInTracerHome_InstrumentsApp()
{
SetEnvironmentVariable("DD_INTERNAL_WAIT_FOR_DEBUGGER_ATTACH", "1");
// not using Path.Combine here because it resolves the .. and we want it in the path
var path = EnvironmentHelper.MonitoringHome + "/../" + Path.GetFileName(EnvironmentHelper.MonitoringHome);
var path = Path.Combine(EnvironmentHelper.MonitoringHome, "..", Path.GetFileName(EnvironmentHelper.MonitoringHome)!);
Output.WriteLine("Using DD_DOTNET_TRACER_HOME " + path);
SetEnvironmentVariable("DD_DOTNET_TRACER_HOME", path);
using var agent = EnvironmentHelper.GetMockAgent(useTelemetry: true);
Expand Down

0 comments on commit 6f6e684

Please sign in to comment.