bug/issue #2448 - manage special bash options when no shell is defined (#2449)

* bash without "-o pipefail" option when "bash" is not explicitely
defined in the workflow
* bonus: fix inverted expected and actual in TestGetGitHubContext assertions
This commit is contained in:
sebastien-perpignane
2024-09-19 10:28:45 +02:00
committed by GitHub
parent 013c0d4e18
commit 2e117a4d2b
4 changed files with 35 additions and 20 deletions

View File

@@ -397,15 +397,18 @@ func TestReadWorkflow_Strategy(t *testing.T) {
func TestStep_ShellCommand(t *testing.T) {
tests := []struct {
shell string
workflowShell string
want string
}{
{"pwsh -v '. {0}'", "pwsh -v '. {0}'"},
{"pwsh", "pwsh -command . '{0}'"},
{"powershell", "powershell -command . '{0}'"},
{"pwsh -v '. {0}'", "", "pwsh -v '. {0}'"},
{"pwsh", "", "pwsh -command . '{0}'"},
{"powershell", "", "powershell -command . '{0}'"},
{"bash", "", "bash -e {0}"},
{"bash", "bash", "bash --noprofile --norc -e -o pipefail {0}"},
}
for _, tt := range tests {
t.Run(tt.shell, func(t *testing.T) {
got := (&Step{Shell: tt.shell}).ShellCommand()
got := (&Step{Shell: tt.shell, WorkflowShell: tt.workflowShell}).ShellCommand()
assert.Equal(t, got, tt.want)
})
}