Skip to content

Commit

Permalink
More hardcoded shell stuff.
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchell-as committed Aug 22, 2023
1 parent ca096f0 commit 36a8781
Showing 1 changed file with 14 additions and 26 deletions.
40 changes: 14 additions & 26 deletions test/integration/shell_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ import (
"runtime"
"testing"

"github.com/ActiveState/cli/internal/condition"
"github.com/ActiveState/cli/internal/config"
"github.com/ActiveState/cli/internal/fileutils"
"github.com/ActiveState/cli/internal/subshell"
"github.com/ActiveState/cli/internal/subshell/sscommon"
"github.com/ActiveState/cli/internal/subshell/bash"
"github.com/ActiveState/cli/internal/subshell/zsh"
"github.com/ActiveState/cli/internal/testhelpers/e2e"
"github.com/ActiveState/cli/internal/testhelpers/tagsuite"
Expand Down Expand Up @@ -288,36 +287,25 @@ func (suite *ShellIntegrationTestSuite) TestNestedShellNotification() {
ts := e2e.New(suite.T(), false)
defer ts.Close()

cfg, err := config.New()
suite.Require().NoError(err)

// Setup subshell. Since our CI tests are running in bash, override with zsh on macOS.
var ss subshell.SubShell
var rcFile string
env := []string{"ACTIVESTATE_CLI_DISABLE_RUNTIME=false"}
if runtime.GOOS != "darwin" || !condition.OnCI() {
ss = subshell.New(cfg)
} else {
cfg.Set(subshell.ConfigKeyShell, "zsh")
ss = subshell.New(cfg)
cfg.Set(subshell.ConfigKeyShell, "")
env = append(env, "SHELL=zsh")
}

// Setup shell-specific RC file in test-specific home directory.
var rcFile, rcFileAppend string
switch ss.Shell() {
case "bash":
rcFile = filepath.Join(ts.Dirs.HomeDir, ".bashrc")
rcFileAppend = "bashrc_append.sh"
case "zsh":
switch runtime.GOOS {
case "darwin":
ss = &zsh.SubShell{}
ss.SetBinary("zsh")
rcFile = filepath.Join(ts.Dirs.HomeDir, ".zshrc")
rcFileAppend = "zshrc_append.sh"
suite.Require().NoError(fileutils.WriteFile(rcFile, fileutils.ReadFileUnsafe("zshrc_append.sh")))
env = append(env, "SHELL=zsh") // override since CI tests are running on bash
case "linux":
ss = &bash.SubShell{}
ss.SetBinary("bash")
rcFile = filepath.Join(ts.Dirs.HomeDir, ".bashrc")
suite.Require().NoError(fileutils.WriteFile(rcFile, fileutils.ReadFileUnsafe("bashrc_append.sh")))
default:
suite.Fail("Unknown subshell: %s", ss.Shell())
suite.Fail("Unsupported OS")
}
suite.Require().Equal(filepath.Dir(rcFile), ts.Dirs.HomeDir, "rc file not in test suite homedir")
fileutils.TouchFileUnlessExists(rcFile)
sscommon.WriteRcFile(rcFileAppend, rcFile, sscommon.InstallID, nil)
suite.Require().Contains(string(fileutils.ReadFileUnsafe(rcFile)), "State Tool is operating on project")

cp := ts.Spawn("checkout", "ActiveState-CLI/small-python")
Expand Down

0 comments on commit 36a8781

Please sign in to comment.