diff --git a/shells/bash_test.go b/shells/bash_test.go index 9ed9e65ff..02b6e6d5f 100644 --- a/shells/bash_test.go +++ b/shells/bash_test.go @@ -4,11 +4,9 @@ package shells import ( "path" - "runtime" "testing" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" "gitlab.com/gitlab-org/gitlab-runner/common" ) @@ -90,65 +88,6 @@ 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) - }) - } -} - func Test_BashWriter_isTmpFile(t *testing.T) { tmpDir := "/foo/bar" bw := BashWriter{TemporaryPath: tmpDir}