-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fail fast on errors in powershell TTP steps (#518)
Summary: Set ErrorActionPreference variable as first thing when executing the powershell TTPs Resolves #517 Brings parity with bash fail-fast logic introduced in #406 Differential Revision: D65080213
- Loading branch information
1 parent
c789c78
commit 25963ca
Showing
2 changed files
with
35 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package blocks | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
) | ||
|
||
func TestBashExecutor_Echo_Success(t *testing.T) { | ||
emptyEnvironment := map[string]string{} | ||
execCtx := TTPExecutionContext{Vars: &TTPExecutionVars{}} | ||
executor := NewExecutor("bash", "echo success", "", []string{}, emptyEnvironment) | ||
|
||
result, err := executor.Execute(context.Background(), execCtx) | ||
if err != nil { | ||
t.Fatalf("expected no error, got %v", err) | ||
} | ||
if result.Stdout != "success\n" { | ||
t.Fatalf("expected output 'success\\n', got %#v", result.Stdout) | ||
} | ||
} | ||
|
||
func TestBashExecutor_False_FailFast(t *testing.T) { | ||
emptyEnvironment := map[string]string{} | ||
execCtx := TTPExecutionContext{Vars: &TTPExecutionVars{}} | ||
executor := NewExecutor("bash", "false; echo success", "", []string{}, emptyEnvironment) | ||
|
||
result, err := executor.Execute(context.Background(), execCtx) | ||
if err == nil { | ||
t.Fatalf("expected error, got result %#v", result) | ||
} | ||
if err.Error() != "exit status 1" { | ||
t.Fatalf("expected error 'exit status 1', got %#v", err.Error()) | ||
} | ||
} |