mirror of
https://github.com/kopia/kopia.git
synced 2026-03-17 05:38:34 -04:00
This helps recycle buffers more efficiently during snapshots. Also, improved memory tracking, enabled profiling flags and added pprof by default.
45 lines
1.0 KiB
Go
45 lines
1.0 KiB
Go
package testenv
|
|
|
|
import (
|
|
"io"
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/kopia/kopia/cli"
|
|
"github.com/kopia/kopia/internal/testlogging"
|
|
)
|
|
|
|
// CLIInProcRunner is a CLIRunner that invokes provided commands in the current process.
|
|
type CLIInProcRunner struct {
|
|
RepoPassword string
|
|
}
|
|
|
|
// Start implements CLIRunner.
|
|
func (e *CLIInProcRunner) Start(t *testing.T, args []string) (stdout, stderr io.Reader, wait func() error, kill func()) {
|
|
t.Helper()
|
|
|
|
ctx := testlogging.Context(t)
|
|
|
|
a := cli.NewApp()
|
|
a.AdvancedCommands = "enabled"
|
|
|
|
return a.RunSubcommand(ctx, append([]string{
|
|
"--password", e.RepoPassword,
|
|
}, args...))
|
|
}
|
|
|
|
// NewInProcRunner returns a runner that executes CLI subcommands in the current process using cli.RunSubcommand().
|
|
func NewInProcRunner(t *testing.T) *CLIInProcRunner {
|
|
t.Helper()
|
|
|
|
if os.Getenv("KOPIA_EXE") != "" && os.Getenv("KOPIA_RUN_ALL_INTEGRATION_TESTS") == "" {
|
|
t.Skip("not running test since it's also included in the unit tests")
|
|
}
|
|
|
|
return &CLIInProcRunner{
|
|
RepoPassword: TestRepoPassword,
|
|
}
|
|
}
|
|
|
|
var _ CLIRunner = (*CLIInProcRunner)(nil)
|