-
Notifications
You must be signed in to change notification settings - Fork 55
Expose single command execute methods #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -75,7 +75,39 @@ public void testExecFailingScript() throws Exception { | |
| @Test(groups="Live") | ||
| public void testExecScriptExit0() throws Exception { | ||
| assertExecSucceeds("exit /B 0", "", ""); | ||
| assertExecSucceeds(ImmutableList.of("exit /B 0"), "", ""); | ||
| } | ||
|
|
||
| @Test(groups = "Live") | ||
| public void testChainCommands() { | ||
| assertExecCommand("echo Hi & echo World", "Hi \r\nWorld", "", 0); | ||
| } | ||
|
|
||
| /** | ||
| * Please bear in mind this behavior when executing commands. | ||
| */ | ||
| @Test(groups="Live") | ||
| public void testExecRNSplitExit() throws Exception { | ||
| assertExecCommand("echo Hi\r\necho World\r\n", "Hi", "", 0); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you saying that the Other similar styles of test are marked as
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @aledsage I wouldn't say it should be a failing test. |
||
| assertExecCommand("echo Hi\r\necho World", "Hi", "", 0); | ||
| assertExecCommand("echo Hi\necho World\n", "Hi", "", 0); | ||
| assertExecCommand("echo Hi\necho World", "Hi", "", 0); | ||
| } | ||
|
|
||
| /** | ||
| * Please bear in mind this behavior when executing commands. | ||
| */ | ||
| @Test(groups="Live") | ||
| public void testExecCommandExit() throws Exception { | ||
| assertExecCommand("exit /B 0", "", "", 0); | ||
| assertExecCommand("exit /B 1", "", "", 0); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As above: this test is not demonstrating desired behaviour. |
||
| assertExecCommand("exit 1", "", "", 0); | ||
| assertExecCommand("dslfkdsfjskl", "", null, 1); | ||
| } | ||
|
|
||
| @Test(groups = "Live") | ||
| public void testExecPowershellExit() throws Exception { | ||
| assertExecCommand(WinRmTool.compilePs("exit 123"), "", "", 123); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wht not create analogous
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 will change that in my branch of this. |
||
| assertExecCommand(WinRmTool.compilePs("Write-Host Hi World\r\nexit 123"), "Hi World", "", 123); | ||
| } | ||
|
|
||
| /* | ||
|
|
@@ -239,7 +271,7 @@ public void testExecPsBatchFileExit3() throws Exception { | |
| String scriptPath = "C:\\myscript-"+makeRandomString(8)+".bat"; | ||
| copyTo(new ByteArrayInputStream(script.getBytes()), scriptPath); | ||
|
|
||
| WinRmToolResponse response = executePs(ImmutableList.of("& '"+scriptPath+"'")); | ||
| WinRmToolResponse response = executePs("& '"+scriptPath+"'"); | ||
| String msg = "statusCode="+response.getStatusCode()+"; out="+response.getStdOut()+"; err="+response.getStdErr(); | ||
| assertEquals(response.getStatusCode(), 3, msg); | ||
| } | ||
|
|
@@ -347,7 +379,7 @@ public void testConfirmUseOfErrorActionPreferenceDoesNotCauseErr() throws Except | |
| public void testExecPsExit1() throws Exception { | ||
| // Single commands | ||
| assertExecPsFails("exit 1"); | ||
| assertExecPsFails(ImmutableList.of("exit 1")); | ||
| assertExecPsFails("exit 1"); | ||
|
|
||
| // Multi-part | ||
| assertExecPsFails(ImmutableList.of(PS_ERR_ACTION_PREF_EQ_STOP, "Write-Host myline", "exit 1")); | ||
|
|
@@ -372,11 +404,11 @@ public void testToolReuse() throws Exception { | |
| WinRmTool winRmTool = connect(); | ||
|
|
||
| Stopwatch stopwatch = Stopwatch.createStarted(); | ||
| WinRmToolResponse response = executePs(winRmTool, ImmutableList.of("echo myline")); | ||
| WinRmToolResponse response = executePs(winRmTool, "echo myline"); | ||
| assertSucceeded("echo myline", response, "myline", "", stopwatch); | ||
|
|
||
| stopwatch = Stopwatch.createStarted(); | ||
| WinRmToolResponse response2 = executePs(winRmTool, ImmutableList.of("echo myline")); | ||
| WinRmToolResponse response2 = executePs(winRmTool, "echo myline"); | ||
| assertSucceeded("echo myline", response2, "myline", "", stopwatch); | ||
| } | ||
|
|
||
|
|
@@ -397,7 +429,7 @@ public Void call() throws Exception { | |
| String line = "myline" + makeRandomString(8); | ||
| Stopwatch stopwatch = Stopwatch.createStarted(); | ||
| try { | ||
| WinRmToolResponse response = executePs(winRmTool, ImmutableList.of("echo " + line)); | ||
| WinRmToolResponse response = executePs(winRmTool, "echo " + line); | ||
| assertSucceeded("echo " + line, response, line, "", stopwatch); | ||
| LOG.info("Executed `echo "+line+"` in "+makeTimeStringRounded(stopwatch)+", in thread "+Thread.currentThread()+"; total "+counter.incrementAndGet()+" methods done"); | ||
| return null; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea using
&as the delimiter. Since it's the recommended approach to chaining commands we can now provide a well behavedexecuteCommand(List), wdyt?