Add Binding redirects tests

This commit is contained in:
Sridhar Periyasamy 2016-04-21 13:41:22 -07:00
parent 4ccd88d00e
commit c82d3cc08d
25 changed files with 645 additions and 55 deletions

View file

@ -14,6 +14,8 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
public class TestCommand
{
protected string _command;
private string _baseDirectory;
public string WorkingDirectory { get; set; }
@ -24,6 +26,11 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
public TestCommand(string command)
{
_command = command;
#if NET451
_baseDirectory = AppDomain.CurrentDomain.BaseDirectory;
#else
_baseDirectory = AppContext.BaseDirectory;
#endif
}
public virtual CommandResult Execute(string args = "")
@ -63,7 +70,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
var command = _command;
ResolveCommand(ref command, ref args);
var commandPath = Env.GetCommandPath(command, ".exe", ".cmd", "") ??
Env.GetCommandPathFromRootPath(AppContext.BaseDirectory, command, ".exe", ".cmd", "");
Env.GetCommandPathFromRootPath(_baseDirectory, command, ".exe", ".cmd", "");
Console.WriteLine($"Executing (Captured Output) - {commandPath} {args}");
@ -102,7 +109,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
if (!Path.IsPathRooted(executable))
{
executable = Env.GetCommandPath(executable) ??
Env.GetCommandPathFromRootPath(AppContext.BaseDirectory, executable);
Env.GetCommandPathFromRootPath(_baseDirectory, executable);
}
}
@ -153,12 +160,17 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
Arguments = args,
RedirectStandardError = true,
RedirectStandardOutput = true,
RedirectStandardInput = true
RedirectStandardInput = true,
UseShellExecute = false
};
foreach (var item in Environment)
{
#if NET451
psi.EnvironmentVariables[item.Key] = item.Value;
#else
psi.Environment[item.Key] = item.Value;
#endif
}
if (!string.IsNullOrWhiteSpace(WorkingDirectory))