at 24.11-pre 2.3 kB view raw
1diff --git a/shells/bash_test.go b/shells/bash_test.go 2index 9ed9e65ff..02b6e6d5f 100644 3--- a/shells/bash_test.go 4+++ b/shells/bash_test.go 5@@ -4,11 +4,9 @@ package shells 6 7 import ( 8 "path" 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@@ -90,65 +88,6 @@ func TestBash_CheckForErrors(t *testing.T) { 18 } 19 } 20 21-func TestBash_GetConfiguration(t *testing.T) { 22- tests := map[string]struct { 23- info common.ShellScriptInfo 24- cmd string 25- args []string 26- os string 27- }{ 28- `bash`: { 29- info: common.ShellScriptInfo{Shell: "bash", Type: common.NormalShell}, 30- cmd: "bash", 31- }, 32- `bash -l`: { 33- info: common.ShellScriptInfo{Shell: "bash", Type: common.LoginShell}, 34- cmd: "bash", 35- args: []string{"-l"}, 36- }, 37- `su -s /bin/bash foobar -c bash`: { 38- info: common.ShellScriptInfo{Shell: "bash", User: "foobar", Type: common.NormalShell}, 39- cmd: "su", 40- args: []string{"-s", "/bin/bash", "foobar", "-c", "bash"}, 41- os: OSLinux, 42- }, 43- `su -s /bin/bash foobar -c $'bash -l'`: { 44- info: common.ShellScriptInfo{Shell: "bash", User: "foobar", Type: common.LoginShell}, 45- cmd: "su", 46- args: []string{"-s", "/bin/bash", "foobar", "-c", "bash -l"}, 47- os: OSLinux, 48- }, 49- `su -s /bin/sh foobar -c $'sh -l'`: { 50- info: common.ShellScriptInfo{Shell: "sh", User: "foobar", Type: common.LoginShell}, 51- cmd: "su", 52- args: []string{"-s", "/bin/sh", "foobar", "-c", "sh -l"}, 53- os: OSLinux, 54- }, 55- `su foobar -c $'bash -l'`: { 56- info: common.ShellScriptInfo{Shell: "bash", User: "foobar", Type: common.LoginShell}, 57- cmd: "su", 58- args: []string{"foobar", "-c", "bash -l"}, 59- os: "darwin", 60- }, 61- } 62- 63- for tn, tc := range tests { 64- t.Run(tn, func(t *testing.T) { 65- if tc.os != "" && tc.os != runtime.GOOS { 66- t.Skipf("test only runs on %s", tc.os) 67- } 68- 69- sh := BashShell{Shell: tc.info.Shell} 70- config, err := sh.GetConfiguration(tc.info) 71- require.NoError(t, err) 72- 73- assert.Equal(t, tc.cmd, config.Command) 74- assert.Equal(t, tc.args, config.Arguments) 75- assert.Equal(t, tn, config.CmdLine) 76- }) 77- } 78-} 79- 80 func Test_BashWriter_isTmpFile(t *testing.T) { 81 tmpDir := "/foo/bar" 82 bw := BashWriter{TemporaryPath: tmpDir}