Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions internal/testhelpers/tagsuite/tagsuite.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package tagsuite

import (
"os"
"runtime"
"strings"

"github.com/thoas/go-funk"
Expand Down Expand Up @@ -95,8 +96,30 @@ type Suite struct {
suite.Suite
}

// ARM-supported tags for integration tests
var armSupportedTags = []string{
Install,
Installer,
InstallScripts,
Update,
}

// OnlyRunForTags skips a test unless one of the given tags is asked for.
func (suite *Suite) OnlyRunForTags(tags ...string) {
// Skip tests on ARM64 if they don't have an ARM-supported tag
if runtime.GOOS == "linux" && runtime.GOARCH == "arm64" {
hasArmSupportedTag := false
for _, tag := range tags {
if funk.Contains(armSupportedTags, tag) {
hasArmSupportedTag = true
break
}
}
if !hasArmSupportedTag {
suite.T().Skipf("Skipping test on Linux/arm64 - only tags %s are supported", strings.Join(armSupportedTags, ", "))
}
}

setTagsString, _ := os.LookupEnv("TEST_SUITE_TAGS")

setTags := strings.Split(strings.ToLower(setTagsString), ":")
Expand Down
3 changes: 2 additions & 1 deletion pkg/projectfile/projectfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -1130,7 +1130,8 @@ func AddLockInfo(projectFilePath, branch, version string) error {

projectRegex := regexp.MustCompile(fmt.Sprintf("(?m:(^project:\\s*%s))", ProjectURLRe))
lockString := fmt.Sprintf("%s@%s", branch, version)
lockUpdate := []byte(fmt.Sprintf(`${1}\nlock: %s`, lockString))
lockUpdate := fmt.Append(nil, `${1}`)
lockUpdate = append(lockUpdate, []byte(fmt.Sprintf("lock: %s", lockString))...)

data, err = os.ReadFile(projectFilePath)
if err != nil {
Expand Down
23 changes: 12 additions & 11 deletions test/integration/deploy_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (

"github.com/ActiveState/cli/internal/testhelpers/suite"

"github.com/ActiveState/cli/internal/config"
"github.com/ActiveState/cli/internal/constants"
"github.com/ActiveState/cli/internal/fileutils"
"github.com/ActiveState/cli/internal/subshell"
Expand Down Expand Up @@ -205,7 +204,9 @@ func (suite *DeployIntegrationTestSuite) TestDeployPython() {
cp.SendLine("exit")
cp.ExpectExitCode(0)

suite.AssertConfig(ts, targetID.String())
ts.WithEnv(func() {
suite.AssertConfig(ts, targetID.String())
})
}

func (suite *DeployIntegrationTestSuite) TestDeployInstall() {
Expand Down Expand Up @@ -290,17 +291,17 @@ func (suite *DeployIntegrationTestSuite) TestDeployConfigure() {
func (suite *DeployIntegrationTestSuite) AssertConfig(ts *e2e.Session, targetID string) {
if runtime.GOOS != "windows" {
// Test config file
cfg, err := config.New()
suite.Require().NoError(err)

subshell := subshell.New(cfg)
rcFile, err := subshell.RcFile()
suite.Require().NoError(err)
ts.WithEnv(func() {
subshell := subshell.New(ts.Config())
rcFile, err := subshell.RcFile()
suite.Require().NoError(err)

bashContents := fileutils.ReadFileUnsafe(rcFile)
suite.Contains(string(bashContents), constants.RCAppendDeployStartLine, "config file should contain our RC Append Start line")
suite.Contains(string(bashContents), constants.RCAppendDeployStopLine, "config file should contain our RC Append Stop line")
suite.Contains(string(bashContents), targetID, "config file should contain our target dir")
bashContents := fileutils.ReadFileUnsafe(rcFile)
suite.Contains(string(bashContents), constants.RCAppendDeployStartLine, "config file should contain our RC Append Start line")
suite.Contains(string(bashContents), constants.RCAppendDeployStopLine, "config file should contain our RC Append Stop line")
suite.Contains(string(bashContents), targetID, "config file should contain our target dir")
})
} else {
// Test registry
out, err := exec.Command("reg", "query", `HKLM\SYSTEM\ControlSet001\Control\Session Manager\Environment`, "/v", "Path").Output()
Expand Down
16 changes: 10 additions & 6 deletions test/integration/use_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,16 @@ func (suite *UseIntegrationTestSuite) TestReset() {
python3Exe := filepath.Join(ts.Dirs.DefaultBin, "python3"+osutils.ExeExtension)
suite.True(fileutils.TargetExists(python3Exe), python3Exe+" not found")

cfg, err := config.New()
suite.NoError(err)
rcfile, err := subshell.New(cfg).RcFile()
if runtime.GOOS != "windows" && fileutils.FileExists(rcfile) {
var rcfile string
ts.WithEnv(func() {
cfg, err := config.New()
suite.NoError(err)
suite.Contains(string(fileutils.ReadFileUnsafe(rcfile)), ts.Dirs.DefaultBin, "PATH does not have your project in it")
}
rcfile, err := subshell.New(cfg).RcFile()
if runtime.GOOS != "windows" && fileutils.FileExists(rcfile) {
suite.NoError(err)
suite.Contains(string(fileutils.ReadFileUnsafe(rcfile)), ts.Dirs.DefaultBin, "PATH does not have your project in it")
}
})

cp = ts.Spawn("use", "reset")
cp.Expect("Continue?")
Expand Down Expand Up @@ -233,6 +236,7 @@ func (suite *UseIntegrationTestSuite) TestSetupNotice() {

func (suite *UseIntegrationTestSuite) TestJSON() {
suite.OnlyRunForTags(tagsuite.Use, tagsuite.JSON)

ts := e2e.New(suite.T(), false)
defer ts.Close()

Expand Down
Loading