From 897b261137f63d1df014a37a1bfef4e20d94e3f3 Mon Sep 17 00:00:00 2001 From: mitchell Date: Thu, 7 Dec 2023 11:44:16 -0500 Subject: [PATCH] Merge exeutils package into osutils. There was overlap in exe extension per OS. --- cmd/state-installer/cmd.go | 11 +++++------ cmd/state-installer/installer.go | 7 +++---- .../test/integration/installer_int_test.go | 2 +- cmd/state-remote-installer/main.go | 4 ++-- cmd/state-svc/test/integration/svc_int_test.go | 4 ++-- cmd/state/autoupdate.go | 3 +-- internal/installation/appinfo.go | 8 ++++---- internal/installation/paths.go | 4 ++-- internal/installation/paths_test.go | 4 ++-- internal/installmgr/stop.go | 5 ++--- internal/language/language.go | 6 +++--- internal/legacytray/legacytray.go | 6 +++--- internal/{exeutils => osutils}/exeutils.go | 7 +++---- internal/{exeutils => osutils}/exeutils_test.go | 4 ++-- internal/{exeutils => osutils}/exeutils_unix.go | 4 ++-- .../{exeutils => osutils}/exeutils_windows.go | 5 ++--- internal/{exeutils => osutils}/find.go | 6 +++--- internal/{exeutils => osutils}/find_test.go | 8 ++++---- internal/osutils/shortcut/shortcut_linux.go | 4 ++-- internal/osutils/vars_lin_mac.go | 4 +--- internal/osutils/vars_windows.go | 4 +--- internal/runbits/auth/login.go | 2 +- internal/runners/clean/run_lin_mac.go | 4 ++-- internal/runners/clean/run_win.go | 3 +-- internal/runners/clean/stop.go | 4 ++-- internal/runners/deploy/deploy.go | 5 ++--- internal/runners/exec/exec.go | 6 +++--- internal/scriptrun/scriptrun.go | 4 ++-- internal/svcctl/svcctl.go | 4 ++-- internal/testhelpers/e2e/session.go | 15 +++++++-------- internal/testhelpers/secrethelper/secrethelper.go | 6 +++--- internal/updater/updater.go | 7 +++---- pkg/platform/runtime/envdef/environment.go | 6 +++--- pkg/platform/runtime/executors/executors.go | 5 ++--- scripts/ci/parallelize/parallelize.go | 10 ++++------ scripts/ci/payload-generator/main.go | 10 +++++----- scripts/ci/propagate-pr/main.go | 8 ++++---- scripts/ci/update-generator/main.go | 2 +- scripts/grab-mergecommits/main.go | 4 ++-- scripts/start-story/main.go | 10 +++++----- test/integration/activate_int_test.go | 10 +++++----- test/integration/checkout_int_test.go | 6 +++--- test/integration/executor_int_test.go | 4 ++-- test/integration/install_scripts_int_test.go | 4 ++-- .../integration/performance_expansion_int_test.go | 4 ++-- test/integration/performance_int_test.go | 4 ++-- test/integration/prepare_int_test.go | 2 +- test/integration/remote_installer_int_test.go | 5 ++--- test/integration/runtime_int_test.go | 4 ++-- test/integration/update_int_test.go | 6 +++--- test/integration/upgen_int_test.go | 4 ++-- test/integration/use_int_test.go | 4 ++-- 52 files changed, 132 insertions(+), 150 deletions(-) rename internal/{exeutils => osutils}/exeutils.go (97%) rename internal/{exeutils => osutils}/exeutils_test.go (99%) rename internal/{exeutils => osutils}/exeutils_unix.go (61%) rename internal/{exeutils => osutils}/exeutils_windows.go (85%) rename internal/{exeutils => osutils}/find.go (91%) rename internal/{exeutils => osutils}/find_test.go (88%) diff --git a/cmd/state-installer/cmd.go b/cmd/state-installer/cmd.go index 7f12ec4337..92daa6ceb9 100644 --- a/cmd/state-installer/cmd.go +++ b/cmd/state-installer/cmd.go @@ -18,7 +18,6 @@ import ( "github.com/ActiveState/cli/internal/constants" "github.com/ActiveState/cli/internal/errs" "github.com/ActiveState/cli/internal/events" - "github.com/ActiveState/cli/internal/exeutils" "github.com/ActiveState/cli/internal/fileutils" "github.com/ActiveState/cli/internal/installation" "github.com/ActiveState/cli/internal/installation/storage" @@ -382,8 +381,8 @@ func postInstallEvents(out output.Outputer, cfg *config.Instance, an analytics.D an.Event(anaConst.CatInstallerFunnel, "forward-command") out.Print(fmt.Sprintf("\nRunning '[ACTIONABLE]%s[/RESET]'\n", params.command)) - cmd, args := exeutils.DecodeCmd(params.command) - if _, _, err := exeutils.ExecuteAndPipeStd(cmd, args, envSlice(binPath)); err != nil { + cmd, args := osutils.DecodeCmd(params.command) + if _, _, err := osutils.ExecuteAndPipeStd(cmd, args, envSlice(binPath)); err != nil { an.EventWithLabel(anaConst.CatInstallerFunnel, "forward-command-err", err.Error()) return errs.Silence(errs.Wrap(err, "Running provided command failed, error returned: %s", errs.JoinMessage(err))) } @@ -392,7 +391,7 @@ func postInstallEvents(out output.Outputer, cfg *config.Instance, an analytics.D an.Event(anaConst.CatInstallerFunnel, "forward-activate") out.Print(fmt.Sprintf("\nRunning '[ACTIONABLE]state activate %s[/RESET]'\n", params.activate.String())) - if _, _, err := exeutils.ExecuteAndPipeStd(stateExe, []string{"activate", params.activate.String()}, envSlice(binPath)); err != nil { + if _, _, err := osutils.ExecuteAndPipeStd(stateExe, []string{"activate", params.activate.String()}, envSlice(binPath)); err != nil { an.EventWithLabel(anaConst.CatInstallerFunnel, "forward-activate-err", err.Error()) return errs.Silence(errs.Wrap(err, "Could not activate %s, error returned: %s", params.activate.String(), errs.JoinMessage(err))) } @@ -401,7 +400,7 @@ func postInstallEvents(out output.Outputer, cfg *config.Instance, an analytics.D an.Event(anaConst.CatInstallerFunnel, "forward-activate-default") out.Print(fmt.Sprintf("\nRunning '[ACTIONABLE]state activate --default %s[/RESET]'\n", params.activateDefault.String())) - if _, _, err := exeutils.ExecuteAndPipeStd(stateExe, []string{"activate", params.activateDefault.String(), "--default"}, envSlice(binPath)); err != nil { + if _, _, err := osutils.ExecuteAndPipeStd(stateExe, []string{"activate", params.activateDefault.String(), "--default"}, envSlice(binPath)); err != nil { an.EventWithLabel(anaConst.CatInstallerFunnel, "forward-activate-default-err", err.Error()) return errs.Silence(errs.Wrap(err, "Could not activate %s, error returned: %s", params.activateDefault.String(), errs.JoinMessage(err))) } @@ -478,7 +477,7 @@ func noArgs() bool { func shouldUpdateInstalledStateTool(stateExePath string) bool { logging.Debug("Checking if installed state tool is an older version.") - stdout, _, err := exeutils.ExecSimple(stateExePath, []string{"--version", "--output", "json"}, os.Environ()) + stdout, _, err := osutils.ExecSimple(stateExePath, []string{"--version", "--output", "json"}, os.Environ()) if err != nil { logging.Debug("Could not determine state tool version.") return true // probably corrupted install diff --git a/cmd/state-installer/installer.go b/cmd/state-installer/installer.go index 6073975296..21a18fdb26 100644 --- a/cmd/state-installer/installer.go +++ b/cmd/state-installer/installer.go @@ -12,7 +12,6 @@ import ( "github.com/ActiveState/cli/internal/config" "github.com/ActiveState/cli/internal/constants" "github.com/ActiveState/cli/internal/errs" - "github.com/ActiveState/cli/internal/exeutils" "github.com/ActiveState/cli/internal/fileutils" "github.com/ActiveState/cli/internal/installation" "github.com/ActiveState/cli/internal/installmgr" @@ -127,7 +126,7 @@ func (i *Installer) Install() (rerr error) { // Run state _prepare after updates to facilitate anything the new version of the state tool might need to set up // Yes this is awkward, followup story here: https://www.pivotaltracker.com/story/show/176507898 - if stdout, stderr, err := exeutils.ExecSimple(stateExec, []string{"_prepare"}, []string{}); err != nil { + if stdout, stderr, err := osutils.ExecSimple(stateExec, []string{"_prepare"}, []string{}); err != nil { multilog.Error("_prepare failed after update: %v\n\nstdout: %s\n\nstderr: %s", err, stdout, stderr) } @@ -211,7 +210,7 @@ func detectCorruptedInstallDir(path string) error { } func isStateExecutable(name string) bool { - if name == constants.StateCmd+exeutils.Extension || name == constants.StateSvcCmd+exeutils.Extension { + if name == constants.StateCmd+osutils.ExeExtension || name == constants.StateSvcCmd+osutils.ExeExtension { return true } return false @@ -223,7 +222,7 @@ func installedOnPath(installRoot, branch string) (bool, string, error) { } // This is not using appinfo on purpose because we want to deal with legacy installation formats, which appinfo does not - stateCmd := constants.StateCmd + exeutils.Extension + stateCmd := constants.StateCmd + osutils.ExeExtension // Check for state.exe in branch, root and bin dir // This is to handle older state tool versions that gave incompatible input paths diff --git a/cmd/state-installer/test/integration/installer_int_test.go b/cmd/state-installer/test/integration/installer_int_test.go index 2a4b78fe24..2b3d5547a9 100644 --- a/cmd/state-installer/test/integration/installer_int_test.go +++ b/cmd/state-installer/test/integration/installer_int_test.go @@ -313,7 +313,7 @@ func (suite *InstallerIntegrationTestSuite) SetupSuite() { localPayload := filepath.Join(rootPath, "build", "payload", constants.ToplevelInstallArchiveDir) suite.Require().DirExists(localPayload, "locally generated payload exists") - installerExe := filepath.Join(localPayload, constants.StateInstallerCmd+osutils.ExeExt) + installerExe := filepath.Join(localPayload, constants.StateInstallerCmd+osutils.ExeExtension) suite.Require().FileExists(installerExe, "locally generated installer exists") suite.installerExe = installerExe diff --git a/cmd/state-remote-installer/main.go b/cmd/state-remote-installer/main.go index 3b0713db2e..eec8434900 100644 --- a/cmd/state-remote-installer/main.go +++ b/cmd/state-remote-installer/main.go @@ -16,10 +16,10 @@ import ( "github.com/ActiveState/cli/internal/constants" "github.com/ActiveState/cli/internal/errs" "github.com/ActiveState/cli/internal/events" - "github.com/ActiveState/cli/internal/exeutils" "github.com/ActiveState/cli/internal/locale" "github.com/ActiveState/cli/internal/logging" "github.com/ActiveState/cli/internal/multilog" + "github.com/ActiveState/cli/internal/osutils" "github.com/ActiveState/cli/internal/output" "github.com/ActiveState/cli/internal/primer" "github.com/ActiveState/cli/internal/prompt" @@ -201,7 +201,7 @@ func execute(out output.Outputer, prompt prompt.Prompter, cfg *config.Instance, env := []string{ constants.InstallerNoSubshell + "=true", } - _, cmd, err := exeutils.ExecuteAndPipeStd(filepath.Join(tmpDir, constants.StateInstallerCmd+exeutils.Extension), args, env) + _, cmd, err := osutils.ExecuteAndPipeStd(filepath.Join(tmpDir, constants.StateInstallerCmd+osutils.ExeExtension), args, env) if err != nil { if cmd != nil && cmd.ProcessState.Sys().(syscall.WaitStatus).Exited() { // The issue happened while running the command itself, meaning the responsibility for conveying the error diff --git a/cmd/state-svc/test/integration/svc_int_test.go b/cmd/state-svc/test/integration/svc_int_test.go index a5b51eadb5..8a0206c952 100644 --- a/cmd/state-svc/test/integration/svc_int_test.go +++ b/cmd/state-svc/test/integration/svc_int_test.go @@ -15,9 +15,9 @@ import ( "github.com/ActiveState/cli/internal/condition" "github.com/ActiveState/cli/internal/constants" - "github.com/ActiveState/cli/internal/exeutils" "github.com/ActiveState/cli/internal/fileutils" "github.com/ActiveState/cli/internal/logging" + "github.com/ActiveState/cli/internal/osutils" "github.com/ActiveState/cli/internal/svcctl" "github.com/ActiveState/cli/internal/testhelpers/e2e" "github.com/ActiveState/cli/internal/testhelpers/tagsuite" @@ -192,7 +192,7 @@ func (suite *SvcIntegrationTestSuite) GetNumStateSvcProcesses() int { for _, p := range procs { if name, err := p.Name(); err == nil { name = filepath.Base(name) // just in case an absolute path is returned - if svcName := constants.ServiceCommandName + exeutils.Extension; name == svcName { + if svcName := constants.ServiceCommandName + osutils.ExeExtension; name == svcName { count++ } } diff --git a/cmd/state/autoupdate.go b/cmd/state/autoupdate.go index bd8cf3ece3..9c380003d1 100644 --- a/cmd/state/autoupdate.go +++ b/cmd/state/autoupdate.go @@ -16,7 +16,6 @@ import ( "github.com/ActiveState/cli/internal/config" "github.com/ActiveState/cli/internal/constants" "github.com/ActiveState/cli/internal/errs" - "github.com/ActiveState/cli/internal/exeutils" "github.com/ActiveState/cli/internal/installation" "github.com/ActiveState/cli/internal/locale" "github.com/ActiveState/cli/internal/logging" @@ -178,7 +177,7 @@ func relaunch(args []string) (int, error) { return -1, &ErrStateExe{locale.WrapError(err, "err_state_exec")} } - code, _, err := exeutils.ExecuteAndPipeStd(exec, args[1:], []string{fmt.Sprintf("%s=true", constants.ForwardedStateEnvVarName)}) + code, _, err := osutils.ExecuteAndPipeStd(exec, args[1:], []string{fmt.Sprintf("%s=true", constants.ForwardedStateEnvVarName)}) if err != nil { return code, &ErrExecuteRelaunch{errs.Wrap(err, "Forwarded command after auto-updating failed. Exit code: %d", code)} } diff --git a/internal/installation/appinfo.go b/internal/installation/appinfo.go index 2d34827a43..c7d37906ca 100644 --- a/internal/installation/appinfo.go +++ b/internal/installation/appinfo.go @@ -22,10 +22,10 @@ const ( ) var execData = map[executableType]string{ - state: constants.StateCmd + osutils.ExeExt, - service: constants.StateSvcCmd + osutils.ExeExt, - installer: constants.StateInstallerCmd + osutils.ExeExt, - executor: constants.StateExecutorCmd + osutils.ExeExt, + state: constants.StateCmd + osutils.ExeExtension, + service: constants.StateSvcCmd + osutils.ExeExtension, + installer: constants.StateInstallerCmd + osutils.ExeExtension, + executor: constants.StateExecutorCmd + osutils.ExeExtension, } func newExec(exec executableType) (string, error) { diff --git a/internal/installation/paths.go b/internal/installation/paths.go index 6168fc7d9a..da18433c08 100644 --- a/internal/installation/paths.go +++ b/internal/installation/paths.go @@ -8,8 +8,8 @@ import ( "github.com/ActiveState/cli/internal/condition" "github.com/ActiveState/cli/internal/constants" "github.com/ActiveState/cli/internal/errs" - "github.com/ActiveState/cli/internal/exeutils" "github.com/ActiveState/cli/internal/fileutils" + "github.com/ActiveState/cli/internal/osutils" ) const ( @@ -81,7 +81,7 @@ func InstallPathFromExecPath() (string, error) { } func InstallPathFromReference(dir string) (string, error) { - cmdName := constants.StateCmd + exeutils.Extension + cmdName := constants.StateCmd + osutils.ExeExtension installPath := filepath.Dir(dir) binPath, err := BinPathFromInstallPath(installPath) if err != nil { diff --git a/internal/installation/paths_test.go b/internal/installation/paths_test.go index cac43a8823..fbdb62dfd8 100644 --- a/internal/installation/paths_test.go +++ b/internal/installation/paths_test.go @@ -6,8 +6,8 @@ import ( "testing" "github.com/ActiveState/cli/internal/constants" - "github.com/ActiveState/cli/internal/exeutils" "github.com/ActiveState/cli/internal/fileutils" + "github.com/ActiveState/cli/internal/osutils" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -110,7 +110,7 @@ func TestInstallPathFromReference(t *testing.T) { err = fileutils.Mkdir(binDir) require.NoError(t, err) - err = fileutils.Touch(filepath.Join(binDir, constants.StateCmd+exeutils.Extension)) + err = fileutils.Touch(filepath.Join(binDir, constants.StateCmd+osutils.ExeExtension)) require.NoError(t, err) t.Setenv(constants.HomeEnvVarName, home) diff --git a/internal/installmgr/stop.go b/internal/installmgr/stop.go index 58ca457d79..c0d8108f56 100644 --- a/internal/installmgr/stop.go +++ b/internal/installmgr/stop.go @@ -12,7 +12,6 @@ import ( "github.com/ActiveState/cli/internal/config" "github.com/ActiveState/cli/internal/constants" "github.com/ActiveState/cli/internal/errs" - "github.com/ActiveState/cli/internal/exeutils" "github.com/ActiveState/cli/internal/fileutils" "github.com/ActiveState/cli/internal/installation" "github.com/ActiveState/cli/internal/locale" @@ -46,7 +45,7 @@ func stopSvc(installPath string) error { } if fileutils.FileExists(svcExec) { - exitCode, _, err := exeutils.Execute(svcExec, []string{"stop"}, nil) + exitCode, _, err := osutils.Execute(svcExec, []string{"stop"}, nil) if err != nil { // We don't return these errors because we want to fall back on killing the process multilog.Error("Stopping %s returned error: %s", constants.SvcAppName, errs.JoinMessage(err)) @@ -74,7 +73,7 @@ func stopSvc(installPath string) error { continue } - svcName := constants.ServiceCommandName + exeutils.Extension + svcName := constants.ServiceCommandName + osutils.ExeExtension if n == svcName { exe, err := p.Exe() if err != nil { diff --git a/internal/language/language.go b/internal/language/language.go index c3355c0065..b582be56f1 100644 --- a/internal/language/language.go +++ b/internal/language/language.go @@ -5,8 +5,8 @@ import ( "strings" "github.com/ActiveState/cli/internal/constants" - "github.com/ActiveState/cli/internal/exeutils" "github.com/ActiveState/cli/internal/locale" + "github.com/ActiveState/cli/internal/osutils" "github.com/thoas/go-funk" ) @@ -58,11 +58,11 @@ var lookup = [...]languageData{ }, { "bash", "Bash", ".sh", true, "", "", - Executable{"bash" + exeutils.Extension, true}, + Executable{"bash" + osutils.ExeExtension, true}, }, { "sh", "Shell", ".sh", true, "", "", - Executable{"sh" + exeutils.Extension, true}, + Executable{"sh" + osutils.ExeExtension, true}, }, { "batch", "Batch", ".bat", false, "", "", diff --git a/internal/legacytray/legacytray.go b/internal/legacytray/legacytray.go index 7c7dcdee3c..4c32c08928 100644 --- a/internal/legacytray/legacytray.go +++ b/internal/legacytray/legacytray.go @@ -8,9 +8,9 @@ import ( "github.com/ActiveState/cli/internal/app" "github.com/ActiveState/cli/internal/config" "github.com/ActiveState/cli/internal/errs" - "github.com/ActiveState/cli/internal/exeutils" "github.com/ActiveState/cli/internal/fileutils" "github.com/ActiveState/cli/internal/installation" + "github.com/ActiveState/cli/internal/osutils" "github.com/ActiveState/cli/internal/osutils/autostart" "github.com/shirou/gopsutil/v3/process" ) @@ -21,7 +21,7 @@ const stateUpdateDialogCmd = "state-update-dialog" func DetectAndRemove(path string, cfg *config.Instance) error { binDir := filepath.Join(path, installation.BinDirName) - trayExec := filepath.Join(binDir, stateTrayCmd+exeutils.Extension) + trayExec := filepath.Join(binDir, stateTrayCmd+osutils.ExeExtension) if !fileutils.FileExists(trayExec) { return nil // nothing to do } @@ -57,7 +57,7 @@ func DetectAndRemove(path string, cfg *config.Instance) error { // Finally, remove state-tray and state-update-dialog executables. for _, name := range []string{stateTrayCmd, stateUpdateDialogCmd} { - if exec := filepath.Join(binDir, name+exeutils.Extension); fileutils.FileExists(exec) { + if exec := filepath.Join(binDir, name+osutils.ExeExtension); fileutils.FileExists(exec) { err = os.Remove(exec) if err != nil { return errs.Wrap(err, "Unable to remove %s", name) diff --git a/internal/exeutils/exeutils.go b/internal/osutils/exeutils.go similarity index 97% rename from internal/exeutils/exeutils.go rename to internal/osutils/exeutils.go index 5428920f06..8a334adb68 100644 --- a/internal/exeutils/exeutils.go +++ b/internal/osutils/exeutils.go @@ -1,4 +1,4 @@ -package exeutils +package osutils import ( "bytes" @@ -15,7 +15,6 @@ import ( "github.com/ActiveState/cli/internal/errs" "github.com/ActiveState/cli/internal/fileutils" "github.com/ActiveState/cli/internal/logging" - "github.com/ActiveState/cli/internal/osutils" ) // Executables will return all the Executables that need to be symlinked in the various provided bin directories @@ -133,7 +132,7 @@ func Execute(command string, arg []string, optSetter func(cmd *exec.Cmd) error) if err != nil { logging.Debug("Executing command returned error: %v", err) } - return osutils.CmdExitCode(cmd), cmd, err + return CmdExitCode(cmd), cmd, err } // ExecuteAndPipeStd will run the given command and pipe stdin, stdout and stderr @@ -157,7 +156,7 @@ func ExecuteAndForget(command string, args []string, opts ...func(cmd *exec.Cmd) } } - cmd.SysProcAttr = osutils.SysProcAttrForBackgroundProcess() + cmd.SysProcAttr = SysProcAttrForBackgroundProcess() if err := cmd.Start(); err != nil { return nil, errs.Wrap(err, "Could not start %s %v", command, args) } diff --git a/internal/exeutils/exeutils_test.go b/internal/osutils/exeutils_test.go similarity index 99% rename from internal/exeutils/exeutils_test.go rename to internal/osutils/exeutils_test.go index 9eb1552d2e..0a83f3d534 100644 --- a/internal/exeutils/exeutils_test.go +++ b/internal/osutils/exeutils_test.go @@ -1,4 +1,4 @@ -package exeutils +package osutils import ( "fmt" @@ -117,4 +117,4 @@ func TestExecuteAndPipeStdExitCode(t *testing.T) { assert.Equalf(t, tt.wantCode, got, "ExecuteAndPipeStd(%v, %v, %v)", tt.args.command, tt.args.arg, tt.args.env) }) } -} \ No newline at end of file +} diff --git a/internal/exeutils/exeutils_unix.go b/internal/osutils/exeutils_unix.go similarity index 61% rename from internal/exeutils/exeutils_unix.go rename to internal/osutils/exeutils_unix.go index 95b82ef43c..e37bae40fe 100644 --- a/internal/exeutils/exeutils_unix.go +++ b/internal/osutils/exeutils_unix.go @@ -1,8 +1,8 @@ //go:build !windows // +build !windows -package exeutils +package osutils -const Extension = "" +const ExeExtension = "" var exts = []string{} diff --git a/internal/exeutils/exeutils_windows.go b/internal/osutils/exeutils_windows.go similarity index 85% rename from internal/exeutils/exeutils_windows.go rename to internal/osutils/exeutils_windows.go index 7654183096..9221eab9b2 100644 --- a/internal/exeutils/exeutils_windows.go +++ b/internal/osutils/exeutils_windows.go @@ -1,4 +1,4 @@ -package exeutils +package osutils import ( "os" @@ -7,7 +7,7 @@ import ( "github.com/thoas/go-funk" ) -const Extension = ".exe" +const ExeExtension = ".exe" var exts = []string{".exe"} @@ -15,4 +15,3 @@ func init() { PATHEXT := os.Getenv("PATHEXT") exts = funk.Uniq(funk.Map(strings.Split(PATHEXT, string(os.PathListSeparator)), strings.ToLower).([]string)).([]string) } - diff --git a/internal/exeutils/find.go b/internal/osutils/find.go similarity index 91% rename from internal/exeutils/find.go rename to internal/osutils/find.go index a6fc74ef8d..6e0e14d189 100644 --- a/internal/exeutils/find.go +++ b/internal/osutils/find.go @@ -1,4 +1,4 @@ -package exeutils +package osutils import ( "os" @@ -20,7 +20,7 @@ func FindExeOnPATH(executable string) string { // FindExeOnPATH returns the first path from the PATH env var for which the executable exists func FilterExesOnPATH(executable string, PATH string, filter func(exe string) bool) []string { - return findExes(executable, PATH, exts, fileutils.TargetExists, filter) + return findExes(executable, PATH, exts, fileutils.TargetExists, filter) } func FindExeInside(executable string, PATH string) string { @@ -50,7 +50,7 @@ func findExes(executable string, PATH string, exts []string, fileExists func(str return result } -func findExe(executable string, PATH string, exts []string,fileExists func(string) bool, filter func(exe string) bool) string { +func findExe(executable string, PATH string, exts []string, fileExists func(string) bool, filter func(exe string) bool) string { r := findExes(executable, PATH, exts, fileExists, filter) if len(r) > 0 { return r[0] diff --git a/internal/exeutils/find_test.go b/internal/osutils/find_test.go similarity index 88% rename from internal/exeutils/find_test.go rename to internal/osutils/find_test.go index bed5da144d..b0c3386535 100644 --- a/internal/exeutils/find_test.go +++ b/internal/osutils/find_test.go @@ -1,4 +1,4 @@ -package exeutils +package osutils import ( "os" @@ -11,12 +11,12 @@ import ( func Test_FilterExesOnPATH(t *testing.T) { fileExistsIfEquals := func(equals string) func(string) bool { - return func(f string) bool { return f==equals } + return func(f string) bool { return f == equals } } fileExistsTrue := func(f string) bool { return true } fileExistsFalse := func(f string) bool { return false } - filterTrue := func(string) bool { return true} - filterFalse := func(string) bool { return false} + filterTrue := func(string) bool { return true } + filterFalse := func(string) bool { return false } PATH := strings.Join([]string{"test2", "test"}, string(os.PathListSeparator)) diff --git a/internal/osutils/shortcut/shortcut_linux.go b/internal/osutils/shortcut/shortcut_linux.go index 1a743c4c10..2809c9269d 100644 --- a/internal/osutils/shortcut/shortcut_linux.go +++ b/internal/osutils/shortcut/shortcut_linux.go @@ -6,10 +6,10 @@ import ( "strings" "github.com/ActiveState/cli/internal/errs" - "github.com/ActiveState/cli/internal/exeutils" "github.com/ActiveState/cli/internal/fileutils" "github.com/ActiveState/cli/internal/logging" "github.com/ActiveState/cli/internal/multilog" + "github.com/ActiveState/cli/internal/osutils" "github.com/ActiveState/cli/internal/rollbar" "github.com/ActiveState/cli/internal/strutils" ) @@ -72,7 +72,7 @@ func Save(target, path string, args []string, opts SaveOpts) (file string, err e // set the executable as trusted so users do not need to do it manually // gio is "Gnome input/output" - stdoutText, stderrText, err := exeutils.ExecSimple("gio", []string{"set", path, "metadata::trusted", "true"}, []string{}) + stdoutText, stderrText, err := osutils.ExecSimple("gio", []string{"set", path, "metadata::trusted", "true"}, []string{}) if err != nil { multilog.Log(logging.ErrorNoStacktrace, rollbar.Error)("Could not set desktop file as trusted: %v (stdout: %s; stderr: %s)", errs.JoinMessage(err), stdoutText, stderrText) } diff --git a/internal/osutils/vars_lin_mac.go b/internal/osutils/vars_lin_mac.go index d7ab766d0e..15f8fc04d6 100644 --- a/internal/osutils/vars_lin_mac.go +++ b/internal/osutils/vars_lin_mac.go @@ -1,9 +1,7 @@ +//go:build linux || darwin // +build linux darwin package osutils // LineSep is the line separator character string used on the GOOS const LineSep = "\n" - -// ExeExt is the extension used for executable files -const ExeExt = "" diff --git a/internal/osutils/vars_windows.go b/internal/osutils/vars_windows.go index 1931f2cae5..9e6a49ab09 100644 --- a/internal/osutils/vars_windows.go +++ b/internal/osutils/vars_windows.go @@ -1,9 +1,7 @@ +//go:build windows // +build windows package osutils // LineSep is the line separator character string used on the GOOS const LineSep = "\r\n" - -// ExeExt is the extension used for executable files -const ExeExt = ".exe" diff --git a/internal/runbits/auth/login.go b/internal/runbits/auth/login.go index b389b286d7..d4b8cb6cb0 100644 --- a/internal/runbits/auth/login.go +++ b/internal/runbits/auth/login.go @@ -21,7 +21,7 @@ import ( "github.com/go-openapi/strfmt" ) -// OpenURI aliases to exeutils.OpenURI which opens the given URI in your browser. This is being exposed so that it can be +// OpenURI aliases to osutils.OpenURI which opens the given URI in your browser. This is being exposed so that it can be // overwritten in tests var OpenURI = osutils.OpenURI diff --git a/internal/runners/clean/run_lin_mac.go b/internal/runners/clean/run_lin_mac.go index 912ee70832..76fb7fe52e 100644 --- a/internal/runners/clean/run_lin_mac.go +++ b/internal/runners/clean/run_lin_mac.go @@ -12,13 +12,13 @@ import ( "github.com/ActiveState/cli/internal/config" "github.com/ActiveState/cli/internal/constants" "github.com/ActiveState/cli/internal/errs" - "github.com/ActiveState/cli/internal/exeutils" "github.com/ActiveState/cli/internal/fileutils" "github.com/ActiveState/cli/internal/installation" "github.com/ActiveState/cli/internal/installation/storage" "github.com/ActiveState/cli/internal/legacytray" "github.com/ActiveState/cli/internal/locale" "github.com/ActiveState/cli/internal/logging" + "github.com/ActiveState/cli/internal/osutils" "github.com/ActiveState/cli/internal/output" "github.com/ActiveState/cli/internal/strutils" ) @@ -197,7 +197,7 @@ func cleanInstallDir(dir string, cfg *config.Instance) error { var asFiles = []string{ installation.InstallDirMarker, - constants.StateInstallerCmd + exeutils.Extension, + constants.StateInstallerCmd + osutils.ExeExtension, } // Remove all of the state tool executables and finally the diff --git a/internal/runners/clean/run_win.go b/internal/runners/clean/run_win.go index d6c0c47b41..0df2a1fa8b 100644 --- a/internal/runners/clean/run_win.go +++ b/internal/runners/clean/run_win.go @@ -14,7 +14,6 @@ import ( "github.com/ActiveState/cli/internal/assets" "github.com/ActiveState/cli/internal/config" "github.com/ActiveState/cli/internal/errs" - "github.com/ActiveState/cli/internal/exeutils" "github.com/ActiveState/cli/internal/installation" "github.com/ActiveState/cli/internal/installation/storage" "github.com/ActiveState/cli/internal/language" @@ -154,7 +153,7 @@ func removePaths(logFile string, paths ...string) error { args := []string{"/C", sf.Filename(), logFile, fmt.Sprintf("%d", os.Getpid()), filepath.Base(exe)} args = append(args, paths...) - _, err = exeutils.ExecuteAndForget("cmd.exe", args) + _, err = osutils.ExecuteAndForget("cmd.exe", args) if err != nil { return locale.WrapError(err, "err_clean_start", "Could not start remove direcotry script") } diff --git a/internal/runners/clean/stop.go b/internal/runners/clean/stop.go index 7acbbe6878..25c8e987ef 100644 --- a/internal/runners/clean/stop.go +++ b/internal/runners/clean/stop.go @@ -3,10 +3,10 @@ package clean import ( "github.com/ActiveState/cli/internal/constants" "github.com/ActiveState/cli/internal/errs" - "github.com/ActiveState/cli/internal/exeutils" "github.com/ActiveState/cli/internal/fileutils" "github.com/ActiveState/cli/internal/installation" "github.com/ActiveState/cli/internal/locale" + "github.com/ActiveState/cli/internal/osutils" "github.com/ActiveState/cli/internal/output" "github.com/ActiveState/cli/internal/svcctl" ) @@ -22,7 +22,7 @@ func stopServices(cfg configurable, out output.Outputer, ipComm svcctl.IPCommuni // Stop state-svc before accessing its files if fileutils.FileExists(svcExec) { - code, _, err := exeutils.Execute(svcExec, []string{"stop"}, nil) + code, _, err := osutils.Execute(svcExec, []string{"stop"}, nil) if err != nil { if !ignoreErrors { return errs.AddTips( diff --git a/internal/runners/deploy/deploy.go b/internal/runners/deploy/deploy.go index 6dbf1cae6f..a420bca79f 100644 --- a/internal/runners/deploy/deploy.go +++ b/internal/runners/deploy/deploy.go @@ -13,7 +13,6 @@ import ( "github.com/ActiveState/cli/internal/assets" "github.com/ActiveState/cli/internal/config" "github.com/ActiveState/cli/internal/errs" - "github.com/ActiveState/cli/internal/exeutils" "github.com/ActiveState/cli/internal/fileutils" "github.com/ActiveState/cli/internal/locale" "github.com/ActiveState/cli/internal/logging" @@ -250,13 +249,13 @@ func (d *Deploy) symlink(rtTarget setup.Targeter, overwrite bool) error { return locale.WrapError(err, "err_symlink_exes", "Could not detect executable paths") } - exes, err := exeutils.Executables(bins) + exes, err := osutils.Executables(bins) if err != nil { return locale.WrapError(err, "err_symlink_exes", "Could not detect executables") } // Remove duplicate executables as per PATH and PATHEXT - exes, err = exeutils.UniqueExes(exes, os.Getenv("PATHEXT")) + exes, err = osutils.UniqueExes(exes, os.Getenv("PATHEXT")) if err != nil { return locale.WrapError(err, "err_unique_exes", "Could not detect unique executables, make sure your PATH and PATHEXT environment variables are properly configured.") } diff --git a/internal/runners/exec/exec.go b/internal/runners/exec/exec.go index 855199efdf..0bcfd2a4a6 100644 --- a/internal/runners/exec/exec.go +++ b/internal/runners/exec/exec.go @@ -12,13 +12,13 @@ import ( "github.com/ActiveState/cli/internal/analytics" "github.com/ActiveState/cli/internal/constants" "github.com/ActiveState/cli/internal/errs" - "github.com/ActiveState/cli/internal/exeutils" "github.com/ActiveState/cli/internal/fileutils" "github.com/ActiveState/cli/internal/hash" "github.com/ActiveState/cli/internal/language" "github.com/ActiveState/cli/internal/locale" "github.com/ActiveState/cli/internal/logging" "github.com/ActiveState/cli/internal/multilog" + "github.com/ActiveState/cli/internal/osutils" "github.com/ActiveState/cli/internal/output" "github.com/ActiveState/cli/internal/primer" "github.com/ActiveState/cli/internal/rtutils" @@ -155,7 +155,7 @@ func (s *Exec) Run(params *Params, args ...string) (rerr error) { RTPATH := strings.Join(rtDirs, string(os.PathListSeparator)) // Report recursive execution of executor: The path for the executable should be different from the default bin dir - exesOnPath := exeutils.FilterExesOnPATH(args[0], RTPATH, func(exe string) bool { + exesOnPath := osutils.FilterExesOnPATH(args[0], RTPATH, func(exe string) bool { v, err := executors.IsExecutor(exe) if err != nil { logging.Error("Could not find out if executable is an executor: %s", errs.JoinMessage(err)) @@ -171,7 +171,7 @@ func (s *Exec) Run(params *Params, args ...string) (rerr error) { // Guard against invoking the executor from PATH (ie. by name alone) if os.Getenv(constants.ExecRecursionAllowEnvVarName) != "true" && filepath.Base(exeTarget) == exeTarget { // not a full path - exe := exeutils.FindExeInside(exeTarget, env["PATH"]) + exe := osutils.FindExeInside(exeTarget, env["PATH"]) if exe != exeTarget { // Found the exe name on our PATH isExec, err := executors.IsExecutor(exe) if err != nil { diff --git a/internal/scriptrun/scriptrun.go b/internal/scriptrun/scriptrun.go index 9894a51c3e..e8a1014d9d 100644 --- a/internal/scriptrun/scriptrun.go +++ b/internal/scriptrun/scriptrun.go @@ -8,10 +8,10 @@ import ( "github.com/ActiveState/cli/internal/analytics" "github.com/ActiveState/cli/internal/config" "github.com/ActiveState/cli/internal/errs" - "github.com/ActiveState/cli/internal/exeutils" "github.com/ActiveState/cli/internal/language" "github.com/ActiveState/cli/internal/locale" "github.com/ActiveState/cli/internal/logging" + "github.com/ActiveState/cli/internal/osutils" "github.com/ActiveState/cli/internal/output" "github.com/ActiveState/cli/internal/process" "github.com/ActiveState/cli/internal/rtutils" @@ -203,5 +203,5 @@ func (s *ScriptRun) Run(script *project.Script, args []string) error { } func PathProvidesExec(path, exec string) bool { - return exeutils.FindExeInside(exec, path) != "" + return osutils.FindExeInside(exec, path) != "" } diff --git a/internal/svcctl/svcctl.go b/internal/svcctl/svcctl.go index f0a5e283dc..7bdc5e6208 100644 --- a/internal/svcctl/svcctl.go +++ b/internal/svcctl/svcctl.go @@ -15,12 +15,12 @@ import ( "github.com/ActiveState/cli/internal/constants" "github.com/ActiveState/cli/internal/errs" - "github.com/ActiveState/cli/internal/exeutils" "github.com/ActiveState/cli/internal/fileutils" "github.com/ActiveState/cli/internal/installation" "github.com/ActiveState/cli/internal/ipc" "github.com/ActiveState/cli/internal/locale" "github.com/ActiveState/cli/internal/logging" + "github.com/ActiveState/cli/internal/osutils" "github.com/ActiveState/cli/internal/profile" ) @@ -156,7 +156,7 @@ func startAndWait(ctx context.Context, ipComm IPCommunicator, exec, argText stri debugInfo := newDebugData(ipComm, startSvc, argText) - if _, err := exeutils.ExecuteAndForget(exec, args); err != nil { + if _, err := osutils.ExecuteAndForget(exec, args); err != nil { return locale.WrapError(err, "svcctl_cannot_exec_and_forget", "Cannot execute service in background: {{.V0}}", err.Error()) } diff --git a/internal/testhelpers/e2e/session.go b/internal/testhelpers/e2e/session.go index d80effa8eb..229fe42cf3 100644 --- a/internal/testhelpers/e2e/session.go +++ b/internal/testhelpers/e2e/session.go @@ -25,7 +25,6 @@ import ( "github.com/ActiveState/cli/internal/constants" "github.com/ActiveState/cli/internal/environment" "github.com/ActiveState/cli/internal/errs" - "github.com/ActiveState/cli/internal/exeutils" "github.com/ActiveState/cli/internal/fileutils" "github.com/ActiveState/cli/internal/installation" "github.com/ActiveState/cli/internal/logging" @@ -83,21 +82,21 @@ func init() { // Get username / password from `state secrets` so we can run tests without needing special env setup if PersistentUsername == "" { - out, stderr, err := exeutils.ExecSimpleFromDir(environment.GetRootPathUnsafe(), "state", []string{"secrets", "get", "project.INTEGRATION_TEST_USERNAME"}, []string{}) + out, stderr, err := osutils.ExecSimpleFromDir(environment.GetRootPathUnsafe(), "state", []string{"secrets", "get", "project.INTEGRATION_TEST_USERNAME"}, []string{}) if err != nil { fmt.Printf("WARNING!!! Could not retrieve username via state secrets: %v, stdout/stderr: %v\n%v\n", err, out, stderr) } PersistentUsername = strings.TrimSpace(out) } if PersistentPassword == "" { - out, stderr, err := exeutils.ExecSimpleFromDir(environment.GetRootPathUnsafe(), "state", []string{"secrets", "get", "project.INTEGRATION_TEST_PASSWORD"}, []string{}) + out, stderr, err := osutils.ExecSimpleFromDir(environment.GetRootPathUnsafe(), "state", []string{"secrets", "get", "project.INTEGRATION_TEST_PASSWORD"}, []string{}) if err != nil { fmt.Printf("WARNING!!! Could not retrieve password via state secrets: %v, stdout/stderr: %v\n%v\n", err, out, stderr) } PersistentPassword = strings.TrimSpace(out) } if PersistentToken == "" { - out, stderr, err := exeutils.ExecSimpleFromDir(environment.GetRootPathUnsafe(), "state", []string{"secrets", "get", "project.INTEGRATION_TEST_TOKEN"}, []string{}) + out, stderr, err := osutils.ExecSimpleFromDir(environment.GetRootPathUnsafe(), "state", []string{"secrets", "get", "project.INTEGRATION_TEST_TOKEN"}, []string{}) if err != nil { fmt.Printf("WARNING!!! Could not retrieve token via state secrets: %v, stdout/stderr: %v\n%v\n", err, out, stderr) } @@ -149,9 +148,9 @@ func executablePaths(t *testing.T) (string, string, string) { root := environment.GetRootPathUnsafe() buildDir := fileutils.Join(root, "build") - stateExec := filepath.Join(buildDir, constants.StateCmd+osutils.ExeExt) - svcExec := filepath.Join(buildDir, constants.StateSvcCmd+osutils.ExeExt) - executorExec := filepath.Join(buildDir, constants.StateExecutorCmd+osutils.ExeExt) + stateExec := filepath.Join(buildDir, constants.StateCmd+osutils.ExeExtension) + svcExec := filepath.Join(buildDir, constants.StateSvcCmd+osutils.ExeExtension) + executorExec := filepath.Join(buildDir, constants.StateExecutorCmd+osutils.ExeExtension) if !fileutils.FileExists(stateExec) { t.Fatal("E2E tests require a State Tool binary. Run `state run build`.") @@ -678,7 +677,7 @@ func (s *Session) SvcLog() string { } b := fileutils.ReadFileUnsafe(file) lines = append(lines, filepath.Base(file)+":"+strings.Split(string(b), "\n")[0]) - if !strings.Contains(string(b), fmt.Sprintf("state-svc%s foreground", exeutils.Extension)) { + if !strings.Contains(string(b), fmt.Sprintf("state-svc%s foreground", osutils.ExeExtension)) { continue } diff --git a/internal/testhelpers/secrethelper/secrethelper.go b/internal/testhelpers/secrethelper/secrethelper.go index 8a734ad09f..f77f6d3c36 100644 --- a/internal/testhelpers/secrethelper/secrethelper.go +++ b/internal/testhelpers/secrethelper/secrethelper.go @@ -5,14 +5,14 @@ import ( "github.com/ActiveState/cli/internal/environment" "github.com/ActiveState/cli/internal/errs" - "github.com/ActiveState/cli/internal/exeutils" + "github.com/ActiveState/cli/internal/osutils" ) func GetSecretIfEmpty(value string, key string) string { if value != "" { return value } - out, stderr, err := exeutils.ExecSimpleFromDir(environment.GetRootPathUnsafe(), "state", []string{"secrets", "get", key}, []string{}) + out, stderr, err := osutils.ExecSimpleFromDir(environment.GetRootPathUnsafe(), "state", []string{"secrets", "get", key}, []string{}) if err != nil { panic(errs.Wrap(err, stderr)) } @@ -20,7 +20,7 @@ func GetSecretIfEmpty(value string, key string) string { } func GetSecret(key string) string { - out, stderr, err := exeutils.ExecSimpleFromDir(environment.GetRootPathUnsafe(), "state", []string{"secrets", "get", key}, []string{}) + out, stderr, err := osutils.ExecSimpleFromDir(environment.GetRootPathUnsafe(), "state", []string{"secrets", "get", key}, []string{}) if err != nil { panic(errs.Wrap(err, stderr)) } diff --git a/internal/updater/updater.go b/internal/updater/updater.go index 4e97ba79b3..4d9ad9726d 100644 --- a/internal/updater/updater.go +++ b/internal/updater/updater.go @@ -16,7 +16,6 @@ import ( "github.com/ActiveState/cli/internal/analytics/dimensions" "github.com/ActiveState/cli/internal/constants" "github.com/ActiveState/cli/internal/errs" - "github.com/ActiveState/cli/internal/exeutils" "github.com/ActiveState/cli/internal/fileutils" "github.com/ActiveState/cli/internal/graph" "github.com/ActiveState/cli/internal/installation" @@ -29,7 +28,7 @@ import ( const ( CfgKeyInstallVersion = "state_tool_installer_version" - InstallerName = "state-installer" + osutils.ExeExt + InstallerName = "state-installer" + osutils.ExeExtension ) type ErrorInProgress struct{ *locale.LocalizedError } @@ -226,7 +225,7 @@ func (u *UpdateInstaller) InstallBlocking(installTargetPath string, args ...stri envs = append(envs, fmt.Sprintf("%s=%s", constants.UpdateTagEnvVarName, *u.AvailableUpdate.Tag)) } - _, _, err = exeutils.ExecuteAndPipeStd(installerPath, args, envs) + _, _, err = osutils.ExecuteAndPipeStd(installerPath, args, envs) if err != nil { return errs.Wrap(err, "Could not run installer") } @@ -244,7 +243,7 @@ func (u *UpdateInstaller) InstallWithProgress(installTargetPath string, progress return nil, err } - proc, err := exeutils.ExecuteAndForget(installerPath, args, func(cmd *exec.Cmd) error { + proc, err := osutils.ExecuteAndForget(installerPath, args, func(cmd *exec.Cmd) error { var stdout io.ReadCloser var stderr io.ReadCloser if stderr, err = cmd.StderrPipe(); err != nil { diff --git a/pkg/platform/runtime/envdef/environment.go b/pkg/platform/runtime/envdef/environment.go index 4cfb8a0c2b..822b5492b5 100644 --- a/pkg/platform/runtime/envdef/environment.go +++ b/pkg/platform/runtime/envdef/environment.go @@ -9,7 +9,7 @@ import ( "strings" "github.com/ActiveState/cli/internal/errs" - "github.com/ActiveState/cli/internal/exeutils" + "github.com/ActiveState/cli/internal/osutils" "github.com/thoas/go-funk" "github.com/ActiveState/cli/internal/fileutils" @@ -397,13 +397,13 @@ func (ed *EnvironmentDefinition) ExecutablePaths() (ExecutablePaths, error) { bins = strings.Split(p, string(os.PathListSeparator)) } - exes, err := exeutils.Executables(bins) + exes, err := osutils.Executables(bins) if err != nil { return nil, errs.Wrap(err, "Could not detect executables") } // Remove duplicate executables as per PATH and PATHEXT - exes, err = exeutils.UniqueExes(exes, os.Getenv("PATHEXT")) + exes, err = osutils.UniqueExes(exes, os.Getenv("PATHEXT")) if err != nil { return nil, errs.Wrap(err, "Could not detect unique executables, make sure your PATH and PATHEXT environment variables are properly configured.") } diff --git a/pkg/platform/runtime/executors/executors.go b/pkg/platform/runtime/executors/executors.go index 3c5c88dd80..743ecc0af0 100644 --- a/pkg/platform/runtime/executors/executors.go +++ b/pkg/platform/runtime/executors/executors.go @@ -9,7 +9,6 @@ import ( "github.com/ActiveState/cli/pkg/project" - "github.com/ActiveState/cli/internal/exeutils" "github.com/ActiveState/cli/internal/installation" "github.com/ActiveState/cli/internal/osutils" "github.com/ActiveState/cli/pkg/platform/runtime/envdef" @@ -99,8 +98,8 @@ func makeAlias(destination string) string { if rt.GOOS == "windows" { ext := filepath.Ext(alias) - if ext != "" && ext != exeutils.Extension { // for non-.exe executables like pip.bat - alias = strings.TrimSuffix(alias, ext) + exeutils.Extension // setup alias pip.exe -> pip.bat + if ext != "" && ext != osutils.ExeExtension { // for non-.exe executables like pip.bat + alias = strings.TrimSuffix(alias, ext) + osutils.ExeExtension // setup alias pip.exe -> pip.bat } } diff --git a/scripts/ci/parallelize/parallelize.go b/scripts/ci/parallelize/parallelize.go index 24360ace9a..eb177ab8db 100644 --- a/scripts/ci/parallelize/parallelize.go +++ b/scripts/ci/parallelize/parallelize.go @@ -12,7 +12,6 @@ import ( "github.com/ActiveState/cli/internal/constraints" "github.com/ActiveState/cli/internal/errs" - "github.com/ActiveState/cli/internal/exeutils" "github.com/ActiveState/cli/internal/fileutils" "github.com/ActiveState/cli/internal/installation/storage" "github.com/ActiveState/cli/internal/osutils" @@ -35,7 +34,7 @@ func main() { } func run() error { - if len(os.Args) <= 1{ + if len(os.Args) <= 1 { return errs.New("Must provide single argument with JSON blob, or [job ] to check the results of a job.") } @@ -120,8 +119,7 @@ func runJob(job Job) { return } - - code, _, err := exeutils.Execute(job.Args[0] + osutils.ExeExt, job.Args[1:], func(cmd *exec.Cmd) error { + code, _, err := osutils.Execute(job.Args[0]+osutils.ExeExtension, job.Args[1:], func(cmd *exec.Cmd) error { cmd.Stdout = outfile cmd.Stderr = outfile cmd.Env = append(job.Env, os.Environ()...) @@ -136,14 +134,14 @@ func runJob(job Job) { func readJob(id string) error { jobfile := filepath.Join(jobDir(), fmt.Sprintf("%s.out", id)) - if ! fileutils.FileExists(jobfile) { + if !fileutils.FileExists(jobfile) { return errs.New("Job does not exist: %s", jobfile) } contents := strings.Split(string(fileutils.ReadFileUnsafe(jobfile)), "\n") code, err := strconv.Atoi(contents[len(contents)-1]) if err != nil { - return errs.Wrap(err,"Expected last line to be the exit code, instead found: %s", contents[len(contents)-1]) + return errs.Wrap(err, "Expected last line to be the exit code, instead found: %s", contents[len(contents)-1]) } fmt.Println(strings.Join(contents[0:(len(contents)-2)], "\n")) diff --git a/scripts/ci/payload-generator/main.go b/scripts/ci/payload-generator/main.go index 888d7c033b..cd599da54f 100644 --- a/scripts/ci/payload-generator/main.go +++ b/scripts/ci/payload-generator/main.go @@ -9,9 +9,9 @@ import ( "github.com/ActiveState/cli/internal/constants" "github.com/ActiveState/cli/internal/environment" - "github.com/ActiveState/cli/internal/exeutils" "github.com/ActiveState/cli/internal/fileutils" "github.com/ActiveState/cli/internal/installation" + "github.com/ActiveState/cli/internal/osutils" ) var ( @@ -67,10 +67,10 @@ func generatePayload(inDir, outDir, binDir, branch, version string) error { } files := map[string]string{ - filepath.Join(inDir, constants.StateInstallerCmd+exeutils.Extension): outDir, - filepath.Join(inDir, constants.StateCmd+exeutils.Extension): binDir, - filepath.Join(inDir, constants.StateSvcCmd+exeutils.Extension): binDir, - filepath.Join(inDir, constants.StateExecutorCmd+exeutils.Extension): binDir, + filepath.Join(inDir, constants.StateInstallerCmd+osutils.ExeExtension): outDir, + filepath.Join(inDir, constants.StateCmd+osutils.ExeExtension): binDir, + filepath.Join(inDir, constants.StateSvcCmd+osutils.ExeExtension): binDir, + filepath.Join(inDir, constants.StateExecutorCmd+osutils.ExeExtension): binDir, } if err := copyFiles(files); err != nil { return fmt.Errorf(emsg, err) diff --git a/scripts/ci/propagate-pr/main.go b/scripts/ci/propagate-pr/main.go index 1c8217843f..af07694dac 100644 --- a/scripts/ci/propagate-pr/main.go +++ b/scripts/ci/propagate-pr/main.go @@ -8,7 +8,7 @@ import ( "github.com/ActiveState/cli/internal/environment" "github.com/ActiveState/cli/internal/errs" - "github.com/ActiveState/cli/internal/exeutils" + "github.com/ActiveState/cli/internal/osutils" wc "github.com/ActiveState/cli/scripts/internal/workflow-controllers" wh "github.com/ActiveState/cli/scripts/internal/workflow-helpers" "github.com/andygrunwald/go-jira" @@ -126,12 +126,12 @@ func run() error { } root := environment.GetRootPathUnsafe() - stdout, stderr, err := exeutils.ExecSimpleFromDir(root, "git", []string{"checkout", v.TargetBranch}, nil) + stdout, stderr, err := osutils.ExecSimpleFromDir(root, "git", []string{"checkout", v.TargetBranch}, nil) if err != nil { return errs.Wrap(err, "failed to checkout %s, stdout:\n%s\nstderr:\n%s", v.TargetBranch, stdout, stderr) } - stdout, stderr, err = exeutils.ExecSimpleFromDir(root, "git", []string{ + stdout, stderr, err = osutils.ExecSimpleFromDir(root, "git", []string{ "merge", v.SourceBranch, "--no-edit", "-m", fmt.Sprintf("Merge branch %s to adopt changes from PR #%d", v.SourceBranch, prNumber), @@ -143,7 +143,7 @@ func run() error { v.SourceBranch, v.TargetBranch, intend[i:].String(), stdout, stderr) } - stdout, stderr, err = exeutils.ExecSimpleFromDir(root, "git", []string{"push"}, nil) + stdout, stderr, err = osutils.ExecSimpleFromDir(root, "git", []string{"push"}, nil) if err != nil { return errs.Wrap(err, "failed to merge %s into %s. please manually merge the following branches: %s"+ diff --git a/scripts/ci/update-generator/main.go b/scripts/ci/update-generator/main.go index dfd2b51925..2e1026a49b 100644 --- a/scripts/ci/update-generator/main.go +++ b/scripts/ci/update-generator/main.go @@ -106,7 +106,7 @@ func createUpdate(outputPath, channel, version, versionNumber, platform, target } func createInstaller(buildPath, outputPath, channel, platform string) error { - installer := filepath.Join(buildPath, "state-installer"+osutils.ExeExt) + installer := filepath.Join(buildPath, "state-installer"+osutils.ExeExtension) if !fileutils.FileExists(installer) { return errs.New("state-installer does not exist in build dir") } diff --git a/scripts/grab-mergecommits/main.go b/scripts/grab-mergecommits/main.go index 937b597cff..af241ffeef 100644 --- a/scripts/grab-mergecommits/main.go +++ b/scripts/grab-mergecommits/main.go @@ -8,7 +8,7 @@ import ( "time" "github.com/ActiveState/cli/internal/errs" - "github.com/ActiveState/cli/internal/exeutils" + "github.com/ActiveState/cli/internal/osutils" "github.com/ActiveState/cli/internal/sliceutils" wh "github.com/ActiveState/cli/scripts/internal/workflow-helpers" "github.com/thoas/go-funk" @@ -95,7 +95,7 @@ func orderCommits(hashes []string) []string { for _, hash := range hashes { handled := false for oidx, ohash := range ordered { - code, _, err := exeutils.Execute("git", []string{"merge-base", "--is-ancestor", hash, ohash}, nil) + code, _, err := osutils.Execute("git", []string{"merge-base", "--is-ancestor", hash, ohash}, nil) if err != nil && !errs.Matches(err, &exec.ExitError{}) { panic(err) } diff --git a/scripts/start-story/main.go b/scripts/start-story/main.go index becb60a4bd..83e0896645 100644 --- a/scripts/start-story/main.go +++ b/scripts/start-story/main.go @@ -6,7 +6,7 @@ import ( "github.com/ActiveState/cli/internal/environment" "github.com/ActiveState/cli/internal/errs" - "github.com/ActiveState/cli/internal/exeutils" + "github.com/ActiveState/cli/internal/osutils" wc "github.com/ActiveState/cli/scripts/internal/workflow-controllers" wh "github.com/ActiveState/cli/scripts/internal/workflow-helpers" "github.com/andygrunwald/go-jira" @@ -103,19 +103,19 @@ func run() error { return nil } - stdout, stderr, err := exeutils.ExecSimpleFromDir(environment.GetRootPathUnsafe(), "git", []string{"checkout", ref}, nil) + stdout, stderr, err := osutils.ExecSimpleFromDir(environment.GetRootPathUnsafe(), "git", []string{"checkout", ref}, nil) if err != nil { return errs.Wrap(err, "failed to checkout base ref, stdout:\n%s\nstderr:\n%s", stdout, stderr) } - stdout, stderr, err = exeutils.ExecSimpleFromDir(environment.GetRootPathUnsafe(), "git", []string{"pull", "--rebase"}, nil) + stdout, stderr, err = osutils.ExecSimpleFromDir(environment.GetRootPathUnsafe(), "git", []string{"pull", "--rebase"}, nil) if err != nil { return errs.Wrap(err, "failed to pull latest changes, stdout:\n%s\nstderr:\n%s", stdout, stderr) } - stdout, stderr, err = exeutils.ExecSimpleFromDir(environment.GetRootPathUnsafe(), "git", []string{"branch", branchName}, nil) + stdout, stderr, err = osutils.ExecSimpleFromDir(environment.GetRootPathUnsafe(), "git", []string{"branch", branchName}, nil) if err != nil { return errs.Wrap(err, "failed to create branch, stdout:\n%s\nstderr:\n%s", stdout, stderr) } - stdout, stderr, err = exeutils.ExecSimpleFromDir(environment.GetRootPathUnsafe(), "git", []string{"checkout", branchName}, nil) + stdout, stderr, err = osutils.ExecSimpleFromDir(environment.GetRootPathUnsafe(), "git", []string{"checkout", branchName}, nil) if err != nil { return errs.Wrap(err, "failed to checkout branch, stdout:\n%s\nstderr:\n%s", stdout, stderr) } diff --git a/test/integration/activate_int_test.go b/test/integration/activate_int_test.go index c37c3a81ed..2f3010f1ea 100644 --- a/test/integration/activate_int_test.go +++ b/test/integration/activate_int_test.go @@ -18,8 +18,8 @@ import ( "github.com/ActiveState/cli/internal/rtutils" "github.com/ActiveState/cli/internal/constants" - "github.com/ActiveState/cli/internal/exeutils" "github.com/ActiveState/cli/internal/fileutils" + "github.com/ActiveState/cli/internal/osutils" "github.com/ActiveState/cli/internal/testhelpers/e2e" "github.com/ActiveState/cli/internal/testhelpers/tagsuite" ) @@ -65,7 +65,7 @@ func (suite *ActivateIntegrationTestSuite) TestActivateWithoutRuntime() { // addForegroundSvc launches the state-svc in a way where we can track its output for debugging purposes // without this we are mostly blind to the svc exiting prematurely func (suite *ActivateIntegrationTestSuite) addForegroundSvc(ts *e2e.Session) func() { - cmd, stdout, stderr, err := exeutils.ExecuteInBackground(ts.SvcExe, []string{"foreground"}, func(cmd *exec.Cmd) error { + cmd, stdout, stderr, err := osutils.ExecuteInBackground(ts.SvcExe, []string{"foreground"}, func(cmd *exec.Cmd) error { cmd.Env = append(ts.Env, "VERBOSE=true", "") // For whatever reason the last entry is ignored.. return nil }) @@ -75,7 +75,7 @@ func (suite *ActivateIntegrationTestSuite) addForegroundSvc(ts *e2e.Session) fun rtutils.Timeout(func() error { code := -1 for code != 0 { - code, _, _ = exeutils.Execute(ts.SvcExe, []string{"status"}, func(cmd *exec.Cmd) error { + code, _, _ = osutils.Execute(ts.SvcExe, []string{"status"}, func(cmd *exec.Cmd) error { cmd.Env = ts.Env return nil }) @@ -89,7 +89,7 @@ func (suite *ActivateIntegrationTestSuite) addForegroundSvc(ts *e2e.Session) fun defer func() { suite.Require().Nil(recover()) }() - stdout, stderr, err := exeutils.ExecSimple(ts.SvcExe, []string{"stop"}, ts.Env) + stdout, stderr, err := osutils.ExecSimple(ts.SvcExe, []string{"stop"}, ts.Env) suite.Require().NoError(err, "svc stop failed: %s\n%s", stdout, stderr) }() @@ -257,7 +257,7 @@ func (suite *ActivateIntegrationTestSuite) activatePython(version string, extraE cp.SendLine("state activate --default") cp.Expect("Creating a Virtual Environment") cp.ExpectInput(termtest.OptExpectTimeout(40 * time.Second)) - pythonShim := pythonExe + exeutils.Extension + pythonShim := pythonExe + osutils.ExeExtension // test that other executables that use python work as well pipExe := "pip" + version diff --git a/test/integration/checkout_int_test.go b/test/integration/checkout_int_test.go index e7a3a87ed6..f156810d32 100644 --- a/test/integration/checkout_int_test.go +++ b/test/integration/checkout_int_test.go @@ -11,8 +11,8 @@ import ( "github.com/stretchr/testify/suite" "github.com/ActiveState/cli/internal/constants" - "github.com/ActiveState/cli/internal/exeutils" "github.com/ActiveState/cli/internal/fileutils" + "github.com/ActiveState/cli/internal/osutils" "github.com/ActiveState/cli/internal/testhelpers/e2e" "github.com/ActiveState/cli/internal/testhelpers/tagsuite" "github.com/ActiveState/cli/pkg/platform/runtime/setup" @@ -50,7 +50,7 @@ func (suite *CheckoutIntegrationTestSuite) TestCheckout() { // Verify runtime was installed correctly and works. targetDir := target.ProjectDirToTargetDir(ts.Dirs.Work, ts.Dirs.Cache) - pythonExe := filepath.Join(setup.ExecDir(targetDir), "python3"+exeutils.Extension) + pythonExe := filepath.Join(setup.ExecDir(targetDir), "python3"+osutils.ExeExtension) cp = ts.SpawnCmd(pythonExe, "--version") cp.Expect("Python 3") cp.ExpectExitCode(0) @@ -186,7 +186,7 @@ func (suite *CheckoutIntegrationTestSuite) TestCheckoutCustomRTPath() { ) cp.Expect("Checked out project", e2e.RuntimeSourcingTimeoutOpt) - pythonExe := filepath.Join(setup.ExecDir(customRTPath), "python3"+exeutils.Extension) + pythonExe := filepath.Join(setup.ExecDir(customRTPath), "python3"+osutils.ExeExtension) suite.Require().True(fileutils.DirExists(customRTPath)) suite.Require().True(fileutils.FileExists(pythonExe)) diff --git a/test/integration/executor_int_test.go b/test/integration/executor_int_test.go index f65577d71a..ef68fd7586 100644 --- a/test/integration/executor_int_test.go +++ b/test/integration/executor_int_test.go @@ -8,7 +8,7 @@ import ( "github.com/stretchr/testify/suite" "github.com/ActiveState/cli/internal/constants" - "github.com/ActiveState/cli/internal/exeutils" + "github.com/ActiveState/cli/internal/osutils" "github.com/ActiveState/cli/internal/testhelpers/e2e" "github.com/ActiveState/cli/internal/testhelpers/tagsuite" ) @@ -83,7 +83,7 @@ func (suite *ExecutorIntegrationTestSuite) TestExecutorSizeOnDisk() { ts := e2e.New(suite.T(), false) defer ts.Close() - execFilePath := filepath.Join(ts.Dirs.Bin, constants.StateExecutorCmd+exeutils.Extension) + execFilePath := filepath.Join(ts.Dirs.Bin, constants.StateExecutorCmd+osutils.ExeExtension) fi, err := os.Stat(execFilePath) suite.Require().NoError(err, "should be able to obtain executor file info") diff --git a/test/integration/install_scripts_int_test.go b/test/integration/install_scripts_int_test.go index 2b441f5e25..4f4a64c60f 100644 --- a/test/integration/install_scripts_int_test.go +++ b/test/integration/install_scripts_int_test.go @@ -233,8 +233,8 @@ func scriptPath(t *testing.T, targetDir string) string { // assertBinDirContents checks if given files are or are not in the bin directory func (suite *InstallScriptsIntegrationTestSuite) assertBinDirContents(dir string) { binFiles := listFilesOnly(dir) - suite.Contains(binFiles, "state"+osutils.ExeExt) - suite.Contains(binFiles, "state-svc"+osutils.ExeExt) + suite.Contains(binFiles, "state"+osutils.ExeExtension) + suite.Contains(binFiles, "state-svc"+osutils.ExeExtension) } // listFilesOnly is a helper function for assertBinDirContents filtering a directory recursively for base filenames diff --git a/test/integration/performance_expansion_int_test.go b/test/integration/performance_expansion_int_test.go index d1debfa6c3..85acd318af 100644 --- a/test/integration/performance_expansion_int_test.go +++ b/test/integration/performance_expansion_int_test.go @@ -10,8 +10,8 @@ import ( "github.com/ActiveState/cli/internal/config" "github.com/ActiveState/cli/internal/errs" - "github.com/ActiveState/cli/internal/exeutils" "github.com/ActiveState/cli/internal/fileutils" + "github.com/ActiveState/cli/internal/osutils" "github.com/ActiveState/cli/internal/testhelpers/e2e" "github.com/ActiveState/cli/internal/testhelpers/tagsuite" "github.com/ActiveState/cli/pkg/projectfile" @@ -37,7 +37,7 @@ type PerformanceExpansionIntegrationTestSuite struct { func (suite *PerformanceExpansionIntegrationTestSuite) startSvc(ts *e2e.Session) { // Start svc first, as we don't want to measure svc startup time which would only happen the very first invocation - stdout, stderr, err := exeutils.ExecSimple(ts.SvcExe, []string{"start"}, []string{}) + stdout, stderr, err := osutils.ExecSimple(ts.SvcExe, []string{"start"}, []string{}) suite.Require().NoError(err, fmt.Sprintf("Full error:\n%v\nstdout:\n%s\nstderr:\n%s", errs.JoinMessage(err), stdout, stderr)) } diff --git a/test/integration/performance_int_test.go b/test/integration/performance_int_test.go index a3e6c7a11b..95f4bd14c6 100644 --- a/test/integration/performance_int_test.go +++ b/test/integration/performance_int_test.go @@ -14,7 +14,7 @@ import ( "github.com/ActiveState/cli/internal/constants" "github.com/ActiveState/cli/internal/errs" - "github.com/ActiveState/cli/internal/exeutils" + "github.com/ActiveState/cli/internal/osutils" "github.com/ActiveState/termtest" "github.com/stretchr/testify/suite" @@ -37,7 +37,7 @@ func (suite *PerformanceIntegrationTestSuite) TestVersionPerformance() { defer ts.Close() // Start svc first, as we don't want to measure svc startup time which would only happen the very first invocation - stdout, stderr, err := exeutils.ExecSimple(ts.SvcExe, []string{"start"}, []string{}) + stdout, stderr, err := osutils.ExecSimple(ts.SvcExe, []string{"start"}, []string{}) suite.Require().NoError(err, fmt.Sprintf("Full error:\n%v\nstdout:\n%s\nstderr:\n%s", errs.JoinMessage(err), stdout, stderr)) performanceTest([]string{"--version"}, "", StateVersionTotalSamples, StateVersionMaxTime, false, suite.Suite, ts) diff --git a/test/integration/prepare_int_test.go b/test/integration/prepare_int_test.go index 48f165886a..8fc0312c08 100644 --- a/test/integration/prepare_int_test.go +++ b/test/integration/prepare_int_test.go @@ -158,7 +158,7 @@ func (suite *PrepareIntegrationTestSuite) TestResetExecutors() { err = os.Remove(filepath.Join(targetDir, constants.LocalRuntimeEnvironmentDirectory, constants.RuntimeInstallationCompleteMarker)) suite.Assert().NoError(err, "removal of complete marker should have worked") - suite.FileExists(filepath.Join(globalExecDir, "python3"+osutils.ExeExt)) + suite.FileExists(filepath.Join(globalExecDir, "python3"+osutils.ExeExtension)) err = os.RemoveAll(projectExecDir) cp = ts.Spawn("activate") diff --git a/test/integration/remote_installer_int_test.go b/test/integration/remote_installer_int_test.go index 00ba3d163b..2323a10373 100644 --- a/test/integration/remote_installer_int_test.go +++ b/test/integration/remote_installer_int_test.go @@ -8,7 +8,6 @@ import ( anaConst "github.com/ActiveState/cli/internal/analytics/constants" "github.com/ActiveState/cli/internal/constants" "github.com/ActiveState/cli/internal/environment" - "github.com/ActiveState/cli/internal/exeutils" "github.com/ActiveState/cli/internal/fileutils" "github.com/ActiveState/cli/internal/osutils" "github.com/ActiveState/cli/internal/testhelpers/e2e" @@ -46,7 +45,7 @@ func (suite *RemoteInstallIntegrationTestSuite) TestInstall() { suite.setupTest(ts) installPath := filepath.Join(ts.Dirs.Work, "install") - stateExePath := filepath.Join(installPath, "bin", constants.StateCmd+exeutils.Extension) + stateExePath := filepath.Join(installPath, "bin", constants.StateCmd+osutils.ExeExtension) args := []string{} if tt.Version != "" { @@ -109,7 +108,7 @@ func (suite *RemoteInstallIntegrationTestSuite) TestInstall() { func (s *RemoteInstallIntegrationTestSuite) setupTest(ts *e2e.Session) { root := environment.GetRootPathUnsafe() buildDir := fileutils.Join(root, "build") - installerExe := filepath.Join(buildDir, constants.StateRemoteInstallerCmd+osutils.ExeExt) + installerExe := filepath.Join(buildDir, constants.StateRemoteInstallerCmd+osutils.ExeExtension) if !fileutils.FileExists(installerExe) { s.T().Fatal("E2E tests require a state-remote-installer binary. Run `state run build-installer`.") } diff --git a/test/integration/runtime_int_test.go b/test/integration/runtime_int_test.go index afb5b8f179..c6334e0fd3 100644 --- a/test/integration/runtime_int_test.go +++ b/test/integration/runtime_int_test.go @@ -6,7 +6,7 @@ import ( "time" "github.com/ActiveState/cli/internal/constants" - "github.com/ActiveState/cli/internal/exeutils" + "github.com/ActiveState/cli/internal/osutils" "github.com/ActiveState/cli/internal/testhelpers/e2e" "github.com/ActiveState/cli/internal/testhelpers/tagsuite" "github.com/ActiveState/cli/pkg/platform/runtime/setup" @@ -94,7 +94,7 @@ func (suite *RuntimeIntegrationTestSuite) TestInterruptSetup() { cp.Expect("Checked out project", e2e.RuntimeSourcingTimeoutOpt) targetDir := target.ProjectDirToTargetDir(ts.Dirs.Work, ts.Dirs.Cache) - pythonExe := filepath.Join(setup.ExecDir(targetDir), "python3"+exeutils.Extension) + pythonExe := filepath.Join(setup.ExecDir(targetDir), "python3"+osutils.ExeExtension) cp = ts.SpawnCmd(pythonExe, "-c", `print(__import__('sys').version)`) cp.Expect("3.8.8") cp.ExpectExitCode(0) diff --git a/test/integration/update_int_test.go b/test/integration/update_int_test.go index 9f0da8ea5c..423bfe3d0f 100644 --- a/test/integration/update_int_test.go +++ b/test/integration/update_int_test.go @@ -16,10 +16,10 @@ import ( "github.com/ActiveState/cli/internal/config" "github.com/ActiveState/cli/internal/constants" - "github.com/ActiveState/cli/internal/exeutils" "github.com/ActiveState/cli/internal/fileutils" "github.com/ActiveState/cli/internal/httputil" "github.com/ActiveState/cli/internal/installation" + "github.com/ActiveState/cli/internal/osutils" "github.com/ActiveState/cli/internal/rtutils/singlethread" "github.com/ActiveState/cli/internal/testhelpers/e2e" "github.com/ActiveState/cli/internal/testhelpers/tagsuite" @@ -208,8 +208,8 @@ func (suite *UpdateIntegrationTestSuite) TestUpdate_Repair() { suite.Require().True(found, "Expecting to find %q and %q", searchA, searchB) - suite.NoFileExists(filepath.Join(ts.Dirs.Bin, constants.StateCmd+exeutils.Extension), "State Tool executable at install dir should no longer exist") - suite.NoFileExists(filepath.Join(ts.Dirs.Bin, constants.StateSvcCmd+exeutils.Extension), "State Service executable at install dir should no longer exist") + suite.NoFileExists(filepath.Join(ts.Dirs.Bin, constants.StateCmd+osutils.ExeExtension), "State Tool executable at install dir should no longer exist") + suite.NoFileExists(filepath.Join(ts.Dirs.Bin, constants.StateSvcCmd+osutils.ExeExtension), "State Service executable at install dir should no longer exist") } func (suite *UpdateIntegrationTestSuite) TestUpdateChannel() { diff --git a/test/integration/upgen_int_test.go b/test/integration/upgen_int_test.go index a3fba2745c..6f684e49a8 100644 --- a/test/integration/upgen_int_test.go +++ b/test/integration/upgen_int_test.go @@ -57,8 +57,8 @@ func (suite *UpdateGenIntegrationTestSuite) TestUpdateBits() { cp.ExpectExitCode(0) baseDir := filepath.Join(tempPath, constants.ToplevelInstallArchiveDir) - suite.FileExists(filepath.Join(baseDir, installation.BinDirName, constants.StateCmd+osutils.ExeExt)) - suite.FileExists(filepath.Join(baseDir, installation.BinDirName, constants.StateSvcCmd+osutils.ExeExt)) + suite.FileExists(filepath.Join(baseDir, installation.BinDirName, constants.StateCmd+osutils.ExeExtension)) + suite.FileExists(filepath.Join(baseDir, installation.BinDirName, constants.StateSvcCmd+osutils.ExeExtension)) } func TestUpdateGenIntegrationTestSuite(t *testing.T) { diff --git a/test/integration/use_int_test.go b/test/integration/use_int_test.go index d0a315528b..e013191bb3 100644 --- a/test/integration/use_int_test.go +++ b/test/integration/use_int_test.go @@ -42,7 +42,7 @@ func (suite *UseIntegrationTestSuite) TestUse() { cp.ExpectExitCode(0) // Verify runtime works. - pythonExe := filepath.Join(ts.Dirs.DefaultBin, "python3"+osutils.ExeExt) + pythonExe := filepath.Join(ts.Dirs.DefaultBin, "python3"+osutils.ExeExtension) cp = ts.SpawnCmd(pythonExe, "--version") cp.Expect("Python 3") cp.ExpectExitCode(0) @@ -139,7 +139,7 @@ func (suite *UseIntegrationTestSuite) TestReset() { cp.Expect("Switched to project", e2e.RuntimeSourcingTimeoutOpt) cp.ExpectExitCode(0) - python3Exe := filepath.Join(ts.Dirs.DefaultBin, "python3"+osutils.ExeExt) + python3Exe := filepath.Join(ts.Dirs.DefaultBin, "python3"+osutils.ExeExtension) suite.True(fileutils.TargetExists(python3Exe), python3Exe+" not found") cfg, err := config.New()