From 09ec2476467920476c4a77f5e0828540bed55bc5 Mon Sep 17 00:00:00 2001 From: Tanya Bouman Date: Mon, 28 Jun 2021 10:38:15 -0400 Subject: [PATCH] cmd/tendermint/commands: replace $HOME/.some/test/dir with t.TempDir (#6623) * cmd/tendermint/commands: replace $HOME/.some/test/dir with t.TempDir * update changelog Co-authored-by: Marko --- CHANGELOG_PENDING.md | 1 + cmd/tendermint/commands/root_test.go | 11 +++++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CHANGELOG_PENDING.md b/CHANGELOG_PENDING.md index 249cf2bba..76fc81819 100644 --- a/CHANGELOG_PENDING.md +++ b/CHANGELOG_PENDING.md @@ -131,6 +131,7 @@ Friendly reminder: We have a [bug bounty program](https://hackerone.com/tendermi - [statesync] \#6587 Increase chunk priority and re-request chunks that don't arrive (@cmwaters) - [state/privval] \#6578 No GetPubKey retry beyond the proposal/voting window (@JayT106) - [rpc] \#6615 Add TotalGasUsed to block_results response (@crypto-facs) +- [cmd/tendermint/commands] \#6623 replace `$HOME/.some/test/dir` with `t.TempDir` (@tanyabouman) ### BUG FIXES diff --git a/cmd/tendermint/commands/root_test.go b/cmd/tendermint/commands/root_test.go index 385da7051..cd4bc9f5f 100644 --- a/cmd/tendermint/commands/root_test.go +++ b/cmd/tendermint/commands/root_test.go @@ -18,10 +18,6 @@ import ( tmos "github.com/tendermint/tendermint/libs/os" ) -var ( - defaultRoot = os.ExpandEnv("$HOME/.some/test/dir") -) - // clearConfig clears env vars, the given root dir, and resets viper. func clearConfig(dir string) { if err := os.Unsetenv("TMHOME"); err != nil { @@ -52,10 +48,10 @@ func testRootCmd() *cobra.Command { } func testSetup(rootDir string, args []string, env map[string]string) error { - clearConfig(defaultRoot) + clearConfig(rootDir) rootCmd := testRootCmd() - cmd := cli.PrepareBaseCmd(rootCmd, "TM", defaultRoot) + cmd := cli.PrepareBaseCmd(rootCmd, "TM", rootDir) // run with the args and env args = append([]string{rootCmd.Use}, args...) @@ -63,6 +59,7 @@ func testSetup(rootDir string, args []string, env map[string]string) error { } func TestRootHome(t *testing.T) { + defaultRoot := t.TempDir() newRoot := filepath.Join(defaultRoot, "something-else") cases := []struct { args []string @@ -105,6 +102,7 @@ func TestRootFlagsEnv(t *testing.T) { {nil, map[string]string{"TM_LOG_LEVEL": "debug"}, "debug"}, // right env } + defaultRoot := t.TempDir() for i, tc := range cases { idxString := strconv.Itoa(i) @@ -135,6 +133,7 @@ func TestRootConfig(t *testing.T) { } for i, tc := range cases { + defaultRoot := t.TempDir() idxString := strconv.Itoa(i) clearConfig(defaultRoot)