github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/internal/testhelpers/e2e/env_windows.go (about) 1 //go:build windows 2 // +build windows 3 4 package e2e 5 6 import ( 7 "fmt" 8 "os" 9 10 "github.com/ActiveState/cli/internal/condition" 11 "github.com/ActiveState/cli/internal/constants" 12 ) 13 14 const ( 15 basePath = `C:\Windows\System32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\PowerShell\7\;` 16 systemHomeEnvVarName = "USERPROFILE" 17 ) 18 19 func platformSpecificEnv(dirs *Dirs) []string { 20 return []string{ 21 "SystemDrive=C:", 22 "SystemRoot=C:\\Windows", 23 "PROGRAMFILES=C:\\Program Files", 24 "ProgramFiles(x86)=C:\\Program Files (x86)", 25 "PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC", 26 "HOMEDRIVE=C:", 27 "ALLUSERSPROFILE=C:\\ProgramData", 28 "ProgramData=C:\\ProgramData", 29 "COMSPEC=C:\\Windows\\System32\\cmd.exe", 30 "PROGRAMFILES=C:\\Program Files", 31 "CommonProgramW6432=C:\\Program Files\\Common Files", 32 "WINDIR=C:\\Windows", 33 "PUBLIC=C:\\Users\\Public", 34 "PSModuleAnalysisCachePath=C:\\PSModuleAnalysisCachePath\\ModuleAnalysisCache", 35 fmt.Sprintf("HOMEPATH=%s", dirs.HomeDir), 36 // Other environment variables are commonly set by CI systems, but this one is not. 37 // This is requried for some tests in order to get the correct powershell output. 38 fmt.Sprintf("PSModulePath=%s", os.Getenv("PSModulePath")), 39 fmt.Sprintf("LOCALAPPDATA=%s", dirs.TempDir), 40 fmt.Sprintf("%s=true", constants.DisableActivateEventsEnvVarName), 41 } 42 } 43 44 func platformPath() string { 45 if condition.OnCI() { 46 return `C:\msys64\usr\bin` + string(os.PathListSeparator) + basePath 47 } 48 return basePath 49 }