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

Commit

Permalink
dep: Update scads of tests
Browse files Browse the repository at this point in the history
Tests are now almost completely working, after updating all the outputs
to the new lock format. There is also an assortment of other fixes in
here, mostly related to fixing nil pointer panics, that were uncovered
by fixing up these tests.
  • Loading branch information
sdboyer committed Jul 3, 2018
1 parent 6b47f58 commit b17ee5f
Show file tree
Hide file tree
Showing 79 changed files with 698 additions and 521 deletions.
2 changes: 1 addition & 1 deletion Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 34 additions & 32 deletions cmd/dep/ensure.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ func (cmd *ensureCommand) runDefault(ctx *dep.Ctx, args []string, p *dep.Project
return err
}

var solve bool
lock := p.ChangedLock
if lock != nil {
lsat := verify.LockSatisfiesInputs(p.Lock, p.Manifest, params.RootPackageTree)
Expand All @@ -298,21 +299,26 @@ func (cmd *ensureCommand) runDefault(ctx *dep.Ctx, args []string, p *dep.Project
}
ctx.Out.Println()
}

solver, err := gps.Prepare(params, sm)
if err != nil {
return errors.Wrap(err, "prepare solver")
}

solution, err := solver.Solve(context.TODO())
if err != nil {
return handleAllTheFailuresOfTheWorld(err)
}
lock = dep.LockFromSolution(solution, p.Manifest.PruneOptions)
solve = true
} else if cmd.noVendor {
// The user said not to touch vendor/, so definitely nothing to do.
return nil
}
} else {
solve = true
}

if solve {
solver, err := gps.Prepare(params, sm)
if err != nil {
return errors.Wrap(err, "prepare solver")
}

solution, err := solver.Solve(context.TODO())
if err != nil {
return handleAllTheFailuresOfTheWorld(err)
}
lock = dep.LockFromSolution(solution, p.Manifest.PruneOptions)
}

dw, err := dep.NewDeltaWriter(p.Lock, lock, <-statchan, p.Manifest.PruneOptions, filepath.Join(p.AbsRoot, "vendor"))
Expand Down Expand Up @@ -414,33 +420,29 @@ func (cmd *ensureCommand) runAdd(ctx *dep.Ctx, args []string, p *dep.Project, sm
return err
}

// We'll need to discard this prepared solver as later work changes params,
// but solver preparation is cheap and worth doing up front in order to
// perform the fastpath check of hash comparison.
solver, err := gps.Prepare(params, sm)
if err != nil {
return errors.Wrap(err, "fastpath solver prepare")
}

rm, _ := params.RootPackageTree.ToReachMap(true, true, false, p.Manifest.IgnoredPackages())

// Compile unique sets of 1) all external packages imported or required, and
// 2) the project roots under which they fall.
exmap := make(map[string]bool)
exrmap := make(map[gps.ProjectRoot]bool)

for _, ex := range append(rm.FlattenFn(paths.IsStandardImportPath), p.Manifest.Required...) {
exmap[ex] = true
root, err := sm.DeduceProjectRoot(ex)
if err != nil {
// This should be very uncommon to hit, as it entails that we
// couldn't deduce the root for an import, but that some previous
// solve run WAS able to deduce the root. It's most likely to occur
// if the user has e.g. not connected to their organization's VPN,
// and thus cannot access an internal go-get metadata service.
return errors.Wrapf(err, "could not deduce project root for %s", ex)
var exlist []string
if p.ChangedLock != nil {
for _, imp := range p.ChangedLock.InputImports() {
exmap[imp] = true
}
exrmap[root] = true
} else {
rm, _ := p.RoockPackageTree.ToReachMap(true, true, false, p.Manifest.IgnoredPackages())
for _, imp := range rm.FlattenFn(paths.IsStandardImportPath) {
exmap[imp] = true
}
for imp := range p.Manifest.RequiredPackages() {
exmap[imp] = true
}
}

exrmap, err := p.GetDirectDependencyNames()
if err != nil {
return err
}

// Note: these flags are only partially used by the latter parts of the
Expand Down
2 changes: 0 additions & 2 deletions cmd/dep/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,6 @@ func (cmd *initCommand) Run(ctx *dep.Ctx, args []string) error {
return errors.Wrap(err, "init failed: unable to recalculate the lock digest")
}

//p.Lock.SolveMeta.InputsDigest = s.HashInputs()

// Pass timestamp (yyyyMMddHHmmss format) as suffix to backup name.
vendorbak, err := dep.BackupVendor(filepath.Join(root, "vendor"), time.Now().Format("20060102150405"))
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions cmd/dep/root_analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (

"github.com/golang/dep"
"github.com/golang/dep/gps"
"github.com/golang/dep/gps/verify"
fb "github.com/golang/dep/internal/feedback"
"github.com/golang/dep/internal/importers"
"golang.org/x/sync/errgroup"
Expand Down Expand Up @@ -168,7 +167,7 @@ func (a *rootAnalyzer) DeriveManifestAndLock(dir string, pr gps.ProjectRoot) (gp
func (a *rootAnalyzer) FinalizeRootManifestAndLock(m *dep.Manifest, l *dep.Lock, ol dep.Lock) {
// Iterate through the new projects in solved lock and add them to manifest
// if they are direct deps and log feedback for all the new projects.
diff := verify.DiffLocks(&ol, l)
diff := fb.DiffLocks(&ol, l)
bi := fb.NewBrokenImportFeedback(diff)
bi.LogFeedback(a.ctx.Err)
for _, y := range l.Projects() {
Expand Down
4 changes: 4 additions & 0 deletions cmd/dep/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,10 @@ func (cmd *statusCommand) runStatusAll(ctx *dep.Ctx, out outputter, p *dep.Proje
sort.Slice(slp, func(i, j int) bool {
return slp[i].Ident().Less(slp[j].Ident())
})
slcp := p.ChangedLock.Projects()
sort.Slice(slcp, func(i, j int) bool {
return slcp[i].Ident().Less(slcp[j].Ident())
})

lsat := verify.LockSatisfiesInputs(p.Lock, p.Manifest, params.RootPackageTree)
if lsat.Passed() {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 13 additions & 3 deletions cmd/dep/testdata/harness_tests/ensure/add/desync/final/Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
Warning: Gopkg.lock is out of sync with Gopkg.toml or the project's imports.
Fetching sources...

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit b17ee5f

Please sign in to comment.