depot/third_party/nixpkgs/pkgs/development/tools/continuous-integration/gitlab-runner/remove-bash-test.patch
Default email 8a45d4525b Project import generated by Copybara.
GitOrigin-RevId: 710fed5a2483f945b14f4a58af2cd3676b42d8c8
2022-03-30 11:31:56 +02:00

80 lines
2.2 KiB
Diff

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)
- })
- }
-}