at 23.05-pre 2.2 kB view raw
1diff --git a/shells/bash_test.go b/shells/bash_test.go 2index b8a48f85e..0e3173fc3 100644 3--- a/shells/bash_test.go 4+++ b/shells/bash_test.go 5@@ -4,12 +4,9 @@ 6 package shells 7 8 import ( 9- "runtime" 10 "testing" 11 12 "github.com/stretchr/testify/assert" 13- "github.com/stretchr/testify/require" 14- "gitlab.com/gitlab-org/gitlab-runner/common" 15 ) 16 17 func TestBash_CommandShellEscapesLegacy(t *testing.T) { 18@@ -84,62 +81,3 @@ func TestBash_CheckForErrors(t *testing.T) { 19 }) 20 } 21 } 22- 23-func TestBash_GetConfiguration(t *testing.T) { 24- tests := map[string]struct { 25- info common.ShellScriptInfo 26- cmd string 27- args []string 28- os string 29- }{ 30- `bash`: { 31- info: common.ShellScriptInfo{Shell: "bash", Type: common.NormalShell}, 32- cmd: "bash", 33- }, 34- `bash -l`: { 35- info: common.ShellScriptInfo{Shell: "bash", Type: common.LoginShell}, 36- cmd: "bash", 37- args: []string{"-l"}, 38- }, 39- `su -s /bin/bash foobar -c bash`: { 40- info: common.ShellScriptInfo{Shell: "bash", User: "foobar", Type: common.NormalShell}, 41- cmd: "su", 42- args: []string{"-s", "/bin/bash", "foobar", "-c", "bash"}, 43- os: OSLinux, 44- }, 45- `su -s /bin/bash foobar -c $'bash -l'`: { 46- info: common.ShellScriptInfo{Shell: "bash", User: "foobar", Type: common.LoginShell}, 47- cmd: "su", 48- args: []string{"-s", "/bin/bash", "foobar", "-c", "bash -l"}, 49- os: OSLinux, 50- }, 51- `su -s /bin/sh foobar -c $'sh -l'`: { 52- info: common.ShellScriptInfo{Shell: "sh", User: "foobar", Type: common.LoginShell}, 53- cmd: "su", 54- args: []string{"-s", "/bin/sh", "foobar", "-c", "sh -l"}, 55- os: OSLinux, 56- }, 57- `su foobar -c $'bash -l'`: { 58- info: common.ShellScriptInfo{Shell: "bash", User: "foobar", Type: common.LoginShell}, 59- cmd: "su", 60- args: []string{"foobar", "-c", "bash -l"}, 61- os: "darwin", 62- }, 63- } 64- 65- for tn, tc := range tests { 66- t.Run(tn, func(t *testing.T) { 67- if tc.os != "" && tc.os != runtime.GOOS { 68- t.Skipf("test only runs on %s", tc.os) 69- } 70- 71- sh := BashShell{Shell: tc.info.Shell} 72- config, err := sh.GetConfiguration(tc.info) 73- require.NoError(t, err) 74- 75- assert.Equal(t, tc.cmd, config.Command) 76- assert.Equal(t, tc.args, config.Arguments) 77- assert.Equal(t, tn, config.CmdLine) 78- }) 79- } 80-}