Merge pull request #15094 from dotnet/marcpopMSFT-cleanupnugets

Delete some test folders once run to not leave them on the machine
This commit is contained in:
Marc Paine 2022-12-13 16:39:17 -08:00 committed by GitHub
commit ffda9745d6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -234,6 +234,12 @@ namespace EndToEnd.Tests
//check if the template created files
Assert.True(directory.Exists);
Assert.True(directory.EnumerateFileSystemInfos().Any());
// delete test directory for some tests so we aren't leaving behind non-compliant nuget files
if (templateName.Equals("nugetconfig"))
{
directory.Delete(true);
}
}
[WindowsOnlyTheory]
@ -317,7 +323,7 @@ namespace EndToEnd.Tests
public void ItCanCreateTemplateWithDefaultFramework(string templateName)
{
string framework = DetectExpectedDefaultFramework(templateName);
TestTemplateCreateAndBuild(templateName, build: false, framework: framework);
TestTemplateCreateAndBuild(templateName, build: false, framework: framework, deleteTestDirectory: true);
}
/// <summary>
@ -401,7 +407,7 @@ namespace EndToEnd.Tests
throw new Exception("Unsupported version of SDK");
}
private static void TestTemplateCreateAndBuild(string templateName, bool build = true, bool selfContained = false, string language = "", string framework = "")
private static void TestTemplateCreateAndBuild(string templateName, bool build = true, bool selfContained = false, string language = "", string framework = "", bool deleteTestDirectory = false)
{
DirectoryInfo directory = TestAssets.CreateTestDirectory(identifier: string.IsNullOrWhiteSpace(language) ? templateName : $"{templateName}[{language}]");
string projectDirectory = directory.FullName;
@ -454,6 +460,12 @@ namespace EndToEnd.Tests
.Execute(buildArgs)
.Should().Pass();
}
// delete test directory for some tests so we aren't leaving behind non-compliant package files
if (deleteTestDirectory)
{
directory.Delete(true);
}
}
}
}