repo_id
stringclasses
927 values
file_path
stringlengths
99
214
content
stringlengths
2
4.15M
gps
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/solve_bimodal_test.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package gps import ( "fmt" "path/filepath" "strings" "github.com/golang/dep/gps/pkgtree" ) // dsp - "depspec with packages" // // Wraps a set of tpkgs onto a depspec, and returns it. func dsp(ds depspec, pkgs ...tpkg) depspec { ds.pkgs = pkgs return ds } // pkg makes a tpkg appropriate for use in bimodal testing func pkg(path string, imports ...string) tpkg { return tpkg{ path: path, imports: imports, } } func init() { for k, fix := range bimodalFixtures { // Assign the name into the fixture itself fix.n = k bimodalFixtures[k] = fix } } // Fixtures that rely on simulated bimodal (project and package-level) // analysis for correct operation. The name given in the map gets assigned into // the fixture itself in init(). var bimodalFixtures = map[string]bimodalFixture{ // Simple case, ensures that we do the very basics of picking up and // including a single, simple import that is not expressed as a constraint "simple bm-add": { ds: []depspec{ dsp(mkDepspec("root 0.0.0"), pkg("root", "a")), dsp(mkDepspec("a 1.0.0"), pkg("a")), }, r: mksolution( "a 1.0.0", ), }, // Ensure it works when the import jump is not from the package with the // same path as root, but from a subpkg "subpkg bm-add": { ds: []depspec{ dsp(mkDepspec("root 0.0.0"), pkg("root", "root/foo"), pkg("root/foo", "a"), ), dsp(mkDepspec("a 1.0.0"), pkg("a"), ), }, r: mksolution( "a 1.0.0", ), }, // The same, but with a jump through two subpkgs "double-subpkg bm-add": { ds: []depspec{ dsp(mkDepspec("root 0.0.0"), pkg("root", "root/foo"), pkg("root/foo", "root/bar"), pkg("root/bar", "a"), ), dsp(mkDepspec("a 1.0.0"), pkg("a"), ), }, r: mksolution( "a 1.0.0", ), }, // Same again, but now nest the subpkgs "double nested subpkg bm-add": { ds: []depspec{ dsp(mkDepspec("root 0.0.0"), pkg("root", "root/foo"), pkg("root/foo", "root/foo/bar"), pkg("root/foo/bar", "a"), ), dsp(mkDepspec("a 1.0.0"), pkg("a"), ), }, r: mksolution( "a 1.0.0", ), }, // Importing package from project with no root package "bm-add on project with no pkg in root dir": { ds: []depspec{ dsp(mkDepspec("root 0.0.0"), pkg("root", "a/foo")), dsp(mkDepspec("a 1.0.0"), pkg("a/foo")), }, r: mksolution( mklp("a 1.0.0", "foo"), ), }, // Import jump is in a dep, and points to a transitive dep "transitive bm-add": { ds: []depspec{ dsp(mkDepspec("root 0.0.0"), pkg("root", "root/foo"), pkg("root/foo", "a"), ), dsp(mkDepspec("a 1.0.0"), pkg("a", "b"), ), dsp(mkDepspec("b 1.0.0"), pkg("b"), ), }, r: mksolution( "a 1.0.0", "b 1.0.0", ), }, // Constraints apply only if the project that declares them has a // reachable import "constraints activated by import": { ds: []depspec{ dsp(mkDepspec("root 0.0.0", "b 1.0.0"), pkg("root", "root/foo"), pkg("root/foo", "a"), ), dsp(mkDepspec("a 1.0.0"), pkg("a", "b"), ), dsp(mkDepspec("b 1.0.0"), pkg("b"), ), dsp(mkDepspec("b 1.1.0"), pkg("b"), ), }, r: mksolution( "a 1.0.0", "b 1.1.0", ), }, // Constraints apply only if the project that declares them has a // reachable import - non-root "constraints activated by import, transitive": { ds: []depspec{ dsp(mkDepspec("root 0.0.0"), pkg("root", "root/foo", "b"), pkg("root/foo", "a"), ), dsp(mkDepspec("a 1.0.0", "b 1.0.0"), pkg("a"), ), dsp(mkDepspec("b 1.0.0"), pkg("b"), ), dsp(mkDepspec("b 1.1.0"), pkg("b"), ), }, r: mksolution( "a 1.0.0", "b 1.1.0", ), }, // Import jump is in a dep, and points to a transitive dep - but only in not // the first version we try "transitive bm-add on older version": { ds: []depspec{ dsp(mkDepspec("root 0.0.0", "a ~1.0.0"), pkg("root", "root/foo"), pkg("root/foo", "a"), ), dsp(mkDepspec("a 1.0.0"), pkg("a", "b"), ), dsp(mkDepspec("a 1.1.0"), pkg("a"), ), dsp(mkDepspec("b 1.0.0"), pkg("b"), ), }, r: mksolution( "a 1.0.0", "b 1.0.0", ), }, // Import jump is in a dep, and points to a transitive dep - but will only // get there via backtracking "backtrack to dep on bm-add": { ds: []depspec{ dsp(mkDepspec("root 0.0.0"), pkg("root", "root/foo"), pkg("root/foo", "a", "b"), ), dsp(mkDepspec("a 1.0.0"), pkg("a", "c"), ), dsp(mkDepspec("a 1.1.0"), pkg("a"), ), // Include two versions of b, otherwise it'll be selected first dsp(mkDepspec("b 0.9.0"), pkg("b", "c"), ), dsp(mkDepspec("b 1.0.0"), pkg("b", "c"), ), dsp(mkDepspec("c 1.0.0", "a 1.0.0"), pkg("c", "a"), ), }, r: mksolution( "a 1.0.0", "b 1.0.0", "c 1.0.0", ), }, "backjump through pkg-only selection": { ds: []depspec{ dsp(mkDepspec("root 0.0.0"), pkg("root", "root/foo"), pkg("root/foo", "a", "b"), ), dsp(mkDepspec("a 1.0.0"), pkg("a", "c"), ), // Include two versions of b to ensure that a is visited first dsp(mkDepspec("b 0.9.0", "d ^1.0.0"), pkg("b", "c/other", "d"), ), dsp(mkDepspec("b 1.0.0", "d ^1.2.0"), pkg("b", "c/other", "d"), ), // Three versions of c so it's last dsp(mkDepspec("c 1.0.0", "d ^1.0.0"), pkg("c", "d"), pkg("c/other"), ), dsp(mkDepspec("d 1.0.0"), pkg("d"), ), dsp(mkDepspec("d 1.1.0"), pkg("d"), ), }, r: mksolution( "a 1.0.0", "b 0.9.0", mklp("c 1.0.0", ".", "other"), "d 1.1.0", ), }, // Import jump is in a dep subpkg, and points to a transitive dep "transitive subpkg bm-add": { ds: []depspec{ dsp(mkDepspec("root 0.0.0"), pkg("root", "root/foo"), pkg("root/foo", "a"), ), dsp(mkDepspec("a 1.0.0"), pkg("a", "a/bar"), pkg("a/bar", "b"), ), dsp(mkDepspec("b 1.0.0"), pkg("b"), ), }, r: mksolution( mklp("a 1.0.0", ".", "bar"), "b 1.0.0", ), }, // Import jump is in a dep subpkg, pointing to a transitive dep, but only in // not the first version we try "transitive subpkg bm-add on older version": { ds: []depspec{ dsp(mkDepspec("root 0.0.0", "a ~1.0.0"), pkg("root", "root/foo"), pkg("root/foo", "a"), ), dsp(mkDepspec("a 1.0.0"), pkg("a", "a/bar"), pkg("a/bar", "b"), ), dsp(mkDepspec("a 1.1.0"), pkg("a", "a/bar"), pkg("a/bar"), ), dsp(mkDepspec("b 1.0.0"), pkg("b"), ), }, r: mksolution( mklp("a 1.0.0", ".", "bar"), "b 1.0.0", ), }, "project cycle involving root": { ds: []depspec{ dsp(mkDepspec("root 0.0.0", "a ~1.0.0"), pkg("root", "a"), pkg("root/foo"), ), dsp(mkDepspec("a 1.0.0"), pkg("a", "root/foo"), ), }, r: mksolution( "a 1.0.0", ), }, "project cycle involving root with backtracking": { ds: []depspec{ dsp(mkDepspec("root 0.0.0", "a ~1.0.0"), pkg("root", "a", "b"), pkg("root/foo"), ), dsp(mkDepspec("a 1.0.0"), pkg("a", "root/foo"), ), dsp(mkDepspec("a 1.0.1"), pkg("a", "root/foo"), ), dsp(mkDepspec("b 1.0.0", "a 1.0.0"), pkg("b", "a"), ), dsp(mkDepspec("b 1.0.1", "a 1.0.0"), pkg("b", "a"), ), dsp(mkDepspec("b 1.0.2", "a 1.0.0"), pkg("b", "a"), ), }, r: mksolution( "a 1.0.0", "b 1.0.2", ), }, "unify project on disjoint package imports + source switching": { ds: []depspec{ dsp(mkDepspec("root 0.0.0", "b from baz 1.0.0"), pkg("root", "a", "b"), ), dsp(mkDepspec("a 1.0.0"), pkg("a", "b/foo"), ), dsp(mkDepspec("b 1.0.0"), pkg("b"), pkg("b/foo"), ), dsp(mkDepspec("baz 1.0.0"), pkg("b"), pkg("b/foo"), ), }, r: mksolution( "a 1.0.0", mklp("b from baz 1.0.0", ".", "foo"), ), }, "project cycle not involving root": { ds: []depspec{ dsp(mkDepspec("root 0.0.0", "a ~1.0.0"), pkg("root", "a"), ), dsp(mkDepspec("a 1.0.0"), pkg("a", "b"), pkg("a/foo"), ), dsp(mkDepspec("b 1.0.0"), pkg("b", "a/foo"), ), }, r: mksolution( mklp("a 1.0.0", ".", "foo"), "b 1.0.0", ), }, "project cycle not involving root with internal paths": { ds: []depspec{ dsp(mkDepspec("root 0.0.0", "a ~1.0.0"), pkg("root", "a"), ), dsp(mkDepspec("a 1.0.0"), pkg("a", "b/baz"), pkg("a/foo", "a/quux", "a/quark"), pkg("a/quux"), pkg("a/quark"), ), dsp(mkDepspec("b 1.0.0"), pkg("b", "a/foo"), pkg("b/baz", "b"), ), }, r: mksolution( mklp("a 1.0.0", ".", "foo", "quark", "quux"), mklp("b 1.0.0", ".", "baz"), ), }, // Ensure that if a constraint is expressed, but no actual import exists, // then the constraint is disregarded - the project named in the constraint // is not part of the solution. "ignore constraint without import": { ds: []depspec{ dsp(mkDepspec("root 0.0.0", "a 1.0.0"), pkg("root", "root/foo"), pkg("root/foo"), ), dsp(mkDepspec("a 1.0.0"), pkg("a"), ), }, r: mksolution(), }, // Transitive deps from one project (a) get incrementally included as other // deps incorporate its various packages. "multi-stage pkg incorporation": { ds: []depspec{ dsp(mkDepspec("root 0.0.0"), pkg("root", "a", "d"), ), dsp(mkDepspec("a 1.0.0"), pkg("a", "b"), pkg("a/second", "c"), ), dsp(mkDepspec("b 2.0.0"), pkg("b"), ), dsp(mkDepspec("c 1.2.0"), pkg("c"), ), dsp(mkDepspec("d 1.0.0"), pkg("d", "a/second"), ), }, r: mksolution( mklp("a 1.0.0", ".", "second"), "b 2.0.0", "c 1.2.0", "d 1.0.0", ), }, // Regression - make sure that the the constraint/import intersector only // accepts a project 'match' if exactly equal, or a separating slash is // present. "radix path separator post-check": { ds: []depspec{ dsp(mkDepspec("root 0.0.0"), pkg("root", "foo", "foobar"), ), dsp(mkDepspec("foo 1.0.0"), pkg("foo"), ), dsp(mkDepspec("foobar 1.0.0"), pkg("foobar"), ), }, r: mksolution( "foo 1.0.0", "foobar 1.0.0", ), }, // Well-formed failure when there's a dependency on a pkg that doesn't exist "fail when imports nonexistent package": { ds: []depspec{ dsp(mkDepspec("root 0.0.0", "a 1.0.0"), pkg("root", "a/foo"), ), dsp(mkDepspec("a 1.0.0"), pkg("a"), ), }, fail: &noVersionError{ pn: mkPI("a"), fails: []failedVersion{ { v: NewVersion("1.0.0"), f: &checkeeHasProblemPackagesFailure{ goal: mkAtom("a 1.0.0"), failpkg: map[string]errDeppers{ "a/foo": { err: nil, // nil indicates package is missing deppers: []atom{ mkAtom("root"), }, }, }, }, }, }, }, }, // Transitive deps from one project (a) get incrementally included as other // deps incorporate its various packages, and fail with proper error when we // discover one incrementally that isn't present "fail multi-stage missing pkg": { ds: []depspec{ dsp(mkDepspec("root 0.0.0"), pkg("root", "a", "d"), ), dsp(mkDepspec("a 1.0.0"), pkg("a", "b"), pkg("a/second", "c"), ), dsp(mkDepspec("b 2.0.0"), pkg("b"), ), dsp(mkDepspec("c 1.2.0"), pkg("c"), ), dsp(mkDepspec("d 1.0.0"), pkg("d", "a/second"), pkg("d", "a/nonexistent"), ), }, fail: &noVersionError{ pn: mkPI("d"), fails: []failedVersion{ { v: NewVersion("1.0.0"), f: &depHasProblemPackagesFailure{ goal: mkADep("d 1.0.0", "a", Any(), "a/nonexistent"), v: NewVersion("1.0.0"), prob: map[string]error{ "a/nonexistent": nil, }, }, }, }, }, }, // Check ignores on the root project "ignore in double-subpkg": { ds: []depspec{ dsp(mkDepspec("root 0.0.0"), pkg("root", "root/foo"), pkg("root/foo", "root/bar", "b"), pkg("root/bar", "a"), ), dsp(mkDepspec("a 1.0.0"), pkg("a"), ), dsp(mkDepspec("b 1.0.0"), pkg("b"), ), }, ignore: []string{"root/bar"}, r: mksolution( "b 1.0.0", ), }, // Ignores on a dep pkg "ignore through dep pkg": { ds: []depspec{ dsp(mkDepspec("root 0.0.0"), pkg("root", "root/foo"), pkg("root/foo", "a"), ), dsp(mkDepspec("a 1.0.0"), pkg("a", "a/bar"), pkg("a/bar", "b"), ), dsp(mkDepspec("b 1.0.0"), pkg("b"), ), }, ignore: []string{"a/bar"}, r: mksolution( "a 1.0.0", ), }, // Preferred version, as derived from a dep's lock, is attempted first "respect prefv, simple case": { ds: []depspec{ dsp(mkDepspec("root 0.0.0"), pkg("root", "a")), dsp(mkDepspec("a 1.0.0"), pkg("a", "b")), dsp(mkDepspec("b 1.0.0 foorev"), pkg("b")), dsp(mkDepspec("b 2.0.0 barrev"), pkg("b")), }, lm: map[string]fixLock{ "a 1.0.0": mklock( "b 1.0.0 foorev", ), }, r: mksolution( "a 1.0.0", "b 1.0.0 foorev", ), }, // Preferred version, as derived from a dep's lock, is attempted first, even // if the root also has a direct dep on it (root doesn't need to use // preferreds, because it has direct control AND because the root lock // already supersedes dep lock "preferences") "respect dep prefv with root import": { ds: []depspec{ dsp(mkDepspec("root 0.0.0"), pkg("root", "a", "b")), dsp(mkDepspec("a 1.0.0"), pkg("a", "b")), //dsp(newDepspec("a 1.0.1"), //pkg("a", "b")), //dsp(newDepspec("a 1.1.0"), //pkg("a", "b")), dsp(mkDepspec("b 1.0.0 foorev"), pkg("b")), dsp(mkDepspec("b 2.0.0 barrev"), pkg("b")), }, lm: map[string]fixLock{ "a 1.0.0": mklock( "b 1.0.0 foorev", ), }, r: mksolution( "a 1.0.0", "b 1.0.0 foorev", ), }, // Preferred versions can only work if the thing offering it has been // selected, or at least marked in the unselected queue "prefv only works if depper is selected": { ds: []depspec{ dsp(mkDepspec("root 0.0.0"), pkg("root", "a", "b")), // Three atoms for a, which will mean it gets visited after b dsp(mkDepspec("a 1.0.0"), pkg("a", "b")), dsp(mkDepspec("a 1.0.1"), pkg("a", "b")), dsp(mkDepspec("a 1.1.0"), pkg("a", "b")), dsp(mkDepspec("b 1.0.0 foorev"), pkg("b")), dsp(mkDepspec("b 2.0.0 barrev"), pkg("b")), }, lm: map[string]fixLock{ "a 1.0.0": mklock( "b 1.0.0 foorev", ), }, r: mksolution( "a 1.1.0", "b 2.0.0 barrev", ), }, "override unconstrained root import": { ds: []depspec{ dsp(mkDepspec("root 0.0.0"), pkg("root", "a")), dsp(mkDepspec("a 1.0.0"), pkg("a")), dsp(mkDepspec("a 2.0.0"), pkg("a")), }, ovr: ProjectConstraints{ ProjectRoot("a"): ProjectProperties{ Constraint: NewVersion("1.0.0"), }, }, r: mksolution( "a 1.0.0", ), }, "simple case-only differences": { ds: []depspec{ dsp(mkDepspec("root 0.0.0"), pkg("root", "foo", "bar")), dsp(mkDepspec("foo 1.0.0"), pkg("foo", "Bar")), dsp(mkDepspec("bar 1.0.0"), pkg("bar")), }, fail: &noVersionError{ pn: mkPI("foo"), fails: []failedVersion{ { v: NewVersion("1.0.0"), f: &caseMismatchFailure{ goal: mkDep("foo 1.0.0", "Bar 1.0.0", "Bar"), current: ProjectRoot("bar"), failsib: []dependency{mkDep("root", "bar 1.0.0", "bar")}, }, }, }, }, }, "case variations acceptable with agreement": { ds: []depspec{ dsp(mkDepspec("root 0.0.0"), pkg("root", "foo")), dsp(mkDepspec("foo 1.0.0"), pkg("foo", "Bar", "baz")), dsp(mkDepspec("baz 1.0.0"), pkg("baz", "Bar")), dsp(mkDepspec("bar 1.0.0"), pkg("bar")), }, r: mksolution( "foo 1.0.0", "Bar 1.0.0", "baz 1.0.0", ), }, "case variations within root": { ds: []depspec{ dsp(mkDepspec("root 0.0.0"), pkg("root", "foo", "bar", "Bar")), dsp(mkDepspec("foo 1.0.0"), pkg("foo")), dsp(mkDepspec("bar 1.0.0"), pkg("bar")), }, fail: &noVersionError{ pn: mkPI("foo"), fails: []failedVersion{ { v: NewVersion("1.0.0"), f: &caseMismatchFailure{ goal: mkDep("foo 1.0.0", "Bar 1.0.0", "Bar"), current: ProjectRoot("bar"), failsib: []dependency{mkDep("root", "foo 1.0.0", "foo")}, }, }, }, }, broken: "need to implement checking for import case variations *within* the root", }, "case variations within single dep": { ds: []depspec{ dsp(mkDepspec("root 0.0.0"), pkg("root", "foo")), dsp(mkDepspec("foo 1.0.0"), pkg("foo", "bar", "Bar")), dsp(mkDepspec("bar 1.0.0"), pkg("bar")), }, fail: &noVersionError{ pn: mkPI("foo"), fails: []failedVersion{ { v: NewVersion("1.0.0"), f: &caseMismatchFailure{ goal: mkDep("foo 1.0.0", "Bar 1.0.0", "Bar"), current: ProjectRoot("bar"), failsib: []dependency{mkDep("root", "foo 1.0.0", "foo")}, }, }, }, }, broken: "need to implement checking for import case variations *within* a single project", }, "case variations across multiple deps": { ds: []depspec{ dsp(mkDepspec("root 0.0.0"), pkg("root", "foo", "bar")), dsp(mkDepspec("foo 1.0.0"), pkg("foo", "bar", "baz")), dsp(mkDepspec("baz 1.0.0"), pkg("baz", "Bar")), dsp(mkDepspec("bar 1.0.0"), pkg("bar")), }, fail: &noVersionError{ pn: mkPI("baz"), fails: []failedVersion{ { v: NewVersion("1.0.0"), f: &caseMismatchFailure{ goal: mkDep("baz 1.0.0", "Bar 1.0.0", "Bar"), current: ProjectRoot("bar"), failsib: []dependency{ mkDep("root", "bar 1.0.0", "bar"), mkDep("foo 1.0.0", "bar 1.0.0", "bar"), }, }, }, }, }, }, // This isn't actually as crazy as it might seem, as the root is defined by // the addresser, not the addressee. It would occur (to provide a // real-as-of-this-writing example) if something imports // github.com/Sirupsen/logrus, as the contained subpackage at // github.com/Sirupsen/logrus/hooks/syslog imports // github.com/sirupsen/logrus. The only reason that doesn't blow up all the // time is that most people only import the root package, not the syslog // subpackage. "canonical case is established by mutual self-imports": { ds: []depspec{ dsp(mkDepspec("root 0.0.0"), pkg("root", "foo")), dsp(mkDepspec("foo 1.0.0"), pkg("foo", "Bar")), dsp(mkDepspec("bar 1.0.0"), pkg("bar", "bar/subpkg"), pkg("bar/subpkg")), }, fail: &noVersionError{ pn: mkPI("Bar"), fails: []failedVersion{ { v: NewVersion("1.0.0"), f: &wrongCaseFailure{ correct: ProjectRoot("bar"), goal: mkDep("Bar 1.0.0", "bar 1.0.0", "bar"), badcase: []dependency{mkDep("foo 1.0.0", "Bar 1.0.0", "Bar/subpkg")}, }, }, }, }, }, "canonical case only applies if relevant imports are activated": { ds: []depspec{ dsp(mkDepspec("root 0.0.0"), pkg("root", "foo")), dsp(mkDepspec("foo 1.0.0"), pkg("foo", "Bar/subpkg")), dsp(mkDepspec("bar 1.0.0"), pkg("bar", "bar/subpkg"), pkg("bar/subpkg")), }, r: mksolution( "foo 1.0.0", mklp("Bar 1.0.0", "subpkg"), ), }, "simple case-only variations plus source variance": { ds: []depspec{ dsp(mkDepspec("root 0.0.0"), pkg("root", "foo", "bar")), dsp(mkDepspec("foo 1.0.0", "Bar from quux 1.0.0"), pkg("foo", "Bar")), dsp(mkDepspec("bar 1.0.0"), pkg("bar")), dsp(mkDepspec("quux 1.0.0"), pkg("bar")), }, fail: &noVersionError{ pn: mkPI("foo"), fails: []failedVersion{ { v: NewVersion("1.0.0"), f: &caseMismatchFailure{ goal: mkDep("foo 1.0.0", "Bar from quux 1.0.0", "Bar"), current: ProjectRoot("bar"), failsib: []dependency{mkDep("root", "bar 1.0.0", "bar")}, }, }, }, }, }, "case-only variations plus source variance with internal canonicality": { ds: []depspec{ dsp(mkDepspec("root 0.0.0", "Bar from quux 1.0.0"), pkg("root", "foo", "Bar")), dsp(mkDepspec("foo 1.0.0", "Bar from quux 1.0.0"), pkg("foo", "Bar")), dsp(mkDepspec("bar 1.0.0"), pkg("bar", "bar/subpkg"), pkg("bar/subpkg")), dsp(mkDepspec("quux 1.0.0"), pkg("bar", "bar/subpkg"), pkg("bar/subpkg")), }, fail: &noVersionError{ pn: mkPI("Bar"), fails: []failedVersion{ { v: NewVersion("1.0.0"), f: &wrongCaseFailure{ correct: ProjectRoot("bar"), goal: mkDep("Bar from quux 1.0.0", "bar 1.0.0", "bar"), badcase: []dependency{mkDep("root", "Bar 1.0.0", "Bar/subpkg")}, }, }, }, }, }, "alternate net address": { ds: []depspec{ dsp(mkDepspec("root 1.0.0", "foo from bar 2.0.0"), pkg("root", "foo")), dsp(mkDepspec("foo 1.0.0"), pkg("foo")), dsp(mkDepspec("foo 2.0.0"), pkg("foo")), dsp(mkDepspec("bar 1.0.0"), pkg("foo")), dsp(mkDepspec("bar 2.0.0"), pkg("foo")), }, r: mksolution( "foo from bar 2.0.0", ), }, "alternate net address, version only in alt": { ds: []depspec{ dsp(mkDepspec("root 1.0.0", "foo from bar 2.0.0"), pkg("root", "foo")), dsp(mkDepspec("foo 1.0.0"), pkg("foo")), dsp(mkDepspec("bar 1.0.0"), pkg("foo")), dsp(mkDepspec("bar 2.0.0"), pkg("foo")), }, r: mksolution( "foo from bar 2.0.0", ), }, "alternate net address in dep": { ds: []depspec{ dsp(mkDepspec("root 1.0.0", "foo 1.0.0"), pkg("root", "foo")), dsp(mkDepspec("foo 1.0.0", "bar from baz 2.0.0"), pkg("foo", "bar")), dsp(mkDepspec("bar 1.0.0"), pkg("bar")), dsp(mkDepspec("baz 1.0.0"), pkg("bar")), dsp(mkDepspec("baz 2.0.0"), pkg("bar")), }, r: mksolution( "foo 1.0.0", "bar from baz 2.0.0", ), }, // Because NOT specifying an alternate net address for a given import path // is taken as an "eh, whatever", if we see an empty net addr after // something else has already set an alternate one, then the second should // just "go along" with whatever's already been specified. "alternate net address with second depper": { ds: []depspec{ dsp(mkDepspec("root 1.0.0", "foo from bar 2.0.0"), pkg("root", "foo", "baz")), dsp(mkDepspec("foo 1.0.0"), pkg("foo")), dsp(mkDepspec("foo 2.0.0"), pkg("foo")), dsp(mkDepspec("bar 1.0.0"), pkg("foo")), dsp(mkDepspec("bar 2.0.0"), pkg("foo")), dsp(mkDepspec("baz 1.0.0"), pkg("baz", "foo")), }, r: mksolution( "foo from bar 2.0.0", "baz 1.0.0", ), }, // Same as the previous, except the alternate declaration originates in a // dep, not the root. "alternate net addr from dep, with second default depper": { ds: []depspec{ dsp(mkDepspec("root 1.0.0", "foo 1.0.0"), pkg("root", "foo", "bar")), dsp(mkDepspec("foo 1.0.0", "bar 2.0.0"), pkg("foo", "baz")), dsp(mkDepspec("foo 2.0.0", "bar 2.0.0"), pkg("foo", "baz")), dsp(mkDepspec("bar 2.0.0", "baz from quux 1.0.0"), pkg("bar", "baz")), dsp(mkDepspec("baz 1.0.0"), pkg("baz")), dsp(mkDepspec("baz 2.0.0"), pkg("baz")), dsp(mkDepspec("quux 1.0.0"), pkg("baz")), }, r: mksolution( "foo 1.0.0", "bar 2.0.0", "baz from quux 1.0.0", ), }, // When a given project is initially brought in using the default (i.e., // empty) ProjectIdentifier.Source, and a later, presumably // as-yet-undiscovered dependency specifies an alternate net addr for it, we // have to fail - even though, if the deps were visited in the opposite // order (deeper dep w/the alternate location first, default location // second), it would be fine. // // TODO A better solution here would involve restarting the solver w/a // marker to use that alternate, or (ugh) introducing a new failure // path/marker type that changes how backtracking works. (In fact, these // approaches are probably demonstrably equivalent.) "fails with net mismatch when deeper dep specs it": { ds: []depspec{ dsp(mkDepspec("root 1.0.0", "foo 1.0.0"), pkg("root", "foo", "baz")), dsp(mkDepspec("foo 1.0.0", "bar 2.0.0"), pkg("foo", "bar")), dsp(mkDepspec("bar 2.0.0", "baz from quux 1.0.0"), pkg("bar", "baz")), dsp(mkDepspec("baz 1.0.0"), pkg("baz")), dsp(mkDepspec("quux 1.0.0"), pkg("baz")), }, fail: &noVersionError{ pn: mkPI("bar"), fails: []failedVersion{ { v: NewVersion("2.0.0"), f: &sourceMismatchFailure{ shared: ProjectRoot("baz"), current: "baz", mismatch: "quux", prob: mkAtom("bar 2.0.0"), sel: []dependency{mkDep("foo 1.0.0", "bar 2.0.0", "bar")}, }, }, }, }, }, "with mismatched net addrs": { ds: []depspec{ dsp(mkDepspec("root 1.0.0", "foo 1.0.0", "bar 1.0.0"), pkg("root", "foo", "bar")), dsp(mkDepspec("foo 1.0.0", "bar from baz 1.0.0"), pkg("foo", "bar")), dsp(mkDepspec("bar 1.0.0"), pkg("bar")), dsp(mkDepspec("baz 1.0.0"), pkg("bar")), }, fail: &noVersionError{ pn: mkPI("foo"), fails: []failedVersion{ { v: NewVersion("1.0.0"), f: &sourceMismatchFailure{ shared: ProjectRoot("bar"), current: "bar", mismatch: "baz", prob: mkAtom("foo 1.0.0"), sel: []dependency{mkDep("root", "foo 1.0.0", "foo")}, }, }, }, }, }, "overridden mismatched net addrs, alt in dep": { ds: []depspec{ dsp(mkDepspec("root 0.0.0"), pkg("root", "foo")), dsp(mkDepspec("foo 1.0.0", "bar from baz 1.0.0"), pkg("foo", "bar")), dsp(mkDepspec("bar 1.0.0"), pkg("bar")), dsp(mkDepspec("baz 1.0.0"), pkg("bar")), }, ovr: ProjectConstraints{ ProjectRoot("bar"): ProjectProperties{ Source: "baz", }, }, r: mksolution( "foo 1.0.0", "bar from baz 1.0.0", ), }, "overridden mismatched net addrs, alt in root": { ds: []depspec{ dsp(mkDepspec("root 0.0.0", "bar from baz 1.0.0"), pkg("root", "foo")), dsp(mkDepspec("foo 1.0.0"), pkg("foo", "bar")), dsp(mkDepspec("bar 1.0.0"), pkg("bar")), dsp(mkDepspec("baz 1.0.0"), pkg("bar")), }, ovr: ProjectConstraints{ ProjectRoot("bar"): ProjectProperties{ Source: "baz", }, }, r: mksolution( "foo 1.0.0", "bar from baz 1.0.0", ), }, "require package": { ds: []depspec{ dsp(mkDepspec("root 0.0.0", "bar 1.0.0"), pkg("root", "foo")), dsp(mkDepspec("foo 1.0.0"), pkg("foo", "bar")), dsp(mkDepspec("bar 1.0.0"), pkg("bar")), dsp(mkDepspec("baz 1.0.0"), pkg("baz")), }, require: []string{"baz"}, r: mksolution( "foo 1.0.0", "bar 1.0.0", "baz 1.0.0", ), }, "require activates constraints": { ds: []depspec{ dsp(mkDepspec("root 0.0.0", "foo 1.0.0", "bar 1.0.0"), pkg("root", "foo")), dsp(mkDepspec("foo 1.0.0"), pkg("foo", "bar")), dsp(mkDepspec("bar 1.0.0"), pkg("bar")), dsp(mkDepspec("bar 1.1.0"), pkg("bar")), }, require: []string{"bar"}, r: mksolution( "foo 1.0.0", "bar 1.0.0", ), }, "require subpackage": { ds: []depspec{ dsp(mkDepspec("root 0.0.0", "bar 1.0.0"), pkg("root", "foo")), dsp(mkDepspec("foo 1.0.0"), pkg("foo", "bar")), dsp(mkDepspec("bar 1.0.0"), pkg("bar")), dsp(mkDepspec("baz 1.0.0"), pkg("baz", "baz/qux"), pkg("baz/qux")), }, require: []string{"baz/qux"}, r: mksolution( "foo 1.0.0", "bar 1.0.0", mklp("baz 1.0.0", "qux"), ), }, "require impossible subpackage": { ds: []depspec{ dsp(mkDepspec("root 0.0.0", "baz 1.0.0"), pkg("root", "foo")), dsp(mkDepspec("foo 1.0.0"), pkg("foo")), dsp(mkDepspec("baz 1.0.0"), pkg("baz")), dsp(mkDepspec("baz 2.0.0"), pkg("baz", "baz/qux"), pkg("baz/qux")), }, require: []string{"baz/qux"}, fail: &noVersionError{ pn: mkPI("baz"), fails: []failedVersion{ { v: NewVersion("2.0.0"), f: &versionNotAllowedFailure{ goal: mkAtom("baz 2.0.0"), failparent: []dependency{mkDep("root", "baz 1.0.0", "baz/qux")}, c: NewVersion("1.0.0"), }, }, { v: NewVersion("1.0.0"), f: &checkeeHasProblemPackagesFailure{ goal: mkAtom("baz 1.0.0"), failpkg: map[string]errDeppers{ "baz/qux": { err: nil, // nil indicates package is missing deppers: []atom{ mkAtom("root"), }, }, }, }, }, }, }, }, "require subpkg conflicts with other dep constraint": { ds: []depspec{ dsp(mkDepspec("root 0.0.0"), pkg("root", "foo")), dsp(mkDepspec("foo 1.0.0", "baz 1.0.0"), pkg("foo", "baz")), dsp(mkDepspec("baz 1.0.0"), pkg("baz")), dsp(mkDepspec("baz 2.0.0"), pkg("baz", "baz/qux"), pkg("baz/qux")), }, require: []string{"baz/qux"}, fail: &noVersionError{ pn: mkPI("baz"), fails: []failedVersion{ { v: NewVersion("2.0.0"), f: &versionNotAllowedFailure{ goal: mkAtom("baz 2.0.0"), failparent: []dependency{mkDep("foo 1.0.0", "baz 1.0.0", "baz")}, c: NewVersion("1.0.0"), }, }, { v: NewVersion("1.0.0"), f: &checkeeHasProblemPackagesFailure{ goal: mkAtom("baz 1.0.0"), failpkg: map[string]errDeppers{ "baz/qux": { err: nil, // nil indicates package is missing deppers: []atom{ mkAtom("root"), }, }, }, }, }, }, }, }, "require independent subpkg conflicts with other dep constraint": { ds: []depspec{ dsp(mkDepspec("root 0.0.0"), pkg("root", "foo")), dsp(mkDepspec("foo 1.0.0", "baz 1.0.0"), pkg("foo", "baz")), dsp(mkDepspec("baz 1.0.0"), pkg("baz")), dsp(mkDepspec("baz 2.0.0"), pkg("baz"), pkg("baz/qux")), }, require: []string{"baz/qux"}, fail: &noVersionError{ pn: mkPI("baz"), fails: []failedVersion{ { v: NewVersion("2.0.0"), f: &versionNotAllowedFailure{ goal: mkAtom("baz 2.0.0"), failparent: []dependency{mkDep("foo 1.0.0", "baz 1.0.0", "baz")}, c: NewVersion("1.0.0"), }, }, { v: NewVersion("1.0.0"), f: &checkeeHasProblemPackagesFailure{ goal: mkAtom("baz 1.0.0"), failpkg: map[string]errDeppers{ "baz/qux": { err: nil, // nil indicates package is missing deppers: []atom{ mkAtom("root"), }, }, }, }, }, }, }, }, } // tpkg is a representation of a single package. It has its own import path, as // well as a list of paths it itself "imports". type tpkg struct { // Full import path of this package path string // Slice of full paths to its virtual imports imports []string } type bimodalFixture struct { // name of this fixture datum n string // bimodal project; first is always treated as root project ds []depspec // results; map of name/version pairs r map[ProjectIdentifier]LockedProject // max attempts the solver should need to find solution. 0 means no limit maxAttempts int // Use downgrade instead of default upgrade sorter downgrade bool // lock file simulator, if one's to be used at all l fixLock // map of locks for deps, if any. keys should be of the form: // "<project> <version>" lm map[string]fixLock // solve failure expected, if any fail error // overrides, if any ovr ProjectConstraints // request up/downgrade to all projects changeall bool // pkgs to ignore ignore []string // pkgs to require require []string // if the fixture is currently broken/expected to fail, this has a message // recording why broken string } func (f bimodalFixture) name() string { return f.n } func (f bimodalFixture) specs() []depspec { return f.ds } func (f bimodalFixture) maxTries() int { return f.maxAttempts } func (f bimodalFixture) solution() map[ProjectIdentifier]LockedProject { return f.r } func (f bimodalFixture) rootmanifest() RootManifest { m := simpleRootManifest{ c: pcSliceToMap(f.ds[0].deps), ovr: f.ovr, ig: pkgtree.NewIgnoredRuleset(f.ignore), req: make(map[string]bool), } for _, req := range f.require { m.req[req] = true } return m } func (f bimodalFixture) rootTree() pkgtree.PackageTree { pt := pkgtree.PackageTree{ ImportRoot: string(f.ds[0].n), Packages: map[string]pkgtree.PackageOrErr{}, } for _, pkg := range f.ds[0].pkgs { elems := strings.Split(pkg.path, "/") pt.Packages[pkg.path] = pkgtree.PackageOrErr{ P: pkgtree.Package{ ImportPath: pkg.path, Name: elems[len(elems)-1], // TODO(sdboyer) ugh, tpkg type has no space for supporting test // imports... Imports: pkg.imports, }, } } return pt } func (f bimodalFixture) failure() error { return f.fail } // bmSourceManager is an SM specifically for the bimodal fixtures. It composes // the general depspec SM, and differs from it in how it answers static analysis // calls, and its support for package ignores and dep lock data. type bmSourceManager struct { depspecSourceManager lm map[string]fixLock } var _ SourceManager = &bmSourceManager{} func newbmSM(bmf bimodalFixture) *bmSourceManager { sm := &bmSourceManager{ depspecSourceManager: *newdepspecSM(bmf.ds, bmf.ignore), } sm.rm = computeBimodalExternalMap(bmf.ds) sm.lm = bmf.lm return sm } func (sm *bmSourceManager) ListPackages(id ProjectIdentifier, v Version) (pkgtree.PackageTree, error) { // Deal with address-based root-switching with both case folding and // alternate sources. var src, fsrc, root, froot string src, fsrc = id.normalizedSource(), toFold(id.normalizedSource()) if id.Source != "" { root = string(id.ProjectRoot) froot = toFold(root) } else { root, froot = src, fsrc } for k, ds := range sm.specs { // Cheat for root, otherwise we blow up b/c version is empty if fsrc == string(ds.n) && (k == 0 || ds.v.Matches(v)) { var replace bool if root != string(ds.n) { // We're in a case-varying lookup; ensure we replace the actual // leading ProjectRoot portion of import paths with the literal // string from the input. replace = true } ptree := pkgtree.PackageTree{ ImportRoot: src, Packages: make(map[string]pkgtree.PackageOrErr), } for _, pkg := range ds.pkgs { if replace { pkg.path = strings.Replace(pkg.path, froot, root, 1) } ptree.Packages[pkg.path] = pkgtree.PackageOrErr{ P: pkgtree.Package{ ImportPath: pkg.path, Name: filepath.Base(pkg.path), Imports: pkg.imports, }, } } return ptree, nil } } return pkgtree.PackageTree{}, fmt.Errorf("project %s at version %s could not be found", id, v) } func (sm *bmSourceManager) GetManifestAndLock(id ProjectIdentifier, v Version, an ProjectAnalyzer) (Manifest, Lock, error) { src := toFold(id.normalizedSource()) for _, ds := range sm.specs { if src == string(ds.n) && v.Matches(ds.v) { if l, exists := sm.lm[src+" "+v.String()]; exists { return ds, l, nil } return ds, dummyLock{}, nil } } // TODO(sdboyer) proper solver-type errors return nil, nil, fmt.Errorf("project %s at version %s could not be found", id, v) } // computeBimodalExternalMap takes a set of depspecs and computes an // internally-versioned ReachMap that is useful for quickly answering // ReachMap.Flatten()-type calls. // // Note that it does not do things like stripping out stdlib packages - these // maps are intended for use in SM fixtures, and that's a higher-level // responsibility within the system. func computeBimodalExternalMap(specs []depspec) map[pident]map[string][]string { // map of project name+version -> map of subpkg name -> external pkg list rm := make(map[pident]map[string][]string) for _, ds := range specs { ptree := pkgtree.PackageTree{ ImportRoot: string(ds.n), Packages: make(map[string]pkgtree.PackageOrErr), } for _, pkg := range ds.pkgs { ptree.Packages[pkg.path] = pkgtree.PackageOrErr{ P: pkgtree.Package{ ImportPath: pkg.path, Name: filepath.Base(pkg.path), Imports: pkg.imports, }, } } reachmap, em := ptree.ToReachMap(false, true, true, nil) if len(em) > 0 { panic(fmt.Sprintf("pkgs with errors in reachmap processing: %s", em)) } drm := make(map[string][]string) for ip, ie := range reachmap { drm[ip] = ie.External } rm[pident{n: ds.n, v: ds.v}] = drm } return rm }
gps
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/example.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // +build ignore package main import ( "go/build" "io/ioutil" "log" "os" "path/filepath" "strings" "github.com/golang/dep/gps" "github.com/golang/dep/gps/pkgtree" ) // This is probably the simplest possible implementation of gps. It does the // substantive work that `go get` does, except: // 1. It drops the resulting tree into vendor instead of GOPATH // 2. It prefers semver tags (if available) over branches // 3. It removes any vendor directories nested within dependencies // // This will compile and work...and then blow away any vendor directory present // in the cwd. Be careful! func main() { // Assume the current directory is correctly placed on a GOPATH, and that it's the // root of the project. root, _ := os.Getwd() srcprefix := filepath.Join(build.Default.GOPATH, "src") + string(filepath.Separator) importroot := filepath.ToSlash(strings.TrimPrefix(root, srcprefix)) // Set up params, including tracing params := gps.SolveParameters{ RootDir: root, TraceLogger: log.New(os.Stdout, "", 0), ProjectAnalyzer: NaiveAnalyzer{}, } // Perform static analysis on the current project to find all of its imports. params.RootPackageTree, _ = pkgtree.ListPackages(root, importroot) // Set up a SourceManager. This manages interaction with sources (repositories). tempdir, _ := ioutil.TempDir("", "gps-repocache") sourcemgr, _ := gps.NewSourceManager(gps.SourceManagerConfig{Cachedir: filepath.Join(tempdir)}) defer sourcemgr.Release() // Prep and run the solver solver, _ := gps.Prepare(params, sourcemgr) solution, err := solver.Solve() if err == nil { // If no failure, blow away the vendor dir and write a new one out, // stripping nested vendor directories as we go. os.RemoveAll(filepath.Join(root, "vendor")) pruneOpts := gps.CascadingPruneOptions{ DefaultOptions: gps.PruneNestedVendorDirs | gps.PruneUnusedPackages | gps.PruneGoTestFiles, } gps.WriteDepTree(filepath.Join(root, "vendor"), solution, sourcemgr, pruneOpts, nil) } } // NaiveAnalyzer is a project analyzer that implements gps.ProjectAnalyzer interface. type NaiveAnalyzer struct{} // DeriveManifestAndLock is called when the solver needs manifest/lock data // for a particular dependency project (identified by the gps.ProjectRoot // parameter) at a particular version. That version will be checked out in a // directory rooted at path. func (a NaiveAnalyzer) DeriveManifestAndLock(path string, n gps.ProjectRoot) (gps.Manifest, gps.Lock, error) { return nil, nil, nil } // Info reports the name and version of the analyzer. This is used internally as part // of gps' hashing memoization scheme. func (a NaiveAnalyzer) Info() gps.ProjectAnalyzerInfo { return gps.ProjectAnalyzerInfo{ Name: "example-analyzer", Version: 1, } }
gps
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/vcs_repo_test.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package gps import ( "context" "errors" "io/ioutil" "os" "testing" "time" "github.com/Masterminds/vcs" ) // original implementation of these test files come from // https://github.com/Masterminds/vcs test files const gitRemoteTestRepo = "https://github.com/Masterminds/VCSTestRepo" func TestErrs(t *testing.T) { err := newVcsLocalErrorOr(context.Canceled, nil, "", "") if err != context.Canceled { t.Errorf("context errors should always pass through, got %s", err) } err = newVcsRemoteErrorOr(context.Canceled, nil, "", "") if err != context.Canceled { t.Errorf("context errors should always pass through, got %s", err) } err = newVcsLocalErrorOr(context.DeadlineExceeded, nil, "", "") if err != context.DeadlineExceeded { t.Errorf("context errors should always pass through, got %s", err) } err = newVcsRemoteErrorOr(context.DeadlineExceeded, nil, "", "") if err != context.DeadlineExceeded { t.Errorf("context errors should always pass through, got %s", err) } err = newVcsLocalErrorOr(errors.New("bar"), nil, "foo", "baz") if _, is := err.(*vcs.LocalError); !is { t.Errorf("should have gotten local error, got %T %v", err, err) } err = newVcsRemoteErrorOr(errors.New("bar"), nil, "foo", "baz") if _, is := err.(*vcs.RemoteError); !is { t.Errorf("should have gotten remote error, got %T %v", err, err) } } func testSvnRepo(t *testing.T) { t.Parallel() if testing.Short() { t.Skip("Skipping slow test in short mode") } ctx := context.Background() tempDir, err := ioutil.TempDir("", "go-vcs-svn-tests") if err != nil { t.Fatal(err) } defer func() { err = os.RemoveAll(tempDir) if err != nil { t.Error(err) } }() rep, err := vcs.NewSvnRepo("https://github.com/Masterminds/VCSTestRepo/trunk", tempDir+string(os.PathSeparator)+"VCSTestRepo") if err != nil { t.Fatal(err) } repo := &svnRepo{rep} // Do an initial checkout. err = repo.get(ctx) if err != nil { t.Fatalf("Unable to checkout SVN repo. Err was %s", err) } // Verify SVN repo is a SVN repo if !repo.CheckLocal() { t.Fatal("Problem checking out repo or SVN CheckLocal is not working") } // Update the version to a previous version. err = repo.updateVersion(ctx, "r2") if err != nil { t.Fatalf("Unable to update SVN repo version. Err was %s", err) } // Use Version to verify we are on the right version. v, err := repo.Version() if err != nil { t.Fatal(err) } if v != "2" { t.Fatal("Error checking checked SVN out version") } // Perform an update which should take up back to the latest version. err = repo.fetch(ctx) if err != nil { t.Fatal(err) } // Make sure we are on a newer version because of the update. v, err = repo.Version() if err != nil { t.Fatal(err) } if v == "2" { t.Fatal("Error with version. Still on old version. Update failed") } ci, err := repo.CommitInfo("2") if err != nil { t.Fatal(err) } if ci.Commit != "2" { t.Error("Svn.CommitInfo wrong commit id") } if ci.Author != "matt.farina" { t.Error("Svn.CommitInfo wrong author") } if ci.Message != "Update README.md" { t.Error("Svn.CommitInfo wrong message") } ti, err := time.Parse(time.RFC3339Nano, "2015-07-29T13:46:20.000000Z") if err != nil { t.Fatal(err) } if !ti.Equal(ci.Date) { t.Error("Svn.CommitInfo wrong date") } _, err = repo.CommitInfo("555555555") if err != vcs.ErrRevisionUnavailable { t.Error("Svn didn't return expected ErrRevisionUnavailable") } } func testHgRepo(t *testing.T) { t.Parallel() if testing.Short() { t.Skip("Skipping slow test in short mode") } ctx := context.Background() tempDir, err := ioutil.TempDir("", "go-vcs-hg-tests") if err != nil { t.Fatal(err) } defer func() { err = os.RemoveAll(tempDir) if err != nil { t.Error(err) } }() rep, err := vcs.NewHgRepo("https://bitbucket.org/mattfarina/testhgrepo", tempDir+"/testhgrepo") if err != nil { t.Fatal(err) } repo := &hgRepo{rep} // Do an initial clone. err = repo.get(ctx) if err != nil { t.Fatalf("Unable to clone Hg repo. Err was %s", err) } // Verify Hg repo is a Hg repo if !repo.CheckLocal() { t.Fatal("Problem checking out repo or Hg CheckLocal is not working") } // Set the version using the short hash. err = repo.updateVersion(ctx, "a5494ba2177f") if err != nil { t.Fatalf("Unable to update Hg repo version. Err was %s", err) } // Use Version to verify we are on the right version. v, err := repo.Version() if err != nil { t.Fatal(err) } if v != "a5494ba2177ff9ef26feb3c155dfecc350b1a8ef" { t.Fatalf("Error checking checked out Hg version: %s", v) } // Perform an update. err = repo.fetch(ctx) if err != nil { t.Fatal(err) } } func testGitRepo(t *testing.T) { t.Parallel() if testing.Short() { t.Skip("Skipping slow test in short mode") } ctx := context.Background() tempDir, err := ioutil.TempDir("", "go-vcs-git-tests") if err != nil { t.Fatal(err) } defer func() { err = os.RemoveAll(tempDir) if err != nil { t.Error(err) } }() rep, err := vcs.NewGitRepo(gitRemoteTestRepo, tempDir+"/VCSTestRepo") if err != nil { t.Fatal(err) } repo := &gitRepo{rep} // Do an initial clone. err = repo.get(ctx) if err != nil { t.Fatalf("Unable to clone Git repo. Err was %s", err) } // Verify Git repo is a Git repo if !repo.CheckLocal() { t.Fatal("Problem checking out repo or Git CheckLocal is not working") } // Perform an update. err = repo.fetch(ctx) if err != nil { t.Fatal(err) } v, err := repo.Current() if err != nil { t.Fatalf("Error trying Git Current: %s", err) } if v != "master" { t.Fatalf("Current failed to detect Git on tip of master. Got version: %s", v) } // Set the version using the short hash. err = repo.updateVersion(ctx, "806b07b") if err != nil { t.Fatalf("Unable to update Git repo version. Err was %s", err) } // Once a ref has been checked out the repo is in a detached head state. // Trying to pull in an update in this state will cause an error. Update // should cleanly handle this. Pulling on a branch (tested elsewhere) and // skipping that here. err = repo.fetch(ctx) if err != nil { t.Fatal(err) } // Use Version to verify we are on the right version. v, err = repo.Version() if err != nil { t.Fatal(err) } if v != "806b07b08faa21cfbdae93027904f80174679402" { t.Fatal("Error checking checked out Git version") } } func testBzrRepo(t *testing.T) { t.Parallel() if testing.Short() { t.Skip("Skipping slow test in short mode") } ctx := context.Background() tempDir, err := ioutil.TempDir("", "go-vcs-bzr-tests") if err != nil { t.Fatal(err) } defer func() { err = os.RemoveAll(tempDir) if err != nil { t.Error(err) } }() rep, err := vcs.NewBzrRepo("https://launchpad.net/govcstestbzrrepo", tempDir+"/govcstestbzrrepo") if err != nil { t.Fatal(err) } repo := &bzrRepo{rep} // Do an initial clone. err = repo.get(ctx) if err != nil { t.Fatalf("Unable to clone Bzr repo. Err was %s", err) } // Verify Bzr repo is a Bzr repo if !repo.CheckLocal() { t.Fatal("Problem checking out repo or Bzr CheckLocal is not working") } v, err := repo.Current() if err != nil { t.Fatalf("Error trying Bzr Current: %s", err) } if v != "-1" { t.Fatalf("Current failed to detect Bzr on tip of branch. Got version: %s", v) } err = repo.updateVersion(ctx, "2") if err != nil { t.Fatalf("Unable to update Bzr repo version. Err was %s", err) } // Use Version to verify we are on the right version. v, err = repo.Version() if err != nil { t.Fatal(err) } if v != "2" { t.Fatal("Error checking checked out Bzr version") } v, err = repo.Current() if err != nil { t.Fatalf("Error trying Bzr Current: %s", err) } if v != "2" { t.Fatalf("Current failed to detect Bzr on rev 2 of branch. Got version: %s", v) } }
gps
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/cmd_windows.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package gps import ( "context" "os/exec" ) type cmd struct { *exec.Cmd } func commandContext(ctx context.Context, name string, arg ...string) cmd { return cmd{Cmd: exec.CommandContext(ctx, name, arg...)} }
gps
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/error.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package gps import ( "bytes" "fmt" ) type errorSlice []error func (errs errorSlice) Error() string { var buf bytes.Buffer fmt.Fprintln(&buf) for i, err := range errs { fmt.Fprintf(&buf, "\t(%d) %s\n", i+1, err) } return buf.String() } func (errs errorSlice) Format(f fmt.State, c rune) { fmt.Fprintln(f) for i, err := range errs { if ferr, ok := err.(fmt.Formatter); ok { fmt.Fprintf(f, "\t(%d) ", i+1) ferr.Format(f, c) fmt.Fprint(f, "\n") } else { fmt.Fprintf(f, "\t(%d) %s\n", i+1, err) } } }
pkgtree
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/pkgtree/reachmap.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package pkgtree import ( "sort" "strings" ) // ReachMap maps a set of import paths (keys) to the sets of transitively // reachable tree-internal packages, and all the tree-external packages // reachable through those internal packages. // // See PackageTree.ToReachMap() for more information. type ReachMap map[string]struct { Internal, External []string } // Eliminate import paths with any elements having leading dots, leading // underscores, or testdata. If these are internally reachable (which is // a no-no, but possible), any external imports will have already been // pulled up through ExternalReach. The key here is that we don't want // to treat such packages as themselves being sources. func pkgFilter(pkg string) bool { for _, elem := range strings.Split(pkg, "/") { if strings.HasPrefix(elem, ".") || strings.HasPrefix(elem, "_") || elem == "testdata" { return false } } return true } // FlattenFn flattens a reachmap into a sorted, deduplicated list of all the // external imports named by its contained packages, but excludes imports coming // from packages with disallowed patterns in their names: any path element with // a leading dot, a leading underscore, with the name "testdata". // // Imports for which exclude returns true will be left out. func (rm ReachMap) FlattenFn(exclude func(string) bool) []string { exm := make(map[string]struct{}) for pkg, ie := range rm { if pkgFilter(pkg) { for _, ex := range ie.External { if exclude != nil && exclude(ex) { continue } exm[ex] = struct{}{} } } } if len(exm) == 0 { return []string{} } ex := make([]string, 0, len(exm)) for p := range exm { ex = append(ex, p) } sort.Strings(ex) return ex }
pkgtree
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/pkgtree/pkgtree_test.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package pkgtree import ( "fmt" "go/build" "go/scanner" "go/token" "io/ioutil" "os" "path" "path/filepath" "reflect" "runtime" "strings" "testing" "github.com/golang/dep/gps/paths" "github.com/golang/dep/internal/fs" _ "github.com/golang/dep/internal/test" // DO NOT REMOVE, allows go test ./... -update to work "github.com/google/go-cmp/cmp" ) // PackageTree.ToReachMap() uses an easily separable algorithm, wmToReach(), // to turn a discovered set of packages and their imports into a proper pair of // internal and external reach maps. // // That algorithm is purely symbolic (no filesystem interaction), and thus is // easy to test. This is that test. func TestWorkmapToReach(t *testing.T) { empty := func() map[string]bool { return make(map[string]bool) } table := map[string]struct { workmap map[string]wm rm ReachMap em map[string]*ProblemImportError backprop bool }{ "single": { workmap: map[string]wm{ "foo": { ex: empty(), in: empty(), }, }, rm: ReachMap{ "foo": {}, }, }, "no external": { workmap: map[string]wm{ "foo": { ex: empty(), in: empty(), }, "foo/bar": { ex: empty(), in: empty(), }, }, rm: ReachMap{ "foo": {}, "foo/bar": {}, }, }, "no external with subpkg": { workmap: map[string]wm{ "foo": { ex: empty(), in: map[string]bool{ "foo/bar": true, }, }, "foo/bar": { ex: empty(), in: empty(), }, }, rm: ReachMap{ "foo": { Internal: []string{"foo/bar"}, }, "foo/bar": {}, }, }, "simple base transitive": { workmap: map[string]wm{ "foo": { ex: empty(), in: map[string]bool{ "foo/bar": true, }, }, "foo/bar": { ex: map[string]bool{ "baz": true, }, in: empty(), }, }, rm: ReachMap{ "foo": { External: []string{"baz"}, Internal: []string{"foo/bar"}, }, "foo/bar": { External: []string{"baz"}, }, }, }, "missing package is poison": { workmap: map[string]wm{ "A": { ex: map[string]bool{ "B/foo": true, }, in: map[string]bool{ "A/foo": true, // missing "A/bar": true, }, }, "A/bar": { ex: map[string]bool{ "B/baz": true, }, in: empty(), }, }, rm: ReachMap{ "A/bar": { External: []string{"B/baz"}, }, }, em: map[string]*ProblemImportError{ "A": { ImportPath: "A", Cause: []string{"A/foo"}, Err: missingPkgErr("A/foo"), }, }, backprop: true, }, "transitive missing package is poison": { workmap: map[string]wm{ "A": { ex: map[string]bool{ "B/foo": true, }, in: map[string]bool{ "A/foo": true, // transitively missing "A/quux": true, }, }, "A/foo": { ex: map[string]bool{ "C/flugle": true, }, in: map[string]bool{ "A/bar": true, // missing }, }, "A/quux": { ex: map[string]bool{ "B/baz": true, }, in: empty(), }, }, rm: ReachMap{ "A/quux": { External: []string{"B/baz"}, }, }, em: map[string]*ProblemImportError{ "A": { ImportPath: "A", Cause: []string{"A/foo", "A/bar"}, Err: missingPkgErr("A/bar"), }, "A/foo": { ImportPath: "A/foo", Cause: []string{"A/bar"}, Err: missingPkgErr("A/bar"), }, }, backprop: true, }, "err'd package is poison": { workmap: map[string]wm{ "A": { ex: map[string]bool{ "B/foo": true, }, in: map[string]bool{ "A/foo": true, // err'd "A/bar": true, }, }, "A/foo": { err: fmt.Errorf("err pkg"), }, "A/bar": { ex: map[string]bool{ "B/baz": true, }, in: empty(), }, }, rm: ReachMap{ "A/bar": { External: []string{"B/baz"}, }, }, em: map[string]*ProblemImportError{ "A": { ImportPath: "A", Cause: []string{"A/foo"}, Err: fmt.Errorf("err pkg"), }, "A/foo": { ImportPath: "A/foo", Err: fmt.Errorf("err pkg"), }, }, backprop: true, }, "transitive err'd package is poison": { workmap: map[string]wm{ "A": { ex: map[string]bool{ "B/foo": true, }, in: map[string]bool{ "A/foo": true, // transitively err'd "A/quux": true, }, }, "A/foo": { ex: map[string]bool{ "C/flugle": true, }, in: map[string]bool{ "A/bar": true, // err'd }, }, "A/bar": { err: fmt.Errorf("err pkg"), }, "A/quux": { ex: map[string]bool{ "B/baz": true, }, in: empty(), }, }, rm: ReachMap{ "A/quux": { External: []string{"B/baz"}, }, }, em: map[string]*ProblemImportError{ "A": { ImportPath: "A", Cause: []string{"A/foo", "A/bar"}, Err: fmt.Errorf("err pkg"), }, "A/foo": { ImportPath: "A/foo", Cause: []string{"A/bar"}, Err: fmt.Errorf("err pkg"), }, "A/bar": { ImportPath: "A/bar", Err: fmt.Errorf("err pkg"), }, }, backprop: true, }, "transitive err'd package no backprop": { workmap: map[string]wm{ "A": { ex: map[string]bool{ "B/foo": true, }, in: map[string]bool{ "A/foo": true, // transitively err'd "A/quux": true, }, }, "A/foo": { ex: map[string]bool{ "C/flugle": true, }, in: map[string]bool{ "A/bar": true, // err'd }, }, "A/bar": { err: fmt.Errorf("err pkg"), }, "A/quux": { ex: map[string]bool{ "B/baz": true, }, in: empty(), }, }, rm: ReachMap{ "A": { Internal: []string{"A/bar", "A/foo", "A/quux"}, //Internal: []string{"A/foo", "A/quux"}, External: []string{"B/baz", "B/foo", "C/flugle"}, }, "A/foo": { Internal: []string{"A/bar"}, External: []string{"C/flugle"}, }, "A/quux": { External: []string{"B/baz"}, }, }, em: map[string]*ProblemImportError{ "A/bar": { ImportPath: "A/bar", Err: fmt.Errorf("err pkg"), }, }, }, // The following tests are mostly about regressions and weeding out // weird assumptions "internal diamond": { workmap: map[string]wm{ "A": { ex: map[string]bool{ "B/foo": true, }, in: map[string]bool{ "A/foo": true, "A/bar": true, }, }, "A/foo": { ex: map[string]bool{ "C": true, }, in: map[string]bool{ "A/quux": true, }, }, "A/bar": { ex: map[string]bool{ "D": true, }, in: map[string]bool{ "A/quux": true, }, }, "A/quux": { ex: map[string]bool{ "B/baz": true, }, in: empty(), }, }, rm: ReachMap{ "A": { External: []string{ "B/baz", "B/foo", "C", "D", }, Internal: []string{ "A/bar", "A/foo", "A/quux", }, }, "A/foo": { External: []string{ "B/baz", "C", }, Internal: []string{ "A/quux", }, }, "A/bar": { External: []string{ "B/baz", "D", }, Internal: []string{ "A/quux", }, }, "A/quux": { External: []string{"B/baz"}, }, }, }, "rootmost gets imported": { workmap: map[string]wm{ "A": { ex: map[string]bool{ "B": true, }, in: empty(), }, "A/foo": { ex: map[string]bool{ "C": true, }, in: map[string]bool{ "A": true, }, }, }, rm: ReachMap{ "A": { External: []string{"B"}, }, "A/foo": { External: []string{ "B", "C", }, Internal: []string{ "A", }, }, }, }, "self cycle": { workmap: map[string]wm{ "A": {in: map[string]bool{"A": true}}, }, rm: ReachMap{ "A": {Internal: []string{"A"}}, }, }, "simple cycle": { workmap: map[string]wm{ "A": {in: map[string]bool{"B": true}}, "B": {in: map[string]bool{"A": true}}, }, rm: ReachMap{ "A": {Internal: []string{"A", "B"}}, "B": {Internal: []string{"A", "B"}}, }, }, "cycle with external dependency": { workmap: map[string]wm{ "A": { in: map[string]bool{"B": true}, }, "B": { ex: map[string]bool{"C": true}, in: map[string]bool{"A": true}, }, }, rm: ReachMap{ "A": { External: []string{"C"}, Internal: []string{"A", "B"}, }, "B": { External: []string{"C"}, Internal: []string{"A", "B"}, }, }, }, "cycle with transitive external dependency": { workmap: map[string]wm{ "A": { in: map[string]bool{"B": true}, }, "B": { in: map[string]bool{"A": true, "C": true}, }, "C": { ex: map[string]bool{"D": true}, }, }, rm: ReachMap{ "A": { External: []string{"D"}, Internal: []string{"A", "B", "C"}, }, "B": { External: []string{"D"}, Internal: []string{"A", "B", "C"}, }, "C": { External: []string{"D"}, }, }, }, "internal cycle": { workmap: map[string]wm{ "A": { ex: map[string]bool{"B": true}, in: map[string]bool{"C": true}, }, "C": { in: map[string]bool{"D": true}, }, "D": { in: map[string]bool{"E": true}, }, "E": { in: map[string]bool{"C": true}, }, }, rm: ReachMap{ "A": { External: []string{"B"}, Internal: []string{"C", "D", "E"}, }, "C": { Internal: []string{"C", "D", "E"}, }, "D": { Internal: []string{"C", "D", "E"}, }, "E": { Internal: []string{"C", "D", "E"}, }, }, }, } for name, fix := range table { name, fix := name, fix t.Run(name, func(t *testing.T) { t.Parallel() // Avoid erroneous errors by initializing the fixture's error map if // needed if fix.em == nil { fix.em = make(map[string]*ProblemImportError) } rm, em := wmToReach(fix.workmap, fix.backprop) if diff := cmp.Diff(rm, fix.rm); diff != "" { //t.Error(pretty.Sprintf("wmToReach(%q): Did not get expected reach map:\n\t(GOT): %s\n\t(WNT): %s", name, rm, fix.rm)) t.Errorf("Did not get expected reach map:\n\t(GOT): %s\n\t(WNT): %s", rm, fix.rm) } if diff := cmp.Diff(em, fix.em, cmp.Comparer(func(x error, y error) bool { return x.Error() == y.Error() })); diff != "" { //t.Error(pretty.Sprintf("wmToReach(%q): Did not get expected error map:\n\t(GOT): %# v\n\t(WNT): %# v", name, em, fix.em)) t.Errorf("Did not get expected error map:\n\t(GOT): %v\n\t(WNT): %v", em, fix.em) } }) } } func TestListPackagesNoDir(t *testing.T) { out, err := ListPackages(filepath.Join(getTestdataRootDir(t), "notexist"), "notexist") if err == nil { t.Error("ListPackages should have errored on pointing to a nonexistent dir") } if !reflect.DeepEqual(PackageTree{}, out) { t.Error("should've gotten back an empty PackageTree") } } func TestListPackages(t *testing.T) { srcdir := filepath.Join(getTestdataRootDir(t), "src") j := func(s ...string) string { return filepath.Join(srcdir, filepath.Join(s...)) } table := map[string]struct { fileRoot string importRoot string out PackageTree err error }{ "empty": { fileRoot: j("empty"), importRoot: "empty", out: PackageTree{ ImportRoot: "empty", Packages: map[string]PackageOrErr{ "empty": { Err: &build.NoGoError{ Dir: j("empty"), }, }, }, }, }, "code only": { fileRoot: j("simple"), importRoot: "simple", out: PackageTree{ ImportRoot: "simple", Packages: map[string]PackageOrErr{ "simple": { P: Package{ ImportPath: "simple", CommentPath: "", Name: "simple", Imports: []string{ "github.com/golang/dep/gps", "sort", }, }, }, }, }, }, "impose import path": { fileRoot: j("simple"), importRoot: "arbitrary", out: PackageTree{ ImportRoot: "arbitrary", Packages: map[string]PackageOrErr{ "arbitrary": { P: Package{ ImportPath: "arbitrary", CommentPath: "", Name: "simple", Imports: []string{ "github.com/golang/dep/gps", "sort", }, }, }, }, }, }, "test only": { fileRoot: j("t"), importRoot: "simple", out: PackageTree{ ImportRoot: "simple", Packages: map[string]PackageOrErr{ "simple": { P: Package{ ImportPath: "simple", CommentPath: "", Name: "simple", Imports: []string{}, TestImports: []string{ "math/rand", "strconv", }, }, }, }, }, }, "xtest only": { fileRoot: j("xt"), importRoot: "simple", out: PackageTree{ ImportRoot: "simple", Packages: map[string]PackageOrErr{ "simple": { P: Package{ ImportPath: "simple", CommentPath: "", Name: "simple", Imports: []string{}, TestImports: []string{ "sort", "strconv", }, }, }, }, }, }, "code and test": { fileRoot: j("simplet"), importRoot: "simple", out: PackageTree{ ImportRoot: "simple", Packages: map[string]PackageOrErr{ "simple": { P: Package{ ImportPath: "simple", CommentPath: "", Name: "simple", Imports: []string{ "github.com/golang/dep/gps", "sort", }, TestImports: []string{ "math/rand", "strconv", }, }, }, }, }, }, "code and xtest": { fileRoot: j("simplext"), importRoot: "simple", out: PackageTree{ ImportRoot: "simple", Packages: map[string]PackageOrErr{ "simple": { P: Package{ ImportPath: "simple", CommentPath: "", Name: "simple", Imports: []string{ "github.com/golang/dep/gps", "sort", }, TestImports: []string{ "sort", "strconv", }, }, }, }, }, }, "code, test, xtest": { fileRoot: j("simpleallt"), importRoot: "simple", out: PackageTree{ ImportRoot: "simple", Packages: map[string]PackageOrErr{ "simple": { P: Package{ ImportPath: "simple", CommentPath: "", Name: "simple", Imports: []string{ "github.com/golang/dep/gps", "sort", }, TestImports: []string{ "math/rand", "sort", "strconv", }, }, }, }, }, }, "one pkg multifile": { fileRoot: j("m1p"), importRoot: "m1p", out: PackageTree{ ImportRoot: "m1p", Packages: map[string]PackageOrErr{ "m1p": { P: Package{ ImportPath: "m1p", CommentPath: "", Name: "m1p", Imports: []string{ "github.com/golang/dep/gps", "os", "sort", }, }, }, }, }, }, "one nested below": { fileRoot: j("nest"), importRoot: "nest", out: PackageTree{ ImportRoot: "nest", Packages: map[string]PackageOrErr{ "nest": { P: Package{ ImportPath: "nest", CommentPath: "", Name: "simple", Imports: []string{ "github.com/golang/dep/gps", "sort", }, }, }, "nest/m1p": { P: Package{ ImportPath: "nest/m1p", CommentPath: "", Name: "m1p", Imports: []string{ "github.com/golang/dep/gps", "os", "sort", }, }, }, }, }, }, "malformed go file": { fileRoot: j("bad"), importRoot: "bad", out: PackageTree{ ImportRoot: "bad", Packages: map[string]PackageOrErr{ "bad": { Err: scanner.ErrorList{ &scanner.Error{ Pos: token.Position{ Filename: j("bad", "bad.go"), Offset: 273, Line: 6, Column: 43, }, Msg: "expected 'package', found 'EOF'", }, }, }, }, }, }, "two nested under empty root": { fileRoot: j("ren"), importRoot: "ren", out: PackageTree{ ImportRoot: "ren", Packages: map[string]PackageOrErr{ "ren": { Err: &build.NoGoError{ Dir: j("ren"), }, }, "ren/m1p": { P: Package{ ImportPath: "ren/m1p", CommentPath: "", Name: "m1p", Imports: []string{ "github.com/golang/dep/gps", "os", "sort", }, }, }, "ren/simple": { P: Package{ ImportPath: "ren/simple", CommentPath: "", Name: "simple", Imports: []string{ "github.com/golang/dep/gps", "sort", }, }, }, }, }, }, "internal name mismatch": { fileRoot: j("doublenest"), importRoot: "doublenest", out: PackageTree{ ImportRoot: "doublenest", Packages: map[string]PackageOrErr{ "doublenest": { P: Package{ ImportPath: "doublenest", CommentPath: "", Name: "base", Imports: []string{ "github.com/golang/dep/gps", "go/parser", }, }, }, "doublenest/namemismatch": { P: Package{ ImportPath: "doublenest/namemismatch", CommentPath: "", Name: "nm", Imports: []string{ "github.com/Masterminds/semver", "os", }, }, }, "doublenest/namemismatch/m1p": { P: Package{ ImportPath: "doublenest/namemismatch/m1p", CommentPath: "", Name: "m1p", Imports: []string{ "github.com/golang/dep/gps", "os", "sort", }, }, }, }, }, }, "file and importroot mismatch": { fileRoot: j("doublenest"), importRoot: "other", out: PackageTree{ ImportRoot: "other", Packages: map[string]PackageOrErr{ "other": { P: Package{ ImportPath: "other", CommentPath: "", Name: "base", Imports: []string{ "github.com/golang/dep/gps", "go/parser", }, }, }, "other/namemismatch": { P: Package{ ImportPath: "other/namemismatch", CommentPath: "", Name: "nm", Imports: []string{ "github.com/Masterminds/semver", "os", }, }, }, "other/namemismatch/m1p": { P: Package{ ImportPath: "other/namemismatch/m1p", CommentPath: "", Name: "m1p", Imports: []string{ "github.com/golang/dep/gps", "os", "sort", }, }, }, }, }, }, "code and ignored main": { fileRoot: j("igmain"), importRoot: "simple", out: PackageTree{ ImportRoot: "simple", Packages: map[string]PackageOrErr{ "simple": { P: Package{ ImportPath: "simple", CommentPath: "", Name: "simple", Imports: []string{ "github.com/golang/dep/gps", "sort", "unicode", }, }, }, }, }, }, "code and ignored main, order check": { fileRoot: j("igmainfirst"), importRoot: "simple", out: PackageTree{ ImportRoot: "simple", Packages: map[string]PackageOrErr{ "simple": { P: Package{ ImportPath: "simple", CommentPath: "", Name: "simple", Imports: []string{ "github.com/golang/dep/gps", "sort", "unicode", }, }, }, }, }, }, "code and ignored main with comment leader": { fileRoot: j("igmainlong"), importRoot: "simple", out: PackageTree{ ImportRoot: "simple", Packages: map[string]PackageOrErr{ "simple": { P: Package{ ImportPath: "simple", CommentPath: "", Name: "simple", Imports: []string{ "github.com/golang/dep/gps", "sort", "unicode", }, }, }, }, }, }, "code, tests, and ignored main": { fileRoot: j("igmaint"), importRoot: "simple", out: PackageTree{ ImportRoot: "simple", Packages: map[string]PackageOrErr{ "simple": { P: Package{ ImportPath: "simple", CommentPath: "", Name: "simple", Imports: []string{ "github.com/golang/dep/gps", "sort", "unicode", }, TestImports: []string{ "math/rand", "strconv", }, }, }, }, }, }, // imports a missing pkg "missing import": { fileRoot: j("missing"), importRoot: "missing", out: PackageTree{ ImportRoot: "missing", Packages: map[string]PackageOrErr{ "missing": { P: Package{ ImportPath: "missing", CommentPath: "", Name: "simple", Imports: []string{ "github.com/golang/dep/gps", "missing/missing", "sort", }, }, }, "missing/m1p": { P: Package{ ImportPath: "missing/m1p", CommentPath: "", Name: "m1p", Imports: []string{ "github.com/golang/dep/gps", "os", "sort", }, }, }, }, }, }, // import cycle of three packages. ListPackages doesn't do anything // special with cycles - that's the reach calculator's job - so this is // error-free "import cycle, len 3": { fileRoot: j("cycle"), importRoot: "cycle", out: PackageTree{ ImportRoot: "cycle", Packages: map[string]PackageOrErr{ "cycle": { P: Package{ ImportPath: "cycle", CommentPath: "", Name: "cycle", Imports: []string{ "cycle/one", "github.com/golang/dep/gps", }, }, }, "cycle/one": { P: Package{ ImportPath: "cycle/one", CommentPath: "", Name: "one", Imports: []string{ "cycle/two", "github.com/golang/dep/gps", }, }, }, "cycle/two": { P: Package{ ImportPath: "cycle/two", CommentPath: "", Name: "two", Imports: []string{ "cycle", "github.com/golang/dep/gps", }, }, }, }, }, }, // has disallowed dir names "disallowed dirs": { fileRoot: j("disallow"), importRoot: "disallow", out: PackageTree{ ImportRoot: "disallow", Packages: map[string]PackageOrErr{ "disallow": { P: Package{ ImportPath: "disallow", CommentPath: "", Name: "disallow", Imports: []string{ "disallow/testdata", "github.com/golang/dep/gps", "sort", }, }, }, "disallow/testdata": { P: Package{ ImportPath: "disallow/testdata", CommentPath: "", Name: "testdata", Imports: []string{ "hash", }, }, }, }, }, }, "relative imports": { fileRoot: j("relimport"), importRoot: "relimport", out: PackageTree{ ImportRoot: "relimport", Packages: map[string]PackageOrErr{ "relimport": { P: Package{ ImportPath: "relimport", CommentPath: "", Name: "relimport", Imports: []string{ "sort", }, }, }, "relimport/dot": { P: Package{ ImportPath: "relimport/dot", CommentPath: "", Name: "dot", Imports: []string{ ".", "sort", }, }, }, "relimport/dotdot": { Err: &LocalImportsError{ Dir: j("relimport/dotdot"), ImportPath: "relimport/dotdot", LocalImports: []string{ "..", }, }, }, "relimport/dotslash": { Err: &LocalImportsError{ Dir: j("relimport/dotslash"), ImportPath: "relimport/dotslash", LocalImports: []string{ "./simple", }, }, }, "relimport/dotdotslash": { Err: &LocalImportsError{ Dir: j("relimport/dotdotslash"), ImportPath: "relimport/dotdotslash", LocalImports: []string{ "../github.com/golang/dep/gps", }, }, }, }, }, }, "skip underscore": { fileRoot: j("skip_"), importRoot: "skip_", out: PackageTree{ ImportRoot: "skip_", Packages: map[string]PackageOrErr{ "skip_": { P: Package{ ImportPath: "skip_", CommentPath: "", Name: "skip", Imports: []string{ "github.com/golang/dep/gps", "sort", }, }, }, }, }, }, // This case mostly exists for the PackageTree methods, but it does // cover a bit of range "varied": { fileRoot: j("varied"), importRoot: "varied", out: PackageTree{ ImportRoot: "varied", Packages: map[string]PackageOrErr{ "varied": { P: Package{ ImportPath: "varied", CommentPath: "", Name: "main", Imports: []string{ "net/http", "varied/namemismatch", "varied/otherpath", "varied/simple", }, }, }, "varied/otherpath": { P: Package{ ImportPath: "varied/otherpath", CommentPath: "", Name: "otherpath", Imports: []string{}, TestImports: []string{ "varied/m1p", }, }, }, "varied/simple": { P: Package{ ImportPath: "varied/simple", CommentPath: "", Name: "simple", Imports: []string{ "github.com/golang/dep/gps", "go/parser", "varied/simple/another", }, }, }, "varied/simple/another": { P: Package{ ImportPath: "varied/simple/another", CommentPath: "", Name: "another", Imports: []string{ "hash", "varied/m1p", }, TestImports: []string{ "encoding/binary", }, }, }, "varied/namemismatch": { P: Package{ ImportPath: "varied/namemismatch", CommentPath: "", Name: "nm", Imports: []string{ "github.com/Masterminds/semver", "os", }, }, }, "varied/m1p": { P: Package{ ImportPath: "varied/m1p", CommentPath: "", Name: "m1p", Imports: []string{ "github.com/golang/dep/gps", "os", "sort", }, }, }, }, }, }, "varied with hidden dirs": { fileRoot: j("varied_hidden"), importRoot: "varied", out: PackageTree{ ImportRoot: "varied", Packages: map[string]PackageOrErr{ "varied": { P: Package{ ImportPath: "varied", CommentPath: "", Name: "main", Imports: []string{ "net/http", "varied/_frommain", "varied/simple", }, }, }, "varied/always": { P: Package{ ImportPath: "varied/always", CommentPath: "", Name: "always", Imports: []string{}, TestImports: []string{ "varied/.onlyfromtests", }, }, }, "varied/.onlyfromtests": { P: Package{ ImportPath: "varied/.onlyfromtests", CommentPath: "", Name: "onlyfromtests", Imports: []string{ "github.com/golang/dep/gps", "os", "sort", "varied/_secondorder", }, }, }, "varied/simple": { P: Package{ ImportPath: "varied/simple", CommentPath: "", Name: "simple", Imports: []string{ "github.com/golang/dep/gps", "go/parser", "varied/simple/testdata", }, }, }, "varied/simple/testdata": { P: Package{ ImportPath: "varied/simple/testdata", CommentPath: "", Name: "testdata", Imports: []string{ "varied/dotdotslash", }, }, }, "varied/_secondorder": { P: Package{ ImportPath: "varied/_secondorder", CommentPath: "", Name: "secondorder", Imports: []string{ "hash", }, }, }, "varied/_never": { P: Package{ ImportPath: "varied/_never", CommentPath: "", Name: "never", Imports: []string{ "github.com/golang/dep/gps", "sort", }, }, }, "varied/_frommain": { P: Package{ ImportPath: "varied/_frommain", CommentPath: "", Name: "frommain", Imports: []string{ "github.com/golang/dep/gps", "sort", }, }, }, "varied/dotdotslash": { Err: &LocalImportsError{ Dir: j("varied_hidden/dotdotslash"), ImportPath: "varied/dotdotslash", LocalImports: []string{ "../github.com/golang/dep/gps", }, }, }, }, }, }, "invalid buildtag like comments should be ignored": { fileRoot: j("buildtag"), importRoot: "buildtag", out: PackageTree{ ImportRoot: "buildtag", Packages: map[string]PackageOrErr{ "buildtag": { P: Package{ ImportPath: "buildtag", CommentPath: "", Name: "buildtag", Imports: []string{ "sort", }, }, }, }, }, }, "does not skip directories starting with '.'": { fileRoot: j("dotgodir"), importRoot: "dotgodir", out: PackageTree{ ImportRoot: "dotgodir", Packages: map[string]PackageOrErr{ "dotgodir": { P: Package{ ImportPath: "dotgodir", Imports: []string{}, }, }, "dotgodir/.go": { P: Package{ ImportPath: "dotgodir/.go", Name: "dot", Imports: []string{}, }, }, "dotgodir/foo.go": { P: Package{ ImportPath: "dotgodir/foo.go", Name: "foo", Imports: []string{"sort"}, }, }, "dotgodir/.m1p": { P: Package{ ImportPath: "dotgodir/.m1p", CommentPath: "", Name: "m1p", Imports: []string{ "github.com/golang/dep/gps", "os", "sort", }, }, }, }, }, }, "canonical": { fileRoot: j("canonical"), importRoot: "canonical", out: PackageTree{ ImportRoot: "canonical", Packages: map[string]PackageOrErr{ "canonical": { P: Package{ ImportPath: "canonical", CommentPath: "canonical", Name: "pkg", Imports: []string{}, }, }, "canonical/sub": { P: Package{ ImportPath: "canonical/sub", CommentPath: "canonical/subpackage", Name: "sub", Imports: []string{}, }, }, }, }, }, "conflicting canonical comments": { fileRoot: j("canon_confl"), importRoot: "canon_confl", out: PackageTree{ ImportRoot: "canon_confl", Packages: map[string]PackageOrErr{ "canon_confl": { Err: &ConflictingImportComments{ ImportPath: "canon_confl", ConflictingImportComments: []string{ "vanity1", "vanity2", }, }, }, }, }, }, "non-canonical": { fileRoot: j("canonical"), importRoot: "noncanonical", out: PackageTree{ ImportRoot: "noncanonical", Packages: map[string]PackageOrErr{ "noncanonical": { Err: &NonCanonicalImportRoot{ ImportRoot: "noncanonical", Canonical: "canonical", }, }, "noncanonical/sub": { Err: &NonCanonicalImportRoot{ ImportRoot: "noncanonical", Canonical: "canonical/subpackage", }, }, }, }, }, "slash-star": { fileRoot: j("slash-star_confl"), importRoot: "slash-star_confl", out: PackageTree{ ImportRoot: "slash-star_confl", Packages: map[string]PackageOrErr{ "slash-star_confl": { Err: &ConflictingImportComments{ ImportPath: "slash-star_confl", ConflictingImportComments: []string{ "vanity1", "vanity2", }, }, }, }, }, }, } for name, fix := range table { t.Run(name, func(t *testing.T) { if _, err := os.Stat(fix.fileRoot); err != nil { t.Errorf("error on fileRoot %s: %s", fix.fileRoot, err) } out, err := ListPackages(fix.fileRoot, fix.importRoot) if err != nil && fix.err == nil { t.Errorf("Received error but none expected: %s", err) } else if fix.err != nil && err == nil { t.Errorf("Error expected but none received") } else if fix.err != nil && err != nil { if !reflect.DeepEqual(fix.err, err) { t.Errorf("Did not receive expected error:\n\t(GOT): %s\n\t(WNT): %s", err, fix.err) } } if fix.out.ImportRoot != "" && fix.out.Packages != nil { if !reflect.DeepEqual(out, fix.out) { if fix.out.ImportRoot != out.ImportRoot { t.Errorf("Expected ImportRoot %s, got %s", fix.out.ImportRoot, out.ImportRoot) } // overwrite the out one to see if we still have a real problem out.ImportRoot = fix.out.ImportRoot if !reflect.DeepEqual(out, fix.out) { // TODO (kris-nova) We need to disable this bypass here, and in the .travis.yml // as soon as dep#501 is fixed bypass := os.Getenv("DEPTESTBYPASS501") if bypass != "" { t.Log("bypassing fix.out.Packages check < 2") } else { if len(fix.out.Packages) < 2 { t.Errorf("Did not get expected PackageOrErrs:\n\t(GOT): %#v\n\t(WNT): %#v", out, fix.out) } else { seen := make(map[string]bool) for path, perr := range fix.out.Packages { seen[path] = true if operr, exists := out.Packages[path]; !exists { t.Errorf("Expected PackageOrErr for path %s was missing from output:\n\t%s", path, perr) } else { if !reflect.DeepEqual(perr, operr) { t.Errorf("PkgOrErr for path %s was not as expected:\n\t(GOT): %#v\n\t(WNT): %#v", path, operr, perr) } } } for path, operr := range out.Packages { if seen[path] { continue } t.Errorf("Got PackageOrErr for path %s, but none was expected:\n\t%s", path, operr) } } } } } } }) } } // Transform Table Test that operates solely on the varied_hidden fixture. func TestTrimHiddenPackages(t *testing.T) { base, err := ListPackages(filepath.Join(getTestdataRootDir(t), "src", "varied_hidden"), "varied") if err != nil { panic(err) } table := map[string]struct { main, tests bool // literal params to TrimHiddenPackages ignore []string // transformed into IgnoredRuleset param to TrimHiddenPackages trimmed []string // list of packages that should be trimmed in result PackageTree }{ // All of these implicitly verify that the varied/_never pkg is always // trimmed, and that the varied/dotdotslash pkg is not trimmed even // though it has errors. "minimal trim": { main: true, tests: true, }, "ignore simple, lose testdata": { main: true, tests: true, ignore: []string{"simple"}, trimmed: []string{"simple", "simple/testdata"}, }, "no tests": { main: true, tests: false, trimmed: []string{".onlyfromtests", "_secondorder"}, }, "ignore a reachable hidden": { main: true, tests: true, ignore: []string{"_secondorder"}, trimmed: []string{"_secondorder"}, }, "ignore a reachable hidden with another hidden solely reachable through it": { main: true, tests: true, ignore: []string{".onlyfromtests"}, trimmed: []string{".onlyfromtests", "_secondorder"}, }, "no main": { main: false, tests: true, trimmed: []string{"", "_frommain"}, }, "no main or tests": { main: false, tests: false, trimmed: []string{"", "_frommain", ".onlyfromtests", "_secondorder"}, }, "no main or tests and ignore simple": { main: false, tests: false, ignore: []string{"simple"}, trimmed: []string{"", "_frommain", ".onlyfromtests", "_secondorder", "simple", "simple/testdata"}, }, } for name, fix := range table { t.Run(name, func(t *testing.T) { want := base.Copy() var ig []string for _, v := range fix.ignore { ig = append(ig, path.Join("varied", v)) } got := base.TrimHiddenPackages(fix.main, fix.tests, NewIgnoredRuleset(ig)) for _, ip := range append(fix.trimmed, "_never") { ip = path.Join("varied", ip) if _, has := want.Packages[ip]; !has { panic(fmt.Sprintf("bad input, %s does not exist in fixture ptree", ip)) } delete(want.Packages, ip) } if !reflect.DeepEqual(want, got) { if len(want.Packages) < 2 { t.Errorf("Did not get expected PackageOrErrs:\n\t(GOT): %#v\n\t(WNT): %#v", got, want) } else { seen := make(map[string]bool) for path, perr := range want.Packages { seen[path] = true if operr, exists := got.Packages[path]; !exists { t.Errorf("Expected PackageOrErr for path %s was missing from output:\n\t%s", path, perr) } else { if !reflect.DeepEqual(perr, operr) { t.Errorf("PkgOrErr for path %s was not as expected:\n\t(GOT): %#v\n\t(WNT): %#v", path, operr, perr) } } } for path, operr := range got.Packages { if seen[path] { continue } t.Errorf("Got PackageOrErr for path %s, but none was expected:\n\t%s", path, operr) } } } }) } } // Test that ListPackages skips directories for which it lacks permissions to // enter and files it lacks permissions to read. func TestListPackagesNoPerms(t *testing.T) { if runtime.GOOS == "windows" { // TODO This test doesn't work on windows because I wasn't able to easily // figure out how to chmod a dir in a way that made it untraversable. // // It's not a big deal, though, because the os.IsPermission() call we // use in the real code is effectively what's being tested here, and // that's designed to be cross-platform. So, if the unix tests pass, we // have every reason to believe windows tests would too, if the situation // arises. t.Skip() } tmp, err := ioutil.TempDir("", "listpkgsnp") if err != nil { t.Fatalf("Failed to create temp dir: %s", err) } defer os.RemoveAll(tmp) srcdir := filepath.Join(getTestdataRootDir(t), "src", "ren") workdir := filepath.Join(tmp, "ren") fs.CopyDir(srcdir, workdir) // chmod the simple dir and m1p/b.go file so they can't be read err = os.Chmod(filepath.Join(workdir, "simple"), 0) if err != nil { t.Fatalf("Error while chmodding simple dir: %s", err) } os.Chmod(filepath.Join(workdir, "m1p", "b.go"), 0) if err != nil { t.Fatalf("Error while chmodding b.go file: %s", err) } want := PackageTree{ ImportRoot: "ren", Packages: map[string]PackageOrErr{ "ren": { Err: &build.NoGoError{ Dir: workdir, }, }, "ren/m1p": { P: Package{ ImportPath: "ren/m1p", CommentPath: "", Name: "m1p", Imports: []string{ "github.com/golang/dep/gps", "sort", }, }, }, }, } got, err := ListPackages(workdir, "ren") if err != nil { t.Fatalf("Unexpected err from ListPackages: %s", err) } if want.ImportRoot != got.ImportRoot { t.Fatalf("Expected ImportRoot %s, got %s", want.ImportRoot, got.ImportRoot) } if !reflect.DeepEqual(got, want) { t.Errorf("Did not get expected PackageOrErrs:\n\t(GOT): %#v\n\t(WNT): %#v", got, want) if len(got.Packages) != 2 { if len(got.Packages) == 3 { t.Error("Wrong number of PackageOrErrs - did 'simple' subpackage make it into results somehow?") } else { t.Error("Wrong number of PackageOrErrs") } } if got.Packages["ren"].Err == nil { t.Error("Should have gotten error on empty root directory") } if !reflect.DeepEqual(got.Packages["ren/m1p"].P.Imports, want.Packages["ren/m1p"].P.Imports) { t.Error("Mismatch between imports in m1p") } } } func TestToReachMap(t *testing.T) { // There's enough in the 'varied' test case to test most of what matters vptree, err := ListPackages(filepath.Join(getTestdataRootDir(t), "src", "github.com", "example", "varied"), "github.com/example/varied") if err != nil { t.Fatalf("ListPackages failed on varied test case: %s", err) } // Helper to add github.com/varied/example prefix b := func(s string) string { if s == "" { return "github.com/example/varied" } return "github.com/example/varied/" + s } bl := func(parts ...string) string { for k, s := range parts { parts[k] = b(s) } return strings.Join(parts, " ") } // Set up vars for validate closure var want ReachMap var name string var main, tests bool var ignore []string validate := func() { got, em := vptree.ToReachMap(main, tests, true, NewIgnoredRuleset(ignore)) if len(em) != 0 { t.Errorf("Should not have any error packages from ToReachMap, got %s", em) } if !reflect.DeepEqual(want, got) { seen := make(map[string]bool) for ip, wantie := range want { seen[ip] = true if gotie, exists := got[ip]; !exists { t.Errorf("ver(%q): expected import path %s was not present in result", name, ip) } else { if !reflect.DeepEqual(wantie, gotie) { t.Errorf("ver(%q): did not get expected import set for pkg %s:\n\t(GOT): %#v\n\t(WNT): %#v", name, ip, gotie, wantie) } } } for ip, ie := range got { if seen[ip] { continue } t.Errorf("ver(%q): Got packages for import path %s, but none were expected:\n\t%s", name, ip, ie) } } } // maps of each internal package, and their expected external and internal // imports in the maximal case. allex := map[string][]string{ b(""): {"encoding/binary", "github.com/Masterminds/semver", "github.com/golang/dep/gps", "go/parser", "hash", "net/http", "os", "sort"}, b("m1p"): {"github.com/golang/dep/gps", "os", "sort"}, b("namemismatch"): {"github.com/Masterminds/semver", "os"}, b("otherpath"): {"github.com/golang/dep/gps", "os", "sort"}, b("simple"): {"encoding/binary", "github.com/golang/dep/gps", "go/parser", "hash", "os", "sort"}, b("simple/another"): {"encoding/binary", "github.com/golang/dep/gps", "hash", "os", "sort"}, } allin := map[string][]string{ b(""): {b("m1p"), b("namemismatch"), b("otherpath"), b("simple"), b("simple/another")}, b("m1p"): {}, b("namemismatch"): {}, b("otherpath"): {b("m1p")}, b("simple"): {b("m1p"), b("simple/another")}, b("simple/another"): {b("m1p")}, } // build a map to validate the exception inputs. do this because shit is // hard enough to keep track of that it's preferable not to have silent // success if a typo creeps in and we're trying to except an import that // isn't in a pkg in the first place valid := make(map[string]map[string]bool) for ip, expkgs := range allex { m := make(map[string]bool) for _, pkg := range expkgs { m[pkg] = true } valid[ip] = m } validin := make(map[string]map[string]bool) for ip, inpkgs := range allin { m := make(map[string]bool) for _, pkg := range inpkgs { m[pkg] = true } validin[ip] = m } // helper to compose want, excepting specific packages // // this makes it easier to see what we're taking out on each test except := func(pkgig ...string) { // reinit expect with everything from all want = make(ReachMap) for ip, expkgs := range allex { var ie struct{ Internal, External []string } inpkgs := allin[ip] lenex, lenin := len(expkgs), len(inpkgs) if lenex > 0 { ie.External = make([]string, len(expkgs)) copy(ie.External, expkgs) } if lenin > 0 { ie.Internal = make([]string, len(inpkgs)) copy(ie.Internal, inpkgs) } want[ip] = ie } // now build the dropmap drop := make(map[string]map[string]bool) for _, igstr := range pkgig { // split on space; first elem is import path to pkg, the rest are // the imports to drop. not := strings.Split(igstr, " ") var ip string ip, not = not[0], not[1:] if _, exists := valid[ip]; !exists { t.Fatalf("%s is not a package name we're working with, doofus", ip) } // if only a single elem was passed, though, drop the whole thing if len(not) == 0 { delete(want, ip) continue } m := make(map[string]bool) for _, imp := range not { if strings.HasPrefix(imp, "github.com/example/varied") { if !validin[ip][imp] { t.Fatalf("%s is not a reachable import of %s, even in the all case", imp, ip) } } else { if !valid[ip][imp] { t.Fatalf("%s is not a reachable import of %s, even in the all case", imp, ip) } } m[imp] = true } drop[ip] = m } for ip, ie := range want { var nie struct{ Internal, External []string } for _, imp := range ie.Internal { if !drop[ip][imp] { nie.Internal = append(nie.Internal, imp) } } for _, imp := range ie.External { if !drop[ip][imp] { nie.External = append(nie.External, imp) } } want[ip] = nie } } /* PREP IS DONE, BEGIN ACTUAL TESTING */ // first, validate all name = "all" main, tests = true, true except() validate() // turn off main pkgs, which necessarily doesn't affect anything else name = "no main" main = false except(b("")) validate() // ignoring the "varied" pkg has same effect as disabling main pkgs name = "ignore root" ignore = []string{b("")} main = true validate() // when we drop tests, varied/otherpath loses its link to varied/m1p and // varied/simple/another loses its test import, which has a fairly big // cascade name = "no tests" tests = false ignore = nil except( b("")+" encoding/binary", b("simple")+" encoding/binary", b("simple/another")+" encoding/binary", b("otherpath")+" github.com/golang/dep/gps os sort", ) // almost the same as previous, but varied just goes away completely name = "no main or tests" main = false except( b(""), b("simple")+" encoding/binary", b("simple/another")+" encoding/binary", bl("otherpath", "m1p")+" github.com/golang/dep/gps os sort", ) validate() // focus on ignores now, so reset main and tests main, tests = true, true // now, the fun stuff. punch a hole in the middle by cutting out // varied/simple name = "ignore varied/simple" ignore = []string{b("simple")} except( // root pkg loses on everything in varied/simple/another // FIXME this is a bit odd, but should probably exclude m1p as well, // because it actually shouldn't be valid to import a package that only // has tests. This whole model misses that nuance right now, though. bl("", "simple", "simple/another")+" hash encoding/binary go/parser", b("simple"), ) validate() // widen the hole by excluding otherpath name = "ignore varied/{otherpath,simple}" ignore = []string{ b("otherpath"), b("simple"), } except( // root pkg loses on everything in varied/simple/another and varied/m1p bl("", "simple", "simple/another", "m1p", "otherpath")+" hash encoding/binary go/parser github.com/golang/dep/gps sort", b("otherpath"), b("simple"), ) validate() // remove namemismatch, though we're mostly beating a dead horse now name = "ignore varied/{otherpath,simple,namemismatch}" ignore = append(ignore, b("namemismatch")) except( // root pkg loses on everything in varied/simple/another and varied/m1p bl("", "simple", "simple/another", "m1p", "otherpath", "namemismatch")+" hash encoding/binary go/parser github.com/golang/dep/gps sort os github.com/Masterminds/semver", b("otherpath"), b("simple"), b("namemismatch"), ) validate() } func TestFlattenReachMap(t *testing.T) { // There's enough in the 'varied' test case to test most of what matters vptree, err := ListPackages(filepath.Join(getTestdataRootDir(t), "src", "github.com", "example", "varied"), "github.com/example/varied") if err != nil { t.Fatalf("listPackages failed on varied test case: %s", err) } all := []string{ "encoding/binary", "github.com/Masterminds/semver", "github.com/golang/dep/gps", "go/parser", "hash", "net/http", "os", "sort", } // helper to generate testCase.expect as: all, except for a couple packages // // this makes it easier to see what we're taking out on each test except := func(not ...string) []string { expect := make([]string, len(all)-len(not)) drop := make(map[string]bool) for _, npath := range not { drop[npath] = true } k := 0 for _, path := range all { if !drop[path] { expect[k] = path k++ } } return expect } for _, testCase := range []*flattenReachMapCase{ // everything on { name: "simple", expect: except(), isStdLibFn: nil, main: true, tests: true, }, // no stdlib { name: "no stdlib", expect: except("encoding/binary", "go/parser", "hash", "net/http", "os", "sort"), isStdLibFn: paths.IsStandardImportPath, main: true, tests: true, }, // stdlib back in; now exclude tests, which should just cut one { name: "no tests", expect: except("encoding/binary"), isStdLibFn: nil, main: true, tests: false, }, // Now skip main, which still just cuts out one { name: "no main", expect: except("net/http"), isStdLibFn: nil, main: false, tests: true, }, // No test and no main, which should be additive { name: "no tests, no main", expect: except("net/http", "encoding/binary"), isStdLibFn: nil, main: false, tests: false, }, // now, the ignore tests. turn main and tests back on // start with non-matching { name: "non-matching ignore", expect: except(), isStdLibFn: nil, main: true, tests: true, ignore: NewIgnoredRuleset([]string{ "nomatch", }), }, // should have the same effect as ignoring main { name: "ignore the root", expect: except("net/http"), isStdLibFn: nil, main: true, tests: true, ignore: NewIgnoredRuleset([]string{ "github.com/example/varied", }), }, // now drop a more interesting one // we get github.com/golang/dep/gps from m1p, too, so it should still be there { name: "ignore simple", expect: except("go/parser"), isStdLibFn: nil, main: true, tests: true, ignore: NewIgnoredRuleset([]string{ "github.com/example/varied/simple", }), }, // now drop two { name: "ignore simple and nameismatch", expect: except("go/parser", "github.com/Masterminds/semver"), isStdLibFn: nil, main: true, tests: true, ignore: NewIgnoredRuleset([]string{ "github.com/example/varied/simple", "github.com/example/varied/namemismatch", }), }, // make sure tests and main play nice with ignore { name: "ignore simple and nameismatch, and no tests", expect: except("go/parser", "github.com/Masterminds/semver", "encoding/binary"), isStdLibFn: nil, main: true, tests: false, ignore: NewIgnoredRuleset([]string{ "github.com/example/varied/simple", "github.com/example/varied/namemismatch", }), }, { name: "ignore simple and namemismatch, and no main", expect: except("go/parser", "github.com/Masterminds/semver", "net/http"), isStdLibFn: nil, main: false, tests: true, ignore: NewIgnoredRuleset([]string{ "github.com/example/varied/simple", "github.com/example/varied/namemismatch", }), }, { name: "ignore simple and namemismatch, and no main or tests", expect: except("go/parser", "github.com/Masterminds/semver", "net/http", "encoding/binary"), isStdLibFn: nil, main: false, tests: false, ignore: NewIgnoredRuleset([]string{ "github.com/example/varied/simple", "github.com/example/varied/namemismatch", }), }, // ignore two that should knock out gps { name: "ignore both importers", expect: except("sort", "github.com/golang/dep/gps", "go/parser"), isStdLibFn: nil, main: true, tests: true, ignore: NewIgnoredRuleset([]string{ "github.com/example/varied/simple", "github.com/example/varied/m1p", }), }, // finally, directly ignore some external packages { name: "ignore external", expect: except("sort", "github.com/golang/dep/gps", "go/parser"), isStdLibFn: nil, main: true, tests: true, ignore: NewIgnoredRuleset([]string{ "github.com/golang/dep/gps", "go/parser", "sort", }), }, } { t.Run(testCase.name, testFlattenReachMap(&vptree, testCase)) } // The only thing varied *doesn't* cover is disallowed path patterns ptree, err := ListPackages(filepath.Join(getTestdataRootDir(t), "src", "disallow"), "disallow") if err != nil { t.Fatalf("ListPackages failed on disallow test case: %s", err) } t.Run("disallowed", testFlattenReachMap(&ptree, &flattenReachMapCase{ name: "disallowed", expect: []string{"github.com/golang/dep/gps", "hash", "sort"}, isStdLibFn: nil, main: false, tests: false, })) } type flattenReachMapCase struct { expect []string name string ignore *IgnoredRuleset main, tests bool isStdLibFn func(string) bool } func testFlattenReachMap(ptree *PackageTree, testCase *flattenReachMapCase) func(*testing.T) { return func(t *testing.T) { t.Parallel() rm, em := ptree.ToReachMap(testCase.main, testCase.tests, true, testCase.ignore) if len(em) != 0 { t.Errorf("Should not have any error pkgs from ToReachMap, got %s", em) } result := rm.FlattenFn(testCase.isStdLibFn) if !reflect.DeepEqual(testCase.expect, result) { t.Errorf("Wrong imports in %q case:\n\t(GOT): %s\n\t(WNT): %s", testCase.name, result, testCase.expect) } } } // Verify that we handle import cycles correctly - drop em all func TestToReachMapCycle(t *testing.T) { ptree, err := ListPackages(filepath.Join(getTestdataRootDir(t), "src", "cycle"), "cycle") if err != nil { t.Fatalf("ListPackages failed on cycle test case: %s", err) } rm, em := ptree.ToReachMap(true, true, false, nil) if len(em) != 0 { t.Errorf("Should not have any error packages from ToReachMap, got %s", em) } // FIXME TEMPORARILY COMMENTED UNTIL WE CREATE A BETTER LISTPACKAGES MODEL - //if len(rm) > 0 { //t.Errorf("should be empty reachmap when all packages are in a cycle, got %v", rm) //} if len(rm) == 0 { t.Error("TEMPORARY: should ignore import cycles, but cycle was eliminated") } } func TestToReachMapFilterDot(t *testing.T) { ptree, err := ListPackages(filepath.Join(getTestdataRootDir(t), "src", "relimport"), "relimport") if err != nil { t.Fatalf("ListPackages failed on relimport test case: %s", err) } rm, _ := ptree.ToReachMap(true, true, false, nil) if _, has := rm["relimport/dot"]; !has { t.Fatal("relimport/dot should not have had errors") } imports := dedupeStrings(rm["relimport/dot"].External, rm["relimport/dot"].Internal) for _, imp := range imports { if imp == "." { t.Fatal("dot import should have been filtered by ToReachMap") } } } func getTestdataRootDir(t *testing.T) string { cwd, err := os.Getwd() if err != nil { t.Fatal(err) } return filepath.Join(cwd, "..", "_testdata") } // Canary regression test to make sure that if PackageTree ever gains new // fields, we update the Copy method accordingly. func TestCanaryPackageTreeCopy(t *testing.T) { ptreeFields := []string{ "ImportRoot", "Packages", } packageFields := []string{ "Name", "ImportPath", "CommentPath", "Imports", "TestImports", } fieldNames := func(typ reflect.Type) []string { var names []string for i := 0; i < typ.NumField(); i++ { names = append(names, typ.Field(i).Name) } return names } ptreeRefl := fieldNames(reflect.TypeOf(PackageTree{})) packageRefl := fieldNames(reflect.TypeOf(Package{})) if !reflect.DeepEqual(ptreeFields, ptreeRefl) { t.Errorf("PackageTree.Copy is designed to work with an exact set of fields in the PackageTree struct - make sure it (and this test) have been updated!\n\t(GOT):%s\n\t(WNT):%s", ptreeFields, ptreeRefl) } if !reflect.DeepEqual(packageFields, packageRefl) { t.Errorf("PackageTree.Copy is designed to work with an exact set of fields in the Package struct - make sure it (and this test) have been updated!\n\t(GOT):%s\n\t(WNT):%s", packageFields, packageRefl) } } func TestPackageTreeCopy(t *testing.T) { want := PackageTree{ ImportRoot: "ren", Packages: map[string]PackageOrErr{ "ren": { Err: &build.NoGoError{ Dir: "some/dir", }, }, "ren/m1p": { P: Package{ ImportPath: "ren/m1p", CommentPath: "", Name: "m1p", Imports: []string{ "github.com/sdboyer/gps", "sort", }, }, }, }, } got := want.Copy() if !reflect.DeepEqual(want, got) { t.Errorf("Did not get expected PackageOrErrs:\n\t(GOT): %+v\n\t(WNT): %+v", got, want) } }
pkgtree
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/pkgtree/ignored_ruleset.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package pkgtree import ( "sort" "strings" "github.com/armon/go-radix" ) // IgnoredRuleset comprises a set of rules for ignoring import paths. It can // manage both literal and prefix-wildcard matches. type IgnoredRuleset struct { t *radix.Tree } // NewIgnoredRuleset processes a set of strings into an IgnoredRuleset. Strings // that end in "*" are treated as wildcards, where any import path with a // matching prefix will be ignored. IgnoredRulesets are immutable once created. // // Duplicate and redundant (i.e. a literal path that has a prefix of a wildcard // path) declarations are discarded. Consequently, it is possible that the // returned IgnoredRuleset may have a smaller Len() than the input slice. func NewIgnoredRuleset(ig []string) *IgnoredRuleset { if len(ig) == 0 { return &IgnoredRuleset{} } ir := &IgnoredRuleset{ t: radix.New(), } // Sort the list of all the ignores in order to ensure that wildcard // precedence is recorded correctly in the trie. sort.Strings(ig) for _, i := range ig { // Skip global ignore and empty string. if i == "*" || i == "" { continue } _, wildi, has := ir.t.LongestPrefix(i) // We may not always have a value here, but if we do, then it's a bool. wild, _ := wildi.(bool) // Check if it's a wildcard ignore. if strings.HasSuffix(i, "*") { // Check if it is ineffectual. if has && wild { // Skip ineffectual wildcard ignore. continue } // Create the ignore prefix and insert in the radix tree. ir.t.Insert(i[:len(i)-1], true) } else if !has || !wild { ir.t.Insert(i, false) } } if ir.t.Len() == 0 { ir.t = nil } return ir } // IsIgnored indicates whether the provided path should be ignored, according to // the ruleset. func (ir *IgnoredRuleset) IsIgnored(path string) bool { if path == "" || ir == nil || ir.t == nil { return false } prefix, wildi, has := ir.t.LongestPrefix(path) return has && (wildi.(bool) || path == prefix) } // Len indicates the number of rules in the ruleset. func (ir *IgnoredRuleset) Len() int { if ir == nil || ir.t == nil { return 0 } return ir.t.Len() } // ToSlice converts the contents of the IgnoredRuleset to a string slice. // // This operation is symmetrically dual to NewIgnoredRuleset. func (ir *IgnoredRuleset) ToSlice() []string { irlen := ir.Len() if irlen == 0 { return nil } items := make([]string, 0, irlen) ir.t.Walk(func(s string, v interface{}) bool { if s != "" { if v.(bool) { items = append(items, s+"*") } else { items = append(items, s) } } return false }) return items }
pkgtree
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/pkgtree/ignored_ruleset_test.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package pkgtree import "testing" func TestIgnoredRuleset(t *testing.T) { type tfixm []struct { path string wild bool } cases := []struct { name string inputs []string wantInTree tfixm wantEmptyTree bool shouldIgnore []string shouldNotIgnore []string }{ { name: "only skip global ignore", inputs: []string{"*"}, wantEmptyTree: true, }, { name: "ignores without ignore suffix", inputs: []string{ "x/y/z", "*a/b/c", "gophers", }, wantInTree: tfixm{ {path: "x/y/z", wild: false}, {path: "*a/b/c", wild: false}, {path: "gophers", wild: false}, }, shouldIgnore: []string{ "x/y/z", "gophers", }, shouldNotIgnore: []string{ "x/y/z/q", "x/y", "gopher", "gopherss", }, }, { name: "ignores with ignore suffix", inputs: []string{ "x/y/z*", "a/b/c", "gophers", }, wantInTree: tfixm{ {path: "x/y/z", wild: true}, {path: "a/b/c", wild: false}, {path: "gophers", wild: false}, }, shouldIgnore: []string{ "x/y/z", "x/y/zz", "x/y/z/", "x/y/z/q", }, shouldNotIgnore: []string{ "x/y", "gopher", }, }, { name: "global ignore with other strings", inputs: []string{ "*", "gophers*", "x/y/z*", "a/b/c", }, wantInTree: tfixm{ {path: "x/y/z", wild: true}, {path: "a/b/c", wild: false}, {path: "gophers", wild: true}, }, shouldIgnore: []string{ "x/y/z", "x/y/z/", "x/y/z/q", "gophers", "gopherss", "gophers/foo", }, shouldNotIgnore: []string{ "x/y", "gopher", }, }, { name: "ineffectual ignore with wildcard", inputs: []string{ "a/b*", "a/b/c*", "a/b/x/y", "a/c*", }, wantInTree: tfixm{ {path: "a/c", wild: true}, {path: "a/b", wild: true}, }, shouldIgnore: []string{ "a/cb", }, shouldNotIgnore: []string{ "a/", "a/d", }, }, { name: "same path with and without wildcard", inputs: []string{ "a/b*", "a/b", }, wantInTree: tfixm{ {path: "a/b", wild: true}, }, shouldIgnore: []string{ "a/b", "a/bb", }, shouldNotIgnore: []string{ "a/", "a/d", }, }, { name: "empty paths", inputs: []string{ "", "a/b*", }, wantInTree: tfixm{ {path: "a/b", wild: true}, }, shouldNotIgnore: []string{ "", }, }, { name: "single wildcard", inputs: []string{ "a/b*", }, wantInTree: tfixm{ {path: "a/b", wild: true}, }, shouldIgnore: []string{ "a/b/c", }, }, } for _, c := range cases { igm := NewIgnoredRuleset(c.inputs) f := func(t *testing.T) { if c.wantEmptyTree { if igm.Len() != 0 { t.Fatalf("wanted empty tree, but had %v elements", igm.Len()) } } // Check if the wildcard suffix ignores are in the tree. for _, p := range c.wantInTree { wildi, has := igm.t.Get(p.path) if !has { t.Fatalf("expected %q to be in the tree", p.path) } else if wildi.(bool) != p.wild { if p.wild { t.Fatalf("expected %q to be a wildcard matcher, but it was not", p.path) } else { t.Fatalf("expected %q not to be a wildcard matcher, but it was", p.path) } } } for _, p := range c.shouldIgnore { if !igm.IsIgnored(p) { t.Fatalf("%q should be ignored, but it was not", p) } } for _, p := range c.shouldNotIgnore { if igm.IsIgnored(p) { t.Fatalf("%q should not be ignored, but it was", p) } } } t.Run(c.name, f) igm = NewIgnoredRuleset(igm.ToSlice()) t.Run(c.name+"/inandout", f) } }
pkgtree
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/pkgtree/pkgtree.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package pkgtree import ( "bytes" "fmt" "go/ast" "go/build" "go/parser" gscan "go/scanner" "go/token" "os" "path/filepath" "sort" "strconv" "strings" "unicode" ) // Package represents a Go package. It contains a subset of the information // go/build.Package does. type Package struct { Name string // Package name, as declared in the package statement ImportPath string // Full import path, including the prefix provided to ListPackages() CommentPath string // Import path given in the comment on the package statement Imports []string // Imports from all go and cgo files TestImports []string // Imports from all go test files (in go/build parlance: both TestImports and XTestImports) } // vcsRoots is a set of directories we should not descend into in ListPackages when // searching for Go packages var vcsRoots = map[string]struct{}{ ".git": {}, ".bzr": {}, ".svn": {}, ".hg": {}, } // ListPackages reports Go package information about all directories in the tree // at or below the provided fileRoot. // // The importRoot parameter is prepended to the relative path when determining // the import path for each package. The obvious case is for something typical, // like: // // fileRoot = "/home/user/go/src/github.com/foo/bar" // importRoot = "github.com/foo/bar" // // where the fileRoot and importRoot align. However, if you provide: // // fileRoot = "/home/user/workspace/path/to/repo" // importRoot = "github.com/foo/bar" // // then the root package at path/to/repo will be ascribed import path // "github.com/foo/bar", and the package at // "/home/user/workspace/path/to/repo/baz" will be "github.com/foo/bar/baz". // // A PackageTree is returned, which contains the ImportRoot and map of import path // to PackageOrErr - each path under the root that exists will have either a // Package, or an error describing why the directory is not a valid package. func ListPackages(fileRoot, importRoot string) (PackageTree, error) { ptree := PackageTree{ ImportRoot: importRoot, Packages: make(map[string]PackageOrErr), } var err error fileRoot, err = filepath.Abs(fileRoot) if err != nil { return PackageTree{}, err } err = filepath.Walk(fileRoot, func(wp string, fi os.FileInfo, err error) error { if err != nil && err != filepath.SkipDir { if os.IsPermission(err) { return filepath.SkipDir } return err } if !fi.IsDir() { return nil } // Skip dirs that are known to hold non-local/dependency code. // // We don't skip _*, or testdata dirs because, while it may be poor // form, importing them is not a compilation error. switch fi.Name() { case "vendor": return filepath.SkipDir } // Skip dirs that are known to be VCS roots. // // Note that there are some pathological edge cases this doesn't cover, // such as a user using Git for version control, but having a package // named "svn" in a directory named ".svn". if _, ok := vcsRoots[fi.Name()]; ok { return filepath.SkipDir } { // For Go 1.9 and earlier: // // The entry error is nil when visiting a directory that itself is // untraversable, as it's still governed by the parent directory's // perms. We have to check readability of the dir here, because // otherwise we'll have an empty package entry when we fail to read any // of the dir's contents. // // If we didn't check here, then the next time this closure is called it // would have an err with the same path as is called this time, as only // then will filepath.Walk have attempted to descend into the directory // and encountered an error. var f *os.File f, err = os.Open(wp) if err != nil { if os.IsPermission(err) { return filepath.SkipDir } return err } f.Close() } // Compute the import path. Run the result through ToSlash(), so that // windows file paths are normalized to slashes, as is expected of // import paths. ip := filepath.ToSlash(filepath.Join(importRoot, strings.TrimPrefix(wp, fileRoot))) // Find all the imports, across all os/arch combos p := &build.Package{ Dir: wp, ImportPath: ip, } err = fillPackage(p) if err != nil { switch err.(type) { case gscan.ErrorList, *gscan.Error, *build.NoGoError, *ConflictingImportComments: // Assorted cases in which we've encountered malformed or // nonexistent Go source code. ptree.Packages[ip] = PackageOrErr{ Err: err, } return nil default: return err } } pkg := Package{ ImportPath: ip, CommentPath: p.ImportComment, Name: p.Name, Imports: p.Imports, TestImports: dedupeStrings(p.TestImports, p.XTestImports), } if pkg.CommentPath != "" && !strings.HasPrefix(pkg.CommentPath, importRoot) { ptree.Packages[ip] = PackageOrErr{ Err: &NonCanonicalImportRoot{ ImportRoot: importRoot, Canonical: pkg.CommentPath, }, } return nil } // This area has some...fuzzy rules, but check all the imports for // local/relative/dot-ness, and record an error for the package if we // see any. var lim []string for _, imp := range append(pkg.Imports, pkg.TestImports...) { if build.IsLocalImport(imp) { // Do allow the single-dot, at least for now if imp == "." { continue } lim = append(lim, imp) } } if len(lim) > 0 { ptree.Packages[ip] = PackageOrErr{ Err: &LocalImportsError{ Dir: wp, ImportPath: ip, LocalImports: lim, }, } } else { ptree.Packages[ip] = PackageOrErr{ P: pkg, } } return nil }) if err != nil { return PackageTree{}, err } return ptree, nil } // fillPackage full of info. Assumes p.Dir is set at a minimum func fillPackage(p *build.Package) error { var buildPrefix = "// +build " var buildFieldSplit = func(r rune) bool { return unicode.IsSpace(r) || r == ',' } gofiles, err := filepath.Glob(filepath.Join(p.Dir, "*.go")) if err != nil { return err } if len(gofiles) == 0 { return &build.NoGoError{Dir: p.Dir} } var testImports []string var imports []string var importComments []string for _, file := range gofiles { // Skip underscore-led or dot-led files, in keeping with the rest of the toolchain. bPrefix := filepath.Base(file)[0] if bPrefix == '_' || bPrefix == '.' { continue } // Skip any directories that happened to get caught by glob if stat, err := os.Stat(file); err == nil && stat.IsDir() { continue } pf, err := parser.ParseFile(token.NewFileSet(), file, nil, parser.ImportsOnly|parser.ParseComments) if err != nil { if os.IsPermission(err) { continue } return err } testFile := strings.HasSuffix(file, "_test.go") fname := filepath.Base(file) var ignored bool for _, c := range pf.Comments { ic := findImportComment(pf.Name, c) if ic != "" { importComments = append(importComments, ic) } if c.Pos() > pf.Package { // "+build" comment must come before package continue } var ct string for _, cl := range c.List { if strings.HasPrefix(cl.Text, buildPrefix) { ct = cl.Text break } } if ct == "" { continue } for _, t := range strings.FieldsFunc(ct[len(buildPrefix):], buildFieldSplit) { // hardcoded (for now) handling for the "ignore" build tag // We "soft" ignore the files tagged with ignore so that we pull in their imports. if t == "ignore" { ignored = true } } } if testFile { p.TestGoFiles = append(p.TestGoFiles, fname) if p.Name == "" && !ignored { p.Name = strings.TrimSuffix(pf.Name.Name, "_test") } } else { if p.Name == "" && !ignored { p.Name = pf.Name.Name } p.GoFiles = append(p.GoFiles, fname) } for _, is := range pf.Imports { name, err := strconv.Unquote(is.Path.Value) if err != nil { return err // can't happen? } if testFile { testImports = append(testImports, name) } else { imports = append(imports, name) } } } importComments = uniq(importComments) if len(importComments) > 1 { return &ConflictingImportComments{ ImportPath: p.ImportPath, ConflictingImportComments: importComments, } } if len(importComments) > 0 { p.ImportComment = importComments[0] } imports = uniq(imports) testImports = uniq(testImports) p.Imports = imports p.TestImports = testImports return nil } var ( slashSlash = []byte("//") slashStar = []byte("/*") starSlash = []byte("*/") importKwd = []byte("import ") ) func findImportComment(pkgName *ast.Ident, c *ast.CommentGroup) string { afterPkg := pkgName.NamePos + token.Pos(len(pkgName.Name)) + 1 commentSlash := c.List[0].Slash if afterPkg != commentSlash { return "" } text := []byte(c.List[0].Text) switch { case bytes.HasPrefix(text, slashSlash): eol := bytes.IndexByte(text, '\n') if eol < 0 { eol = len(text) } text = text[2:eol] case bytes.HasPrefix(text, slashStar): text = text[2:] end := bytes.Index(text, starSlash) if end < 0 { // malformed comment return "" } text = text[:end] if bytes.IndexByte(text, '\n') >= 0 { // multiline comment, can't be an import comment return "" } } text = bytes.TrimSpace(text) if !bytes.HasPrefix(text, importKwd) { return "" } quotedPath := bytes.TrimSpace(text[len(importKwd):]) return string(bytes.Trim(quotedPath, `"`)) } // ConflictingImportComments indicates that the package declares more than one // different canonical path. type ConflictingImportComments struct { ImportPath string // An import path referring to this package ConflictingImportComments []string // All distinct "canonical" paths encountered in the package files } func (e *ConflictingImportComments) Error() string { return fmt.Sprintf("import path %s had conflicting import comments: %s", e.ImportPath, quotedPaths(e.ConflictingImportComments)) } // NonCanonicalImportRoot reports the situation when the dependee imports a // package via something other than the package's declared canonical path. type NonCanonicalImportRoot struct { ImportRoot string // A root path that is being used to import a package Canonical string // A canonical path declared by the package being imported } func (e *NonCanonicalImportRoot) Error() string { return fmt.Sprintf("import root %q is not a prefix for the package's declared canonical path %q", e.ImportRoot, e.Canonical) } func quotedPaths(ps []string) string { quoted := make([]string, 0, len(ps)) for _, p := range ps { quoted = append(quoted, fmt.Sprintf("%q", p)) } return strings.Join(quoted, ", ") } // LocalImportsError indicates that a package contains at least one relative // import that will prevent it from compiling. // // TODO(sdboyer) add a Files property once we're doing our own per-file parsing type LocalImportsError struct { ImportPath string Dir string LocalImports []string } func (e *LocalImportsError) Error() string { switch len(e.LocalImports) { case 0: // shouldn't be possible, but just cover the case return fmt.Sprintf("import path %s had bad local imports", e.ImportPath) case 1: return fmt.Sprintf("import path %s had a local import: %q", e.ImportPath, e.LocalImports[0]) default: return fmt.Sprintf("import path %s had local imports: %s", e.ImportPath, quotedPaths(e.LocalImports)) } } type wm struct { err error ex map[string]bool in map[string]bool } // PackageOrErr stores the results of attempting to parse a single directory for // Go source code. type PackageOrErr struct { P Package Err error } // ProblemImportError describes the reason that a particular import path is // not safely importable. type ProblemImportError struct { // The import path of the package with some problem rendering it // unimportable. ImportPath string // The path to the internal package the problem package imports that is the // original cause of this issue. If empty, the package itself is the // problem. Cause []string // The actual error from ListPackages that is undermining importability for // this package. Err error } // Error formats the ProblemImportError as a string, reflecting whether the // error represents a direct or transitive problem. func (e *ProblemImportError) Error() string { switch len(e.Cause) { case 0: return fmt.Sprintf("%q contains malformed code: %s", e.ImportPath, e.Err.Error()) case 1: return fmt.Sprintf("%q imports %q, which contains malformed code: %s", e.ImportPath, e.Cause[0], e.Err.Error()) default: return fmt.Sprintf("%q transitively (through %v packages) imports %q, which contains malformed code: %s", e.ImportPath, len(e.Cause)-1, e.Cause[len(e.Cause)-1], e.Err.Error()) } } // Helper func to create an error when a package is missing. func missingPkgErr(pkg string) error { return fmt.Errorf("no package exists at %q", pkg) } // A PackageTree represents the results of recursively parsing a tree of // packages, starting at the ImportRoot. The results of parsing the files in the // directory identified by each import path - a Package or an error - are stored // in the Packages map, keyed by that import path. type PackageTree struct { ImportRoot string Packages map[string]PackageOrErr } // ToReachMap looks through a PackageTree and computes the list of external // import statements (that is, import statements pointing to packages that are // not logical children of PackageTree.ImportRoot) that are transitively // imported by the internal packages in the tree. // // main indicates whether (true) or not (false) to include main packages in the // analysis. When utilized by gps' solver, main packages are generally excluded // from analyzing anything other than the root project, as they necessarily can't // be imported. // // tests indicates whether (true) or not (false) to include imports from test // files in packages when computing the reach map. // // backprop indicates whether errors (an actual PackageOrErr.Err, or an import // to a nonexistent internal package) should be backpropagated, transitively // "poisoning" all corresponding importers to all importers. // // ignore is a map of import paths that, if encountered, should be excluded from // analysis. This exclusion applies to both internal and external packages. If // an external import path is ignored, it is simply omitted from the results. // // If an internal path is ignored, then it not only does not appear in the final // map, but it is also excluded from the transitive calculations of other // internal packages. That is, if you ignore A/foo, then the external package // list for all internal packages that import A/foo will not include external // packages that are only reachable through A/foo. // // Visually, this means that, given a PackageTree with root A and packages at A, // A/foo, and A/bar, and the following import chain: // // A -> A/foo -> A/bar -> B/baz // // In this configuration, all of A's packages transitively import B/baz, so the // returned map would be: // // map[string][]string{ // "A": []string{"B/baz"}, // "A/foo": []string{"B/baz"} // "A/bar": []string{"B/baz"}, // } // // However, if you ignore A/foo, then A's path to B/baz is broken, and A/foo is // omitted entirely. Thus, the returned map would be: // // map[string][]string{ // "A": []string{}, // "A/bar": []string{"B/baz"}, // } // // If there are no packages to ignore, it is safe to pass a nil map. // // Finally, if an internal PackageOrErr contains an error, it is always omitted // from the result set. If backprop is true, then the error from that internal // package will be transitively propagated back to any other internal // PackageOrErrs that import it, causing them to also be omitted. So, with the // same import chain: // // A -> A/foo -> A/bar -> B/baz // // If A/foo has an error, then it would backpropagate to A, causing both to be // omitted, and the returned map to contain only A/bar: // // map[string][]string{ // "A/bar": []string{"B/baz"}, // } // // If backprop is false, then errors will not backpropagate to internal // importers. So, with an error in A/foo, this would be the result map: // // map[string][]string{ // "A": []string{}, // "A/bar": []string{"B/baz"}, // } func (t PackageTree) ToReachMap(main, tests, backprop bool, ignore *IgnoredRuleset) (ReachMap, map[string]*ProblemImportError) { // world's simplest adjacency list workmap := make(map[string]wm) var imps []string for ip, perr := range t.Packages { if perr.Err != nil { workmap[ip] = wm{ err: perr.Err, } continue } p := perr.P // Skip main packages, unless param says otherwise if p.Name == "main" && !main { continue } // Skip ignored packages if ignore.IsIgnored(ip) { continue } // TODO (kris-nova) Disable to get staticcheck passing //imps = imps[:0] if tests { imps = dedupeStrings(p.Imports, p.TestImports) } else { imps = p.Imports } w := wm{ ex: make(map[string]bool), in: make(map[string]bool), } // For each import, decide whether it should be ignored, or if it // belongs in the external or internal imports list. for _, imp := range imps { if ignore.IsIgnored(imp) || imp == "." { continue } if !eqOrSlashedPrefix(imp, t.ImportRoot) { w.ex[imp] = true } else { w.in[imp] = true } } workmap[ip] = w } return wmToReach(workmap, backprop) } // Copy copies the PackageTree. // // This is really only useful as a defensive measure to prevent external state // mutations. func (t PackageTree) Copy() PackageTree { return PackageTree{ ImportRoot: t.ImportRoot, Packages: CopyPackages(t.Packages, nil), } } // CopyPackages returns a deep copy of p, optionally modifying the entries with fn. func CopyPackages(p map[string]PackageOrErr, fn func(string, PackageOrErr) (string, PackageOrErr)) map[string]PackageOrErr { p2 := make(map[string]PackageOrErr, len(p)) // Walk through and count up the total number of string slice elements we'll // need, then allocate them all at once. strcount := 0 for _, poe := range p { strcount = strcount + len(poe.P.Imports) + len(poe.P.TestImports) } pool := make([]string, strcount) for path, poe := range p { var poe2 PackageOrErr if poe.Err != nil { poe2.Err = poe.Err } else { poe2.P = poe.P il, til := len(poe.P.Imports), len(poe.P.TestImports) if il > 0 { poe2.P.Imports, pool = pool[:il], pool[il:] copy(poe2.P.Imports, poe.P.Imports) } if til > 0 { poe2.P.TestImports, pool = pool[:til], pool[til:] copy(poe2.P.TestImports, poe.P.TestImports) } } if fn != nil { path, poe2 = fn(path, poe2) } p2[path] = poe2 } return p2 } // TrimHiddenPackages returns a new PackageTree where packages that are ignored, // or both hidden and unreachable, have been removed. // // The package list is partitioned into two sets: visible, and hidden, where // packages are considered hidden if they are within or beneath directories // with: // // * leading dots // * leading underscores // * the exact name "testdata" // // Packages in the hidden set are dropped from the returned PackageTree, unless // they are transitively reachable from imports in the visible set. // // The "main", "tests" and "ignored" parameters have the same behavior as with // PackageTree.ToReachMap(): the first two determine, respectively, whether // imports from main packages, and imports from tests, should be considered for // reachability checks. Setting 'main' to true will additionally result in main // packages being trimmed. // // "ignored" designates import paths, or patterns of import paths, where the // corresponding packages should be excluded from reachability checks, if // encountered. Ignored packages are also removed from the final set. // // Note that it is not recommended to call this method if the goal is to obtain // a set of tree-external imports; calling ToReachMap and FlattenFn will achieve // the same effect. func (t PackageTree) TrimHiddenPackages(main, tests bool, ignore *IgnoredRuleset) PackageTree { rm, pie := t.ToReachMap(main, tests, false, ignore) t2 := t.Copy() preserve := make(map[string]bool) for pkg, ie := range rm { if pkgFilter(pkg) && !ignore.IsIgnored(pkg) { preserve[pkg] = true for _, in := range ie.Internal { preserve[in] = true } } } // Also process the problem map, as packages in the visible set with errors // need to be included in the return values. for pkg := range pie { if pkgFilter(pkg) && !ignore.IsIgnored(pkg) { preserve[pkg] = true } } for ip := range t.Packages { if !preserve[ip] { delete(t2.Packages, ip) } } return t2 } // wmToReach takes an internal "workmap" constructed by // PackageTree.ExternalReach(), transitively walks (via depth-first traversal) // all internal imports until they reach an external path or terminate, then // translates the results into a slice of external imports for each internal // pkg. // // It drops any packages with errors, and - if backprop is true - backpropagates // those errors, causing internal packages that (transitively) import other // internal packages having errors to also be dropped. func wmToReach(workmap map[string]wm, backprop bool) (ReachMap, map[string]*ProblemImportError) { // Uses depth-first exploration to compute reachability into external // packages, dropping any internal packages on "poisoned paths" - a path // containing a package with an error, or with a dep on an internal package // that's missing. const ( white uint8 = iota grey black ) colors := make(map[string]uint8) exrsets := make(map[string]map[string]struct{}) inrsets := make(map[string]map[string]struct{}) errmap := make(map[string]*ProblemImportError) // poison is a helper func to eliminate specific reachsets from exrsets and // inrsets, and populate error information along the way. poison := func(path []string, err *ProblemImportError) { for k, ppkg := range path { delete(exrsets, ppkg) delete(inrsets, ppkg) // Duplicate the err for this package kerr := &ProblemImportError{ ImportPath: ppkg, Err: err.Err, } // Shift the slice bounds on the incoming err.Cause. // // This check will only be false on the final path element when // entering via poisonWhite, where the last pkg is the underlying // cause of the problem, and is thus expected to have an empty Cause // slice. if k+1 < len(err.Cause) { // reuse the slice kerr.Cause = err.Cause[k+1:] } // Both black and white cases can have the final element be a // package that doesn't exist. If that's the case, don't write it // directly to the errmap, as presence in the errmap indicates the // package was present in the input PackageTree. if k == len(path)-1 { if _, exists := workmap[path[len(path)-1]]; !exists { continue } } // Direct writing to the errmap means that if multiple errors affect // a given package, only the last error visited will be reported. // But that should be sufficient; presumably, the user can // iteratively resolve the errors. errmap[ppkg] = kerr } } // poisonWhite wraps poison for error recording in the white-poisoning case, // where we're constructing a new poison path. poisonWhite := func(path []string) { err := &ProblemImportError{ Cause: make([]string, len(path)), } copy(err.Cause, path) // find the tail err tail := path[len(path)-1] if w, exists := workmap[tail]; exists { // If we make it to here, the dfe guarantees that the workmap // will contain an error for this pkg. err.Err = w.err } else { err.Err = missingPkgErr(tail) } poison(path, err) } // poisonBlack wraps poison for error recording in the black-poisoning case, // where we're connecting to an existing poison path. poisonBlack := func(path []string, from string) { // Because the outer dfe loop ensures we never directly re-visit a pkg // that was already completed (black), we don't have to defend against // an empty path here. fromErr, exists := errmap[from] // FIXME: It should not be possible for fromErr to not exist, // See issue https://github.com/golang/dep/issues/351 // This is a temporary solution to avoid a panic. if !exists { fromErr = &ProblemImportError{ Err: fmt.Errorf("unknown error for %q, if you get this error see https://github.com/golang/dep/issues/351", from), } } err := &ProblemImportError{ Err: fromErr.Err, Cause: make([]string, 0, len(path)+len(fromErr.Cause)+1), } err.Cause = append(err.Cause, path...) err.Cause = append(err.Cause, from) err.Cause = append(err.Cause, fromErr.Cause...) poison(path, err) } var dfe func(string, []string) bool // dfe is the depth-first-explorer that computes a safe, error-free external // reach map. // // pkg is the import path of the pkg currently being visited; path is the // stack of parent packages we've visited to get to pkg. The return value // indicates whether the level completed successfully (true) or if it was // poisoned (false). dfe = func(pkg string, path []string) bool { // white is the zero value of uint8, which is what we want if the pkg // isn't in the colors map, so this works fine switch colors[pkg] { case white: // first visit to this pkg; mark it as in-process (grey) colors[pkg] = grey // make sure it's present and w/out errs w, exists := workmap[pkg] // Push current visitee onto the path slice. Passing path through // recursion levels as a value has the effect of auto-popping the // slice, while also giving us safe memory reuse. path = append(path, pkg) if !exists || w.err != nil { if backprop { // Does not exist or has an err; poison self and all parents poisonWhite(path) } else if exists { // Only record something in the errmap if there's actually a // package there, per the semantics of the errmap errmap[pkg] = &ProblemImportError{ ImportPath: pkg, Err: w.err, } } // we know we're done here, so mark it black colors[pkg] = black return false } // pkg exists with no errs; start internal and external reachsets for it. rs := make(map[string]struct{}) irs := make(map[string]struct{}) // Dump this package's external pkgs into its own reachset. Separate // loop from the parent dump to avoid nested map loop lookups. for ex := range w.ex { rs[ex] = struct{}{} } exrsets[pkg] = rs // Same deal for internal imports for in := range w.in { irs[in] = struct{}{} } inrsets[pkg] = irs // Push this pkg's imports into all parent reachsets. Not all // parents will necessarily have a reachset; none, some, or all // could have been poisoned by a different path than what we're on // right now. for _, ppkg := range path { if prs, exists := exrsets[ppkg]; exists { for ex := range w.ex { prs[ex] = struct{}{} } } if prs, exists := inrsets[ppkg]; exists { for in := range w.in { prs[in] = struct{}{} } } } // Now, recurse until done, or a false bubbles up, indicating the // path is poisoned. for in := range w.in { clean := dfe(in, path) if !clean && backprop { // Path is poisoned. If we're backpropagating errors, then // the reachmap for the visitee was already deleted by the // path we're returning from; mark the visitee black, then // return false to bubble up the poison. This is OK to do // early, before exploring all internal imports, because the // outer loop visits all internal packages anyway. // // In fact, stopping early is preferable - white subpackages // won't have to iterate pointlessly through a parent path // with no reachset. colors[pkg] = black return false } } // Fully done with this pkg; no transitive problems. colors[pkg] = black return true case grey: // Grey means an import cycle. These can arise in healthy situations // through xtest. They can also arise in less healthy but valid // situations where an edge in the import graph is reversed based on // the presence of a build tag. For example, if A depends on B on // Linux, but B depends on A on Darwin, the import graph is not // cyclic on either Linux or Darwin but dep will see what appears to // be a dependency cycle because it considers all tags at once. // // Handling import cycles for the purposes of reachablity is // straightforward: we treat all packages in the cycle as // equivalent. Any package imported by one package in the cycle is // necessarily reachable by all other packages in the cycle. // Merge the reachsets in the cycle by sharing the same external // reachset and internal reachset amongst all packages in the // cycle. var cycleStarted bool for _, ppkg := range path { if cycleStarted { exrsets[ppkg] = exrsets[pkg] inrsets[ppkg] = inrsets[pkg] } else if ppkg == pkg { cycleStarted = true } } if !cycleStarted { panic(fmt.Sprintf("path to grey package %s did not include cycle: %s", pkg, path)) } return true case black: // black means we're revisiting a package that was already // completely explored. If it has an entry in exrsets, it completed // successfully. If not, it was poisoned, and we need to bubble the // poison back up. rs, exists := exrsets[pkg] if !exists { if backprop { // just poison parents; self was necessarily already poisoned poisonBlack(path, pkg) } return false } // If external reachset existed, internal must (even if empty) irs := inrsets[pkg] // It's good; pull over the imports from its reachset into all // non-poisoned parent reachsets for _, ppkg := range path { if prs, exists := exrsets[ppkg]; exists { for ex := range rs { prs[ex] = struct{}{} } } if prs, exists := inrsets[ppkg]; exists { for in := range irs { prs[in] = struct{}{} } } } return true default: panic(fmt.Sprintf("invalid color marker %v for %s", colors[pkg], pkg)) } } // Run the depth-first exploration. // // Don't bother computing graph sources, this straightforward loop works // comparably well, and fits nicely with an escape hatch in the dfe. var path []string for pkg := range workmap { // However, at least check that the package isn't already fully visited; // this saves a bit of time and implementation complexity inside the // closures. if colors[pkg] != black { dfe(pkg, path) } } type ie struct { Internal, External []string } // Flatten exrsets into reachmap rm := make(ReachMap) for pkg, rs := range exrsets { rlen := len(rs) if rlen == 0 { rm[pkg] = ie{} continue } edeps := make([]string, 0, rlen) for opkg := range rs { edeps = append(edeps, opkg) } sort.Strings(edeps) sets := rm[pkg] sets.External = edeps rm[pkg] = sets } // Flatten inrsets into reachmap for pkg, rs := range inrsets { rlen := len(rs) if rlen == 0 { continue } ideps := make([]string, 0, rlen) for opkg := range rs { ideps = append(ideps, opkg) } sort.Strings(ideps) sets := rm[pkg] sets.Internal = ideps rm[pkg] = sets } return rm, errmap } // eqOrSlashedPrefix checks to see if the prefix is either equal to the string, // or that it is a prefix and the next char in the string is "/". func eqOrSlashedPrefix(s, prefix string) bool { if !strings.HasPrefix(s, prefix) { return false } prflen, pathlen := len(prefix), len(s) return prflen == pathlen || strings.Index(s[prflen:], "/") == 0 } // helper func to merge, dedupe, and sort strings func dedupeStrings(s1, s2 []string) (r []string) { dedupe := make(map[string]bool) if len(s1) > 0 && len(s2) > 0 { for _, i := range s1 { dedupe[i] = true } for _, i := range s2 { dedupe[i] = true } for i := range dedupe { r = append(r, i) } // And then re-sort them sort.Strings(r) } else if len(s1) > 0 { r = s1 } else if len(s2) > 0 { r = s2 } return } func uniq(a []string) []string { if a == nil { return make([]string, 0) } var s string var i int if !sort.StringsAreSorted(a) { sort.Strings(a) } for _, t := range a { if t != s { a[i] = t i++ s = t } } return a[:i] }
badrepo
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/badrepo/README.md
### Test Data This directory contains artifacts that represent malformed repo archives. Its purpose is to ensure `dep` can recover from such corrupted repositories in specific test scenarios. - `corrupt_dot_git_directory.tar`: is a repo with a corrupt `.git` directory. Dep can put a directory in such malformed state when a user hits `Ctrl+C` in the middle of a `dep init` process or others. `TestNewCtxRepoRecovery` uses this file to ensure recovery.
.go
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/dotgodir/.go/dot.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package dot // nothing to see here
foo.go
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/dotgodir/foo.go/foo.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package foo import "sort" var _ = sort.Strings // yes, this is dumb, don't use ".go" in your directory names // See https://github.com/golang/dep/issues/550 for more information
.m1p
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/dotgodir/.m1p/a.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package m1p import ( "sort" "github.com/golang/dep/gps" ) var ( _ = sort.Strings S = gps.Solve )
.m1p
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/dotgodir/.m1p/b.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package m1p import ( "os" "sort" ) var ( _ = sort.Strings _ = os.PathSeparator )
canonical
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/canonical/main.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package pkg // import "canonical" var ( A = "A" )
sub
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/canonical/sub/sub.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package sub // import "canonical/subpackage"
m1p
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/m1p/a.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package m1p import ( "sort" "github.com/golang/dep/gps" ) var ( _ = sort.Strings _ = gps.Solve )
m1p
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/m1p/b.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package m1p import ( "os" "sort" ) var ( _ = sort.Strings _ = os.PathSeparator )
t
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/t/t_test.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package simple import ( "math/rand" "strconv" ) var ( _ = rand.Int() _ = strconv.Unquote )
m1p
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/ren/m1p/a.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package m1p import ( "sort" "github.com/golang/dep/gps" ) var ( _ = sort.Strings _ = gps.Solve )
m1p
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/ren/m1p/b.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package m1p import ( "os" "sort" ) var ( _ = sort.Strings _ = os.PathSeparator )
simple
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/ren/simple/a.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package simple import ( "sort" "github.com/golang/dep/gps" ) var ( _ = sort.Strings _ = gps.Solve )
bad
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/bad/bad.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // This ill-formed Go source file is here to ensure the tool is robust // against bad packages in the workspace.
simplet
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/simplet/a.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package simple import ( "sort" "github.com/golang/dep/gps" ) var ( _ = sort.Strings _ = gps.Solve )
simplet
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/simplet/t_test.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package simple import ( "math/rand" "strconv" ) var ( _ = rand.Int() _ = strconv.Unquote )
slash-star_confl
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/slash-star_confl/a.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package canonical /* import "vanity1" */ var ( A = "A" )
slash-star_confl
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/slash-star_confl/b.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package canonical /* import "vanity2" */ var ( B = "B" )
disallow
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/disallow/a.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package disallow import ( "disallow/testdata" "sort" "github.com/golang/dep/gps" ) var ( _ = sort.Strings _ = gps.Solve _ = testdata.H )
testdata
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/disallow/testdata/another.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package testdata import "hash" var ( H = hash.Hash )
missing
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/missing/a.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package simple import ( "sort" "missing/missing" "github.com/golang/dep/gps" ) var ( _ = sort.Strings _ = gps.Solve _ = missing.Foo )
m1p
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/missing/m1p/a.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package m1p import ( "sort" "github.com/golang/dep/gps" ) var ( _ = sort.Strings _ = gps.Solve )
m1p
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/missing/m1p/b.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package m1p import ( "os" "sort" ) var ( _ = sort.Strings _ = os.PathSeparator )
nest
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/nest/a.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package simple import ( "sort" "github.com/golang/dep/gps" ) var ( _ = sort.Strings _ = gps.Solve )
m1p
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/nest/m1p/a.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package m1p import ( "sort" "github.com/golang/dep/gps" ) var ( _ = sort.Strings _ = gps.Solve )
m1p
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/nest/m1p/b.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package m1p import ( "os" "sort" ) var ( _ = sort.Strings _ = os.PathSeparator )
canon_confl
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/canon_confl/a.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package canonical // import "vanity1" var ( A = "A" )
canon_confl
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/canon_confl/b.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package canonical // import "vanity2" var ( B = "B" )
cycle
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/cycle/a.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package cycle import ( "cycle/one" "github.com/golang/dep/gps" ) var ( A = gps.Solve B = one.A )
two
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/cycle/two/a.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package two import ( "cycle" "github.com/golang/dep/gps" ) var ( A = gps.Solve B = cycle.A )
one
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/cycle/one/a.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package one import ( "cycle/two" "github.com/golang/dep/gps" ) var ( A = gps.Solve B = two.A )
varied_hidden
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/varied_hidden/locals.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main import ( _ "varied/_frommain" "varied/simple" ) var ( _ = simple.S )
varied_hidden
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/varied_hidden/main.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main import ( "net/http" ) var ( _ = http.Client )
always
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/varied_hidden/always/always_test.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package always import _ "varied/.onlyfromtests"
_frommain
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/varied_hidden/_frommain/a.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package frommain import ( "sort" "github.com/golang/dep/gps" ) var ( M = sort.Strings _ = gps.Solve )
.onlyfromtests
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/varied_hidden/.onlyfromtests/a.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package onlyfromtests import ( "sort" _ "varied/_secondorder" "github.com/golang/dep/gps" ) var ( M = sort.Strings _ = gps.Solve )
.onlyfromtests
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/varied_hidden/.onlyfromtests/b.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package onlyfromtests import ( "os" "sort" ) var ( _ = sort.Strings _ = os.PathSeparator )
_secondorder
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/varied_hidden/_secondorder/secondorder.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package secondorder import "hash" var ( H = hash.Hash )
dotdotslash
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/varied_hidden/dotdotslash/a.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package dotslash import ( "../github.com/golang/dep/gps" ) var ( A = gps.Solver )
simple
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/varied_hidden/simple/locals.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package simple import "varied/simple/testdata" var ( _ = testdata.H )
simple
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/varied_hidden/simple/simple.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package simple import ( "go/parser" "github.com/golang/dep/gps" ) var ( _ = parser.ParseFile S = gps.Prepare )
testdata
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/varied_hidden/simple/testdata/another.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package testdata import _ "varied/dotdotslash"
_never
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/varied_hidden/_never/a.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package never import ( "sort" "github.com/golang/dep/gps" ) var ( M = sort.Strings _ = gps.Solve )
buildtag
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/buildtag/invalid.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Hello // Not a valid +build ignore // No Really package buildtag import ( "sort" ) var ( _ = sort.Strings )
simplext
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/simplext/a.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package simple import ( "sort" "github.com/golang/dep/gps" ) var ( _ = sort.Strings _ = gps.Solve )
simplext
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/simplext/a_test.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package simple_test import ( "sort" "strconv" ) var ( _ = sort.Strings _ = strconv.Unquote )
igmainfirst
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/igmainfirst/igmain.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // +build ignore package main import "unicode" var _ = unicode.In
igmainfirst
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/igmainfirst/z.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package simple import ( "sort" "github.com/golang/dep/gps" ) var ( _ = sort.Strings _ = gps.Solve )
twopkgs
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/twopkgs/a.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package simple import ( "sort" "github.com/golang/dep/gps" ) var ( _ = sort.Strings _ = gps.Solve )
twopkgs
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/twopkgs/b.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package m1p import ( "os" "sort" ) var ( _ = sort.Strings _ = os.PathSeparator )
relimport
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/relimport/a.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package relimport import ( "sort" ) var ( A = sort.Strings )
dotslash
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/relimport/dotslash/a.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package dotslash import ( "./simple" ) var ( A = simple.A )
dot
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/relimport/dot/a.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package dot import ( "." "sort" ) var ( A = sort.Strings )
dotdot
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/relimport/dotdot/a.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package dotdot import ( relimport ".." ) var ( A = relimport.A )
dotdotslash
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/relimport/dotdotslash/a.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package dotslash import ( "../github.com/golang/dep/gps" ) var ( A = gps.Solver )
igmainlong
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/igmainlong/a.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package simple import ( "sort" "github.com/golang/dep/gps" ) var ( _ = sort.Strings _ = gps.Solve )
igmainlong
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/igmainlong/igmain.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Another comment, which the parser should ignore and still see builds tags // +build ignore package main import "unicode" var _ = unicode.In
varied
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/github.com/example/varied/locals.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main import ( "github.com/example/varied/namemismatch" "github.com/example/varied/otherpath" "github.com/example/varied/simple" ) var ( _ = simple.S _ = nm.V _ = otherpath.O )
varied
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/github.com/example/varied/main.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main import ( "net/http" ) var ( _ = http.Client )
m1p
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/github.com/example/varied/m1p/a.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package m1p import ( "sort" "github.com/golang/dep/gps" ) var ( M = sort.Strings _ = gps.Solve )
m1p
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/github.com/example/varied/m1p/b.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package m1p import ( "os" "sort" ) var ( _ = sort.Strings _ = os.PathSeparator )
namemismatch
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/github.com/example/varied/namemismatch/nm.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package nm import ( "os" "github.com/Masterminds/semver" ) var ( V = os.FileInfo _ = semver.Constraint )
simple
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/github.com/example/varied/simple/locals.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package simple import "github.com/example/varied/simple/another" var ( _ = another.H )
simple
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/github.com/example/varied/simple/simple.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package simple import ( "go/parser" "github.com/golang/dep/gps" ) var ( _ = parser.ParseFile S = gps.Prepare )
another
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/github.com/example/varied/simple/another/another_test.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package another import "encoding/binary" var ( _ = binary.PutVarint )
another
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/github.com/example/varied/simple/another/another.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package another import "hash" var ( H = hash.Hash )
another
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/github.com/example/varied/simple/another/locals.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package another import "github.com/example/varied/m1p" var _ = m1p.M
otherpath
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/github.com/example/varied/otherpath/otherpath_test.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package otherpath import "github.com/example/varied/m1p" var O = m1p.M
simple
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/simple/a.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package simple import ( "sort" "github.com/golang/dep/gps" ) var ( _ = sort.Strings _ = gps.Solve )
varied
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/varied/locals.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main import ( "varied/namemismatch" "varied/otherpath" "varied/simple" ) var ( _ = simple.S _ = nm.V _ = otherpath.O )
varied
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/varied/main.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main import ( "net/http" ) var ( _ = http.Client )
m1p
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/varied/m1p/a.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package m1p import ( "sort" "github.com/golang/dep/gps" ) var ( M = sort.Strings _ = gps.Solve )
m1p
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/varied/m1p/b.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package m1p import ( "os" "sort" ) var ( _ = sort.Strings _ = os.PathSeparator )
namemismatch
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/varied/namemismatch/nm.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package nm import ( "os" "github.com/Masterminds/semver" ) var ( V = os.FileInfo _ = semver.Constraint )
simple
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/varied/simple/locals.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package simple import "varied/simple/another" var ( _ = another.H )
simple
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/varied/simple/simple.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package simple import ( "go/parser" "github.com/golang/dep/gps" ) var ( _ = parser.ParseFile S = gps.Prepare )
another
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/varied/simple/another/another_test.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package another import "encoding/binary" var ( _ = binary.PutVarint )
another
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/varied/simple/another/another.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package another import "hash" var ( H = hash.Hash )
another
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/varied/simple/another/locals.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package another import "varied/m1p" var _ = m1p.M
otherpath
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/varied/otherpath/otherpath_test.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package otherpath import "varied/m1p" var O = m1p.M
xt
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/xt/a_test.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package simple_test import ( "sort" "strconv" ) var ( _ = sort.Strings _ = strconv.Unquote )
igmaint
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/igmaint/a.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package simple import ( "sort" "github.com/golang/dep/gps" ) var ( _ = sort.Strings _ = gps.Solve )
igmaint
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/igmaint/igmain.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // +build ignore package main import "unicode" var _ = unicode.In
igmaint
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/igmaint/t_test.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package simple import ( "math/rand" "strconv" ) var ( _ = rand.Int() _ = strconv.Unquote )
skip_
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/skip_/a.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package skip import ( "sort" "github.com/golang/dep/gps" ) var ( _ = sort.Strings _ = gps.Solve )
skip_
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/skip_/_a.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package skip import ( "bytes" "sort" ) var ( _ = sort.Strings _ = bytes.Buffer )
igmain
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/igmain/a.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package simple import ( "sort" "github.com/golang/dep/gps" ) var ( _ = sort.Strings _ = gps.Solve )
igmain
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/igmain/igmain.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // +build ignore package main import "unicode" var _ = unicode.In
doublenest
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/doublenest/a.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package base import ( "go/parser" "github.com/golang/dep/gps" ) var ( _ = parser.ParseFile _ = gps.Solve )
namemismatch
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/dep/gps/_testdata/src/doublenest/namemismatch/nm.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package nm import ( "os" "github.com/Masterminds/semver" ) var ( V = os.FileInfo _ = semver.Constraint )