2018-03-03 12:54:20 +08:00
|
|
|
package eval
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/elves/elvish/eval/vals"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestBuiltinFnEnv(t *testing.T) {
|
|
|
|
oldpath := os.Getenv("PATH")
|
|
|
|
listSep := string(os.PathListSeparator)
|
2018-05-22 08:08:11 +08:00
|
|
|
Test(t,
|
2018-03-03 14:08:09 +08:00
|
|
|
That(`get-env var`).ErrorsWith(errNonExistentEnvVar),
|
|
|
|
That(`set-env var test1`),
|
|
|
|
That(`get-env var`).Puts("test1"),
|
|
|
|
That(`put $E:var`).Puts("test1"),
|
|
|
|
That(`set-env var test2`),
|
|
|
|
That(`get-env var`).Puts("test2"),
|
|
|
|
That(`put $E:var`).Puts("test2"),
|
2018-03-03 12:54:20 +08:00
|
|
|
|
2018-03-03 14:08:09 +08:00
|
|
|
That(`set-env PATH /test-path`),
|
|
|
|
That(`put $paths`).Puts(vals.MakeList("/test-path")),
|
|
|
|
That(`paths = [/test-path2 $@paths]`),
|
2018-05-22 08:08:11 +08:00
|
|
|
That(`get-env PATH`).Puts("/test-path2"+listSep+"/test-path"),
|
|
|
|
)
|
2018-03-03 12:54:20 +08:00
|
|
|
os.Setenv("PATH", oldpath)
|
|
|
|
}
|