mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-05 03:17:50 +08:00
Replace "PATH" literals with a constant
This commit is contained in:
parent
19f315e28a
commit
b2c7746bf6
|
@ -77,8 +77,8 @@ func TestMakeHasCommand(t *testing.T) {
|
|||
// Set up environment.
|
||||
testDir, cleanup := util.InTestDir()
|
||||
defer cleanup()
|
||||
oldPath := os.Getenv("PATH")
|
||||
defer os.Setenv("PATH", oldPath)
|
||||
oldPath := os.Getenv(util.EnvPATH)
|
||||
defer os.Setenv(util.EnvPATH, oldPath)
|
||||
if runtime.GOOS == "windows" {
|
||||
oldPathExt := os.Getenv("PATHEXT")
|
||||
defer os.Setenv("PATHEXT", oldPathExt)
|
||||
|
@ -87,7 +87,7 @@ func TestMakeHasCommand(t *testing.T) {
|
|||
}
|
||||
|
||||
// Set up a directory in PATH.
|
||||
os.Setenv("PATH", filepath.Join(testDir, "bin"))
|
||||
os.Setenv(util.EnvPATH, filepath.Join(testDir, "bin"))
|
||||
mustMkdirAll("bin")
|
||||
mustMkExecutable("bin/external")
|
||||
mustMkExecutable("bin/@external")
|
||||
|
|
|
@ -5,10 +5,11 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/elves/elvish/pkg/eval/vals"
|
||||
"github.com/elves/elvish/pkg/util"
|
||||
)
|
||||
|
||||
func TestBuiltinFnEnv(t *testing.T) {
|
||||
oldpath := os.Getenv("PATH")
|
||||
oldpath := os.Getenv(util.EnvPATH)
|
||||
listSep := string(os.PathListSeparator)
|
||||
Test(t,
|
||||
That(`get-env var`).ThrowsCause(errNonExistentEnvVar),
|
||||
|
@ -29,5 +30,5 @@ func TestBuiltinFnEnv(t *testing.T) {
|
|||
That(`paths = [/test-path2 $@paths]`),
|
||||
That(`get-env PATH`).Puts("/test-path2"+listSep+"/test-path"),
|
||||
)
|
||||
os.Setenv("PATH", oldpath)
|
||||
os.Setenv(util.EnvPATH, oldpath)
|
||||
}
|
||||
|
|
|
@ -248,7 +248,7 @@ func (ev *Evaler) SetLibDir(libDir string) {
|
|||
}
|
||||
|
||||
func searchPaths() []string {
|
||||
return strings.Split(os.Getenv("PATH"), ":")
|
||||
return strings.Split(os.Getenv(util.EnvPATH), ":")
|
||||
}
|
||||
|
||||
// growPorts makes the size of ec.ports at least n, adding nil's if necessary.
|
||||
|
|
|
@ -4,6 +4,7 @@ package util
|
|||
// Environment variables with special significance to Elvish.
|
||||
const (
|
||||
EnvHOME = "HOME"
|
||||
EnvPATH = "PATH"
|
||||
EnvPWD = "PWD"
|
||||
EnvSHLVL = "SHLVL"
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue
Block a user