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:
Jarek Kowalski
2021-05-11 22:26:28 -07:00
committed by GitHub
parent 41931f21ce
commit fcd507a56d
54 changed files with 565 additions and 235 deletions

View File

@@ -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")
}