mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-20 06:54:41 +00:00
Clean up temp files more thoroughly after testing. (#7815)
Our test cases spew a lot of files and directories around $TMPDIR. Make more thorough use of the testing package's TempDir methods to ensure these are cleaned up. In a few cases, this required plumbing test contexts through existing helper code. In a couple places an explicit path was required, to work around cases where we do global setup during a TestMain function. Those cases probably deserve more thorough cleansing (preferably with fire), but for now I have just worked around it to keep focused on the cleanup.
This commit is contained in:
@@ -22,7 +22,7 @@ func TestHTTPSimple(t *testing.T) {
|
||||
|
||||
// Start a tendermint node (and kvstore) in the background to test against
|
||||
app := kvstore.NewApplication()
|
||||
conf, err := rpctest.CreateConfig("ExampleHTTP_simple")
|
||||
conf, err := rpctest.CreateConfig(t, "ExampleHTTP_simple")
|
||||
require.NoError(t, err)
|
||||
|
||||
_, closer, err := rpctest.StartTendermint(ctx, conf, app, rpctest.SuppressStdout)
|
||||
@@ -72,7 +72,7 @@ func TestHTTPBatching(t *testing.T) {
|
||||
|
||||
// Start a tendermint node (and kvstore) in the background to test against
|
||||
app := kvstore.NewApplication()
|
||||
conf, err := rpctest.CreateConfig("ExampleHTTP_batching")
|
||||
conf, err := rpctest.CreateConfig(t, "ExampleHTTP_batching")
|
||||
require.NoError(t, err)
|
||||
|
||||
_, closer, err := rpctest.StartTendermint(ctx, conf, app, rpctest.SuppressStdout)
|
||||
|
||||
@@ -2,7 +2,6 @@ package client_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
@@ -20,13 +19,11 @@ func NodeSuite(t *testing.T, logger log.Logger) (service.Service, *config.Config
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
|
||||
conf, err := rpctest.CreateConfig(t.Name())
|
||||
conf, err := rpctest.CreateConfig(t, t.Name())
|
||||
require.NoError(t, err)
|
||||
|
||||
// start a tendermint node in the background to test against
|
||||
dir, err := os.MkdirTemp("/tmp", fmt.Sprint("rpc-client-test-", t.Name()))
|
||||
require.NoError(t, err)
|
||||
|
||||
dir := t.TempDir()
|
||||
app := kvstore.NewPersistentKVStoreApplication(logger, dir)
|
||||
|
||||
node, closer, err := rpctest.StartTendermint(ctx, conf, app, rpctest.SuppressStdout)
|
||||
|
||||
+3
-2
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
abciclient "github.com/tendermint/tendermint/abci/client"
|
||||
@@ -57,8 +58,8 @@ func makeAddrs() (p2pAddr, rpcAddr string) {
|
||||
return fmt.Sprintf(addrTemplate, randPort()), fmt.Sprintf(addrTemplate, randPort())
|
||||
}
|
||||
|
||||
func CreateConfig(testName string) (*config.Config, error) {
|
||||
c, err := config.ResetTestRoot(testName)
|
||||
func CreateConfig(t *testing.T, testName string) (*config.Config, error) {
|
||||
c, err := config.ResetTestRoot(t.TempDir(), testName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user