diff --git a/internal/testhelpers/tagsuite/tagsuite.go b/internal/testhelpers/tagsuite/tagsuite.go index 04fd9c4a5d..1c04bd3b53 100644 --- a/internal/testhelpers/tagsuite/tagsuite.go +++ b/internal/testhelpers/tagsuite/tagsuite.go @@ -2,6 +2,7 @@ package tagsuite import ( "os" + "runtime" "strings" "github.com/thoas/go-funk" @@ -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), ":") diff --git a/pkg/projectfile/projectfile.go b/pkg/projectfile/projectfile.go index 128e01d95a..85c01c3d18 100644 --- a/pkg/projectfile/projectfile.go +++ b/pkg/projectfile/projectfile.go @@ -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 { diff --git a/test/integration/deploy_int_test.go b/test/integration/deploy_int_test.go index f51e686baa..348893af42 100644 --- a/test/integration/deploy_int_test.go +++ b/test/integration/deploy_int_test.go @@ -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" @@ -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() { @@ -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() diff --git a/test/integration/use_int_test.go b/test/integration/use_int_test.go index d9b781eaab..64a46ec299 100644 --- a/test/integration/use_int_test.go +++ b/test/integration/use_int_test.go @@ -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?") @@ -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()