Skip to content

Commit

Permalink
(GH-255) Add updateProcessPath to CommandExecutor
Browse files Browse the repository at this point in the history
In many cases when reaching out, you do not want to try to get the full
path to a command that is available based on PATH variables, so don't
attmept to get the full path.
  • Loading branch information
ferventcoder committed Apr 22, 2015
1 parent c8bec44 commit fd1936e
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public void should_not_get_package_information()
[Fact]
public void should_not_call_command_executor()
{
commandExecutor.Verify(c => c.execute(It.IsAny<String>(), It.IsAny<String>(), It.IsAny<int>(), It.IsAny<Action<object, DataReceivedEventArgs>>(), It.IsAny<Action<object, DataReceivedEventArgs>>()), Times.Never);
commandExecutor.Verify(c => c.execute(It.IsAny<String>(), It.IsAny<String>(), It.IsAny<int>(), It.IsAny<Action<object, DataReceivedEventArgs>>(), It.IsAny<Action<object, DataReceivedEventArgs>>(), It.IsAny<bool>()), Times.Never);
}
}

Expand All @@ -134,7 +134,7 @@ public void should_log_why_it_skips_auto_uninstaller()
[Fact]
public void should_not_call_command_executor()
{
commandExecutor.Verify(c => c.execute(It.IsAny<String>(), It.IsAny<String>(), It.IsAny<int>(), It.IsAny<Action<object, DataReceivedEventArgs>>(), It.IsAny<Action<object, DataReceivedEventArgs>>()), Times.Never);
commandExecutor.Verify(c => c.execute(It.IsAny<String>(), It.IsAny<String>(), It.IsAny<int>(), It.IsAny<Action<object, DataReceivedEventArgs>>(), It.IsAny<Action<object, DataReceivedEventArgs>>(), It.IsAny<bool>()), Times.Never);
}
}

Expand All @@ -160,7 +160,7 @@ public void should_log_why_it_skips_auto_uninstaller()
[Fact]
public void should_not_call_command_executor()
{
commandExecutor.Verify(c => c.execute(It.IsAny<String>(), It.IsAny<String>(), It.IsAny<int>(), It.IsAny<Action<object, DataReceivedEventArgs>>(), It.IsAny<Action<object, DataReceivedEventArgs>>()), Times.Never);
commandExecutor.Verify(c => c.execute(It.IsAny<String>(), It.IsAny<String>(), It.IsAny<int>(), It.IsAny<Action<object, DataReceivedEventArgs>>(), It.IsAny<Action<object, DataReceivedEventArgs>>(), It.IsAny<bool>()), Times.Never);
}
}

Expand All @@ -187,7 +187,7 @@ public void should_log_why_it_skips_auto_uninstaller()
[Fact]
public void should_not_call_command_executor()
{
commandExecutor.Verify(c => c.execute(It.IsAny<String>(), It.IsAny<String>(), It.IsAny<int>(), It.IsAny<Action<object, DataReceivedEventArgs>>(), It.IsAny<Action<object, DataReceivedEventArgs>>()), Times.Never);
commandExecutor.Verify(c => c.execute(It.IsAny<String>(), It.IsAny<String>(), It.IsAny<int>(), It.IsAny<Action<object, DataReceivedEventArgs>>(), It.IsAny<Action<object, DataReceivedEventArgs>>(), It.IsAny<bool>()), Times.Never);
}
}

Expand All @@ -214,7 +214,7 @@ public void should_log_why_it_skips_auto_uninstaller()
[Fact]
public void should_not_call_command_executor()
{
commandExecutor.Verify(c => c.execute(It.IsAny<String>(), It.IsAny<String>(), It.IsAny<int>(), It.IsAny<Action<object, DataReceivedEventArgs>>(), It.IsAny<Action<object, DataReceivedEventArgs>>()), Times.Never);
commandExecutor.Verify(c => c.execute(It.IsAny<String>(), It.IsAny<String>(), It.IsAny<int>(), It.IsAny<Action<object, DataReceivedEventArgs>>(), It.IsAny<Action<object, DataReceivedEventArgs>>(), It.IsAny<bool>()), Times.Never);
}
}

Expand Down Expand Up @@ -243,7 +243,7 @@ public void should_log_why_it_skips_auto_uninstaller()
[Fact]
public void should_not_call_command_executor()
{
commandExecutor.Verify(c => c.execute(It.IsAny<String>(), It.IsAny<String>(), It.IsAny<int>(), It.IsAny<Action<object, DataReceivedEventArgs>>(), It.IsAny<Action<object, DataReceivedEventArgs>>()), Times.Never);
commandExecutor.Verify(c => c.execute(It.IsAny<String>(), It.IsAny<String>(), It.IsAny<int>(), It.IsAny<Action<object, DataReceivedEventArgs>>(), It.IsAny<Action<object, DataReceivedEventArgs>>(), It.IsAny<bool>()), Times.Never);
}
}

Expand All @@ -263,7 +263,7 @@ public void should_call_get_package_information()
[Fact]
public void should_call_command_executor()
{
commandExecutor.Verify(c => c.execute(expectedUninstallString, installerType.build_uninstall_command_arguments().trim_safe(), It.IsAny<int>(), It.IsAny<Action<object, DataReceivedEventArgs>>(), It.IsAny<Action<object, DataReceivedEventArgs>>()), Times.Never);
commandExecutor.Verify(c => c.execute(expectedUninstallString, installerType.build_uninstall_command_arguments().trim_safe(), It.IsAny<int>(), It.IsAny<Action<object, DataReceivedEventArgs>>(), It.IsAny<Action<object, DataReceivedEventArgs>>(), It.IsAny<bool>()), Times.Never);
}
}

Expand Down Expand Up @@ -299,7 +299,7 @@ private void test_installertype(IInstaller installer,bool useInstallerDefaultArg

var uninstallArgs = useInstallerDefaultArgs ? installer.build_uninstall_command_arguments().trim_safe() : registryUninstallArgs.trim_safe();

commandExecutor.Verify(c => c.execute(expectedUninstallString, uninstallArgs, It.IsAny<int>(), It.IsAny<Action<object, DataReceivedEventArgs>>(), It.IsAny<Action<object, DataReceivedEventArgs>>()), Times.Never);
commandExecutor.Verify(c => c.execute(expectedUninstallString, uninstallArgs, It.IsAny<int>(), It.IsAny<Action<object, DataReceivedEventArgs>>(), It.IsAny<Action<object, DataReceivedEventArgs>>(), It.IsAny<bool>()), Times.Never);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ public void run(PackageResult packageResult, ChocolateyConfiguration config)
{
if (e == null || string.IsNullOrWhiteSpace(e.Data)) return;
this.Log().Error(() => " [AutoUninstaller] {0}".format_with(e.Data));
});
},
updateProcessPath: false);

if (exitCode != 0)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ public void install(ChocolateyConfiguration configuration, PackageResult package
{
if (string.IsNullOrWhiteSpace(e.Data)) return;
this.Log().Error(() => " [ShimGen] {0}".format_with(e.Data));
}
},
updateProcessPath: true
);

if (exitCode != 0)
Expand Down
3 changes: 2 additions & 1 deletion src/chocolatey/infrastructure.app/services/WebPiService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ private void set_webpi_install_dictionary()
{
if (string.IsNullOrWhiteSpace(e.Data)) return;
this.Log().Error(() => "{0}".format_with(e.Data));
}
},
updateProcessPath: false
);

if (exitCode != 0)
Expand Down
5 changes: 3 additions & 2 deletions src/chocolatey/infrastructure/commands/CommandExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ public int execute(string process, string arguments, int waitForExitInSeconds)
string arguments,
int waitForExitInSeconds,
Action<object, DataReceivedEventArgs> stdOutAction,
Action<object, DataReceivedEventArgs> stdErrAction
Action<object, DataReceivedEventArgs> stdErrAction,
bool updateProcessPath = true
)
{
return execute(process,
Expand All @@ -66,7 +67,7 @@ public int execute(string process, string arguments, int waitForExitInSeconds)
file_system.get_directory_name(Assembly.GetExecutingAssembly().CodeBase.Replace("file:///", string.Empty)),
stdOutAction,
stdErrAction,
updateProcessPath: true
updateProcessPath
);
}

Expand Down
5 changes: 3 additions & 2 deletions src/chocolatey/infrastructure/commands/ICommandExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public interface ICommandExecutor
string arguments,
int waitForExitInSeconds,
Action<object, DataReceivedEventArgs> stdOutAction,
Action<object, DataReceivedEventArgs> stdErrAction
);
Action<object, DataReceivedEventArgs> stdErrAction,
bool updateProcessPath
);
}
}

0 comments on commit fd1936e

Please sign in to comment.