parent
34919ae092
commit
699c30056b
@ -0,0 +1,80 @@ |
||||
diff --git a/shells/bash_test.go b/shells/bash_test.go
|
||||
index b8a48f85e..0e3173fc3 100644
|
||||
--- a/shells/bash_test.go
|
||||
+++ b/shells/bash_test.go
|
||||
@@ -4,12 +4,9 @@
|
||||
package shells
|
||||
|
||||
import (
|
||||
- "runtime"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
- "github.com/stretchr/testify/require"
|
||||
- "gitlab.com/gitlab-org/gitlab-runner/common"
|
||||
)
|
||||
|
||||
func TestBash_CommandShellEscapesLegacy(t *testing.T) {
|
||||
@@ -84,62 +81,3 @@ func TestBash_CheckForErrors(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
-
|
||||
-func TestBash_GetConfiguration(t *testing.T) {
|
||||
- tests := map[string]struct {
|
||||
- info common.ShellScriptInfo
|
||||
- cmd string
|
||||
- args []string
|
||||
- os string
|
||||
- }{
|
||||
- `bash`: {
|
||||
- info: common.ShellScriptInfo{Shell: "bash", Type: common.NormalShell},
|
||||
- cmd: "bash",
|
||||
- },
|
||||
- `bash -l`: {
|
||||
- info: common.ShellScriptInfo{Shell: "bash", Type: common.LoginShell},
|
||||
- cmd: "bash",
|
||||
- args: []string{"-l"},
|
||||
- },
|
||||
- `su -s /bin/bash foobar -c bash`: {
|
||||
- info: common.ShellScriptInfo{Shell: "bash", User: "foobar", Type: common.NormalShell},
|
||||
- cmd: "su",
|
||||
- args: []string{"-s", "/bin/bash", "foobar", "-c", "bash"},
|
||||
- os: OSLinux,
|
||||
- },
|
||||
- `su -s /bin/bash foobar -c $'bash -l'`: {
|
||||
- info: common.ShellScriptInfo{Shell: "bash", User: "foobar", Type: common.LoginShell},
|
||||
- cmd: "su",
|
||||
- args: []string{"-s", "/bin/bash", "foobar", "-c", "bash -l"},
|
||||
- os: OSLinux,
|
||||
- },
|
||||
- `su -s /bin/sh foobar -c $'sh -l'`: {
|
||||
- info: common.ShellScriptInfo{Shell: "sh", User: "foobar", Type: common.LoginShell},
|
||||
- cmd: "su",
|
||||
- args: []string{"-s", "/bin/sh", "foobar", "-c", "sh -l"},
|
||||
- os: OSLinux,
|
||||
- },
|
||||
- `su foobar -c $'bash -l'`: {
|
||||
- info: common.ShellScriptInfo{Shell: "bash", User: "foobar", Type: common.LoginShell},
|
||||
- cmd: "su",
|
||||
- args: []string{"foobar", "-c", "bash -l"},
|
||||
- os: "darwin",
|
||||
- },
|
||||
- }
|
||||
-
|
||||
- for tn, tc := range tests {
|
||||
- t.Run(tn, func(t *testing.T) {
|
||||
- if tc.os != "" && tc.os != runtime.GOOS {
|
||||
- t.Skipf("test only runs on %s", tc.os)
|
||||
- }
|
||||
-
|
||||
- sh := BashShell{Shell: tc.info.Shell}
|
||||
- config, err := sh.GetConfiguration(tc.info)
|
||||
- require.NoError(t, err)
|
||||
-
|
||||
- assert.Equal(t, tc.cmd, config.Command)
|
||||
- assert.Equal(t, tc.args, config.Arguments)
|
||||
- assert.Equal(t, tn, config.CmdLine)
|
||||
- })
|
||||
- }
|
||||
-}
|
Loading…
Reference in new issue