Improve backup and restore env function + fix makefile with quotes + remove the zdotdir created file

This commit is contained in:
David Dworken 2022-11-13 16:53:37 -08:00
parent 6017eac4a3
commit 53a417296e
No known key found for this signature in database
3 changed files with 7 additions and 2 deletions

View File

@ -6,7 +6,7 @@ test:
HISHTORY_TEST=1 HISHTORY_SKIP_INIT_IMPORT=1 go test -p 1 -timeout 30m ./... HISHTORY_TEST=1 HISHTORY_SKIP_INIT_IMPORT=1 go test -p 1 -timeout 30m ./...
ftest: ftest:
HISHTORY_TEST=1 HISHTORY_SKIP_INIT_IMPORT=1 go test -v -p 1 -run $(FILTER) ./... HISHTORY_TEST=1 HISHTORY_SKIP_INIT_IMPORT=1 go test -v -p 1 -run "$(FILTER)" ./...
acttest: acttest:
act push -j test -e .github/push_event.json --reuse --container-architecture linux/amd64 act push -j test -e .github/push_event.json --reuse --container-architecture linux/amd64

View File

@ -2159,6 +2159,7 @@ func TestZDotDir(t *testing.T) {
} }
os.Setenv("ZDOTDIR", path.Join(homedir, data.HISHTORY_PATH)) os.Setenv("ZDOTDIR", path.Join(homedir, data.HISHTORY_PATH))
installHishtory(t, tester, "") installHishtory(t, tester, "")
defer os.Remove(path.Join(homedir, data.HISHTORY_PATH, ".zshrc"))
// Run a command and check that it was recorded // Run a command and check that it was recorded
tester.RunInteractiveShell(t, `echo foo`) tester.RunInteractiveShell(t, `echo foo`)

View File

@ -150,7 +150,11 @@ func copy(src, dst string) error {
func BackupAndRestoreEnv(k string) func() { func BackupAndRestoreEnv(k string) func() {
origValue := os.Getenv(k) origValue := os.Getenv(k)
return func() { return func() {
os.Setenv(k, origValue) if origValue == "" {
os.Unsetenv(k)
} else {
os.Setenv(k, origValue)
}
} }
} }