Fix test logic for verifying template uninstallation. Now respects global.json for SDK selection.

This commit is contained in:
Steve Sanderson 2017-10-31 15:32:56 +00:00
parent 0a077a21f8
commit a067713a96
1 changed files with 16 additions and 11 deletions

View File

@ -73,21 +73,26 @@ namespace Templates.Test.Helpers
private static void VerifyCannotFindTemplate(ITestOutputHelper output, string templateName)
{
// Verify we really did remove the previous templates
var tempDir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString("D"));
var tempDir = Path.Combine(Directory.GetCurrentDirectory(), Guid.NewGuid().ToString("D"));
Directory.CreateDirectory(tempDir);
var proc = ProcessEx.Run(
output,
tempDir,
"dotnet",
$"new \"{templateName}\"");
proc.WaitForExit(assertSuccess: false);
if (!proc.Error.Contains($"No templates matched the input template name: {templateName}."))
try
{
throw new InvalidOperationException($"Failed to uninstall previous templates. The template '{templateName}' could still be found.");
var proc = ProcessEx.Run(
output,
tempDir,
"dotnet",
$"new \"{templateName}\"");
proc.WaitForExit(assertSuccess: false);
if (!proc.Error.Contains($"No templates matched the input template name: {templateName}."))
{
throw new InvalidOperationException($"Failed to uninstall previous templates. The template '{templateName}' could still be found.");
}
}
finally
{
Directory.Delete(tempDir);
}
Directory.Delete(tempDir);
}
private static string FindAncestorDirectoryContaining(string filename)