Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefer AGENT_TEMPDIRECTORY if available #2752

Merged
1 commit merged into from
Feb 16, 2021
Merged
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
18 changes: 12 additions & 6 deletions test/Microsoft.TestPlatform.TestUtilities/IntegrationTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -725,14 +725,20 @@ protected string BuildMultipleAssemblyPath(params string[] assetNames)
return string.Join(" ", assertFullPaths);
}

/// <summary>
/// Creates an unique temporary directory for storing test results.
/// </summary>
/// <returns>
/// Path of the created directory.
/// </returns>
protected static string GetResultsDirectory()
{
var directoryPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());

if (!Directory.Exists(directoryPath))
{
Directory.CreateDirectory(directoryPath);
}
// AGENT_TEMPDIRECTORY is AzureDevops variable, which is set to path
// that is cleaned up after every job. This is preferable to use over
// just the normal temp.
var temp = Environment.GetEnvironmentVariable("AGENT_TEMPDIRECTORY") ?? Path.GetTempPath();
var directoryPath = Path.Combine(temp, Guid.NewGuid().ToString("n"));
Directory.CreateDirectory(directoryPath);

return directoryPath;
}
Expand Down