Skip to content

Commit b215dc9

Browse files
authored
Merge pull request #3755 from ActiveState/miked/CP-964
Fix some integration tests
2 parents 8a6848c + dc9fded commit b215dc9

File tree

4 files changed

+47
-18
lines changed

4 files changed

+47
-18
lines changed

internal/testhelpers/tagsuite/tagsuite.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package tagsuite
22

33
import (
44
"os"
5+
"runtime"
56
"strings"
67

78
"github.com/thoas/go-funk"
@@ -95,8 +96,30 @@ type Suite struct {
9596
suite.Suite
9697
}
9798

99+
// ARM-supported tags for integration tests
100+
var armSupportedTags = []string{
101+
Install,
102+
Installer,
103+
InstallScripts,
104+
Update,
105+
}
106+
98107
// OnlyRunForTags skips a test unless one of the given tags is asked for.
99108
func (suite *Suite) OnlyRunForTags(tags ...string) {
109+
// Skip tests on ARM64 if they don't have an ARM-supported tag
110+
if runtime.GOOS == "linux" && runtime.GOARCH == "arm64" {
111+
hasArmSupportedTag := false
112+
for _, tag := range tags {
113+
if funk.Contains(armSupportedTags, tag) {
114+
hasArmSupportedTag = true
115+
break
116+
}
117+
}
118+
if !hasArmSupportedTag {
119+
suite.T().Skipf("Skipping test on Linux/arm64 - only tags %s are supported", strings.Join(armSupportedTags, ", "))
120+
}
121+
}
122+
100123
setTagsString, _ := os.LookupEnv("TEST_SUITE_TAGS")
101124

102125
setTags := strings.Split(strings.ToLower(setTagsString), ":")

pkg/projectfile/projectfile.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1130,7 +1130,8 @@ func AddLockInfo(projectFilePath, branch, version string) error {
11301130

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

11351136
data, err = os.ReadFile(projectFilePath)
11361137
if err != nil {

test/integration/deploy_int_test.go

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212

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

15-
"github.com/ActiveState/cli/internal/config"
1615
"github.com/ActiveState/cli/internal/constants"
1716
"github.com/ActiveState/cli/internal/fileutils"
1817
"github.com/ActiveState/cli/internal/subshell"
@@ -205,7 +204,9 @@ func (suite *DeployIntegrationTestSuite) TestDeployPython() {
205204
cp.SendLine("exit")
206205
cp.ExpectExitCode(0)
207206

208-
suite.AssertConfig(ts, targetID.String())
207+
ts.WithEnv(func() {
208+
suite.AssertConfig(ts, targetID.String())
209+
})
209210
}
210211

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

296-
subshell := subshell.New(cfg)
297-
rcFile, err := subshell.RcFile()
298-
suite.Require().NoError(err)
295+
ts.WithEnv(func() {
296+
subshell := subshell.New(ts.Config())
297+
rcFile, err := subshell.RcFile()
298+
suite.Require().NoError(err)
299299

300-
bashContents := fileutils.ReadFileUnsafe(rcFile)
301-
suite.Contains(string(bashContents), constants.RCAppendDeployStartLine, "config file should contain our RC Append Start line")
302-
suite.Contains(string(bashContents), constants.RCAppendDeployStopLine, "config file should contain our RC Append Stop line")
303-
suite.Contains(string(bashContents), targetID, "config file should contain our target dir")
300+
bashContents := fileutils.ReadFileUnsafe(rcFile)
301+
suite.Contains(string(bashContents), constants.RCAppendDeployStartLine, "config file should contain our RC Append Start line")
302+
suite.Contains(string(bashContents), constants.RCAppendDeployStopLine, "config file should contain our RC Append Stop line")
303+
suite.Contains(string(bashContents), targetID, "config file should contain our target dir")
304+
})
304305
} else {
305306
// Test registry
306307
out, err := exec.Command("reg", "query", `HKLM\SYSTEM\ControlSet001\Control\Session Manager\Environment`, "/v", "Path").Output()

test/integration/use_int_test.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,16 @@ func (suite *UseIntegrationTestSuite) TestReset() {
124124
python3Exe := filepath.Join(ts.Dirs.DefaultBin, "python3"+osutils.ExeExtension)
125125
suite.True(fileutils.TargetExists(python3Exe), python3Exe+" not found")
126126

127-
cfg, err := config.New()
128-
suite.NoError(err)
129-
rcfile, err := subshell.New(cfg).RcFile()
130-
if runtime.GOOS != "windows" && fileutils.FileExists(rcfile) {
127+
var rcfile string
128+
ts.WithEnv(func() {
129+
cfg, err := config.New()
131130
suite.NoError(err)
132-
suite.Contains(string(fileutils.ReadFileUnsafe(rcfile)), ts.Dirs.DefaultBin, "PATH does not have your project in it")
133-
}
131+
rcfile, err := subshell.New(cfg).RcFile()
132+
if runtime.GOOS != "windows" && fileutils.FileExists(rcfile) {
133+
suite.NoError(err)
134+
suite.Contains(string(fileutils.ReadFileUnsafe(rcfile)), ts.Dirs.DefaultBin, "PATH does not have your project in it")
135+
}
136+
})
134137

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

234237
func (suite *UseIntegrationTestSuite) TestJSON() {
235238
suite.OnlyRunForTags(tagsuite.Use, tagsuite.JSON)
239+
236240
ts := e2e.New(suite.T(), false)
237241
defer ts.Close()
238242

0 commit comments

Comments
 (0)