Skip to content
This repository was archived by the owner on Sep 9, 2020. It is now read-only.

gps/solver - Remove SolveParameters.Trace #526

Merged
merged 1 commit into from
May 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion cmd/dep/ensure.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ func (cmd *ensureCommand) Run(ctx *dep.Ctx, args []string) error {

params := p.MakeParams()
if *verbose {
params.Trace = true
params.TraceLogger = log.New(os.Stderr, "", 0)
}
params.RootPackageTree, err = pkgtree.ListPackages(p.AbsRoot, string(p.ImportRoot))
Expand Down
1 change: 0 additions & 1 deletion cmd/dep/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ func (cmd *initCommand) Run(ctx *dep.Ctx, args []string) error {
}

if *verbose {
params.Trace = true
params.TraceLogger = log.New(os.Stderr, "", 0)
}
s, err := gps.Prepare(params, sm)
Expand Down
1 change: 0 additions & 1 deletion cmd/dep/prune.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ func (cmd *pruneCommand) Run(ctx *dep.Ctx, args []string) error {
params.RootPackageTree = ptree

if *verbose {
params.Trace = true
params.TraceLogger = log.New(os.Stderr, "", 0)
}

Expand Down
1 change: 0 additions & 1 deletion cmd/dep/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ func (cmd *removeCommand) Run(ctx *dep.Ctx, args []string) error {
params.RootPackageTree = pkgT

if *verbose {
params.Trace = true
params.TraceLogger = log.New(os.Stderr, "", 0)
}
s, err := gps.Prepare(params, sm)
Expand Down
1 change: 0 additions & 1 deletion cmd/dep/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@ func runStatusAll(out outputter, p *dep.Project, sm *gps.SourceMgr) error {
// Locks aren't a part of the input hash check, so we can omit it.
}
if *verbose {
params.Trace = true
params.TraceLogger = log.New(os.Stderr, "", 0)
}

Expand Down
1 change: 0 additions & 1 deletion gps/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ func main() {
// Set up params, including tracing
params := gps.SolveParameters{
RootDir: root,
Trace: true,
TraceLogger: log.New(os.Stdout, "", 0),
ProjectAnalyzer: NaiveAnalyzer{},
}
Expand Down
8 changes: 0 additions & 8 deletions gps/solve_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ func fixSolve(params SolveParameters, sm SourceManager, t *testing.T) (Solution,
// Trace unconditionally; by passing the trace through t.Log(), the testing
// system will decide whether or not to actually show the output (based on
// -v, or selectively on test failure).
params.Trace = true
params.TraceLogger = log.New(testlogger{T: t}, "", 0)

s, err := Prepare(params, sm)
Expand Down Expand Up @@ -374,13 +373,6 @@ func TestBadSolveOpts(t *testing.T) {
},
},
}
params.Trace = true
_, err = Prepare(params, sm)
if err == nil {
t.Errorf("Should have errored on trace with no logger")
} else if !strings.Contains(err.Error(), "no logger provided") {
t.Error("Prepare should have given error on missing trace logger, but gave:", err)
}
params.TraceLogger = log.New(ioutil.Discard, "", 0)

params.Manifest = simpleRootManifest{
Expand Down
14 changes: 4 additions & 10 deletions gps/solver.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,9 @@ type SolveParameters struct {
// typical case.
Downgrade bool

// Trace controls whether the solver will generate informative trace output
// as it moves through the solving process.
Trace bool

// TraceLogger is the logger to use for generating trace output. If Trace is
// true but no logger is provided, solving will result in an error.
// TraceLogger is the logger to use for generating trace output. If set, the
// solver will generate informative trace output as it moves through the
// solving process.
TraceLogger *log.Logger
}

Expand All @@ -122,7 +119,7 @@ type solver struct {
// starts moving forward again.
attempts int

// Logger used exclusively for trace output, if the trace option is set.
// Logger used exclusively for trace output, or nil to suppress.
tl *log.Logger

// A bridge to the standard SourceManager. The adapter does some local
Expand Down Expand Up @@ -281,9 +278,6 @@ func Prepare(params SolveParameters, sm SourceManager) (Solver, error) {
if sm == nil {
return nil, badOptsFailure("must provide non-nil SourceManager")
}
if params.Trace && params.TraceLogger == nil {
return nil, badOptsFailure("trace requested, but no logger provided")
}

rd, err := params.toRootdata()
if err != nil {
Expand Down