@@ -5,11 +5,13 @@ import (
55 "context"
66 "log/slog"
77 "os"
8+ "path/filepath"
89 "testing"
910 "time"
1011
1112 "github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/integration_test/shared"
1213 "github.com/ethereum-optimism/optimism/op-service/testlog"
14+ "github.com/ethereum-optimism/optimism/op-service/testutils"
1315 "github.com/ethereum-optimism/optimism/op-service/testutils/devnet"
1416 "github.com/stretchr/testify/require"
1517)
@@ -37,7 +39,7 @@ func WithPrivateKey(pkHex string) CLITestRunnerOption {
3739}
3840
3941func NewCLITestRunner (t * testing.T , opts ... CLITestRunnerOption ) * CLITestRunner {
40- workDir := t . TempDir ( )
42+ workDir := testutils . IsolatedTestDirWithAutoCleanup ( t )
4143 return & CLITestRunner {
4244 workDir : workDir ,
4345 }
@@ -46,7 +48,7 @@ func NewCLITestRunner(t *testing.T, opts ...CLITestRunnerOption) *CLITestRunner
4648// NewCLITestRunnerWithNetwork creates a new CLI test runner with default network setup.
4749// Defaults can be overridden using functional options.
4850func NewCLITestRunnerWithNetwork (t * testing.T , opts ... CLITestRunnerOption ) * CLITestRunner {
49- workDir := t . TempDir ( )
51+ workDir := testutils . IsolatedTestDirWithAutoCleanup ( t )
5052
5153 // Set up defaults
5254 lgr := testlog .Logger (t , slog .LevelDebug )
@@ -110,11 +112,13 @@ func (r *CLITestRunner) Run(ctx context.Context, args []string, env map[string]s
110112 stdout := newCaptureOutputWriter ()
111113 stderr := newCaptureOutputWriter ()
112114
113- // Add "op-deployer" as the first argument if not already present
114- fullArgs := args
115- if len (args ) == 0 || args [0 ] != "op-deployer" {
116- fullArgs = append ([]string {"op-deployer" }, args ... )
115+ // Ensure command format is: op-deployer --cache-dir <path> <subcommand and flags>
116+ cacheDir := filepath .Join (r .workDir , ".cache" )
117+ commandArgs := args
118+ if len (args ) > 0 && args [0 ] == "op-deployer" {
119+ commandArgs = args [1 :] // Skip "op-deployer" if already present
117120 }
121+ fullArgs := append ([]string {"op-deployer" , "--cache-dir" , cacheDir }, commandArgs ... )
118122
119123 // Run the CLI command using the testable interface
120124 err = RunCLI (ctx , stdout , stderr , fullArgs )
0 commit comments