Maintain test artifacts
Improved test diagnostics Providing diagnostics about failed process. Workaround for https://github.com/NuGet/Home/issues/1977 get past crossgen errors!
This commit is contained in:
parent
066bebcc6c
commit
a66546d8fb
24 changed files with 81 additions and 49 deletions
|
@ -10,22 +10,34 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
{
|
||||
public sealed class TempRoot : IDisposable
|
||||
{
|
||||
private static readonly bool DoDispose;
|
||||
private readonly List<IDisposable> _temps = new List<IDisposable>();
|
||||
public static readonly string Root;
|
||||
|
||||
static TempRoot()
|
||||
{
|
||||
Root = Path.Combine(Path.GetTempPath(), "DotnetCLITests");
|
||||
var persistedRoot = Environment.GetEnvironmentVariable("TEST_ARTIFACTS");
|
||||
|
||||
if (string.IsNullOrWhiteSpace(persistedRoot))
|
||||
{
|
||||
Root = Path.Combine(Path.GetTempPath(), "DotnetCLITests");
|
||||
DoDispose = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Root = persistedRoot;
|
||||
DoDispose = false;
|
||||
}
|
||||
|
||||
Directory.CreateDirectory(Root);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (_temps != null)
|
||||
{
|
||||
DisposeAll(_temps);
|
||||
_temps.Clear();
|
||||
}
|
||||
if (!DoDispose || _temps == null) return;
|
||||
|
||||
DisposeAll(_temps);
|
||||
_temps.Clear();
|
||||
}
|
||||
|
||||
private static void DisposeAll(IEnumerable<IDisposable> temps)
|
||||
|
@ -34,10 +46,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
{
|
||||
try
|
||||
{
|
||||
if (temp != null)
|
||||
{
|
||||
temp.Dispose();
|
||||
}
|
||||
temp?.Dispose();
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue