mirror of
https://github.com/kopia/kopia.git
synced 2026-04-04 14:23:21 -04:00
Refactored most of the CLI tests to run in-process as opposed to using sub-processes (#1059)
* cli: fixed remaining testability indirections for output and logging * cli: added cli.RunSubcommand() which is used in testing to execute a subcommand in the same process * tests: refactored most e2e tests to invoke kopia subcommands in-process * Makefile: enable code coverage for cli/ and internal/ * testing: pass 'testing' tag to unit tests which uses much faster (insecure) password hashing scheme * Makefile: push coverage from PRs again * tests: disable buffer management to reduce memory usage on ARM * cli: fixed misaligned atomic field on ARMHF also temporarily fixed statup-time benign race condition when setting default on the timeZone variable, which is the last global variable.
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
@@ -18,6 +17,8 @@ type commandDiff struct {
|
||||
diffSecondObjectPath string
|
||||
diffCompareFiles bool
|
||||
diffCommandCommand string
|
||||
|
||||
out textOutput
|
||||
}
|
||||
|
||||
func (c *commandDiff) setup(svc appServices, parent commandParent) {
|
||||
@@ -27,6 +28,8 @@ func (c *commandDiff) setup(svc appServices, parent commandParent) {
|
||||
cmd.Flag("files", "Compare files by launching diff command for all pairs of (old,new)").Short('f').BoolVar(&c.diffCompareFiles)
|
||||
cmd.Flag("diff-command", "Displays differences between two repository objects (files or directories)").Default(defaultDiffCommand()).Envar("KOPIA_DIFF").StringVar(&c.diffCommandCommand)
|
||||
cmd.Action(svc.repositoryReaderAction(c.run))
|
||||
|
||||
c.out.setup(svc)
|
||||
}
|
||||
|
||||
func (c *commandDiff) run(ctx context.Context, rep repo.Repository) error {
|
||||
@@ -47,7 +50,7 @@ func (c *commandDiff) run(ctx context.Context, rep repo.Repository) error {
|
||||
return errors.New("arguments do diff must both be directories or both non-directories")
|
||||
}
|
||||
|
||||
d, err := diff.NewComparer(os.Stdout)
|
||||
d, err := diff.NewComparer(c.out.stdout())
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error creating comparer")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user