diff --git a/projectgraph/cha.go b/projectgraph/cha.go index 0cfba62f..219483e8 100644 --- a/projectgraph/cha.go +++ b/projectgraph/cha.go @@ -66,6 +66,7 @@ func (b *builder) mro(class string) []string { return order } b.mros[class] = []string{class} + b.ordering++ var order []string if rec, ok := b.classes[class]; ok && profileOf(rec.ix.Language).c3 { order = b.c3(class) @@ -73,7 +74,9 @@ func (b *builder) mro(class string) []string { if order == nil { order = b.depthFirst(class, 0, map[string]bool{}) } + b.ordering-- b.mros[class] = order + b.memo(func() { delete(b.mros, class) }) return order } @@ -181,6 +184,7 @@ func (b *builder) externalBase(class string) (string, bool) { if !ok { base, _ = b.findExternalBase(class) b.externalBases[class] = base + b.memo(func() { delete(b.externalBases, class) }) } return base, base != "" } diff --git a/projectgraph/graph.go b/projectgraph/graph.go index aac7e573..cb561324 100644 --- a/projectgraph/graph.go +++ b/projectgraph/graph.go @@ -18,7 +18,7 @@ import ( // Version is the version of the link rules. Bump it when a rule that makes a // node, an edge, a root or an unresolved site changes, so a diff of two // reports shows the change. -const Version = "18" +const Version = "19" type NodeKind string diff --git a/projectgraph/link.go b/projectgraph/link.go index 4232e21c..cdc4c1a3 100644 --- a/projectgraph/link.go +++ b/projectgraph/link.go @@ -7,6 +7,7 @@ import ( "io/fs" "slices" "strings" + "sync/atomic" "time" "github.com/safedep/code/fileindex" @@ -78,6 +79,7 @@ func Build(ctx context.Context, indexes []*fileindex.Index, opts Options) (*Grap if err != nil { return nil, err } + defer context.AfterFunc(ctx, func() { b.stopped.Store(true) })() if err := b.linkAll(ctx); err != nil { return nil, err } @@ -85,6 +87,12 @@ func Build(ctx context.Context, indexes []*fileindex.Index, opts Options) (*Grap return nil, err } g := b.finish() + // A stop cuts the resolutions short, so the graph of a stopped build + // lacks edges and goes to no caller. finish resolves the external keys + // of the units, so the check comes after it. + if err := ctx.Err(); err != nil { + return nil, err + } g.Stats.Duration = time.Since(start) return g, nil } @@ -134,6 +142,20 @@ type builder struct { // walk of a unit reads now for the result type of an external key. reading map[string]bool stepping map[nameKey]bool + // expanding holds the scopes whose wildcard imports a resolution reads + // now, with the modules of the last whole pass. + expanding map[*scope]*wildcardRead + // stopped marks a build whose context ended. The walk and the reads of + // wildcard imports then end at once. A context check only between files + // lets the resolutions of one file run on past the budget of the caller, + // and a cycle of glob uses can keep them running for hours. + stopped atomic.Bool + // wildcardMods holds the modules of the wildcard imports of each scope + // whose read no cycle guard cut, as wildcardModules describes. asked + // holds the Rust paths that the read whose modules can go to the table + // asks the resolving guard for, and is nil with no such read. + wildcardMods map[*scope]*wildcardMods + asked map[[2]string]bool // unitTypes holds the type that a unit of dependency code gives for // each external key, or "". unitTypes map[string]string @@ -157,8 +179,14 @@ type builder struct { // files declare a package or a namespace. namespaces map[langcode.Code]*namespaces - mros map[string][]string - children map[string][]string + mros map[string][]string + // ordering counts the classes whose MRO a lookup reads now. A read of + // such a class gets the class alone. + ordering int + // tentative holds an undo step for each memo write made while a read + // of wildcard imports is in progress, as wildcardModules describes. + tentative []func() + children map[string][]string // aliases holds the definitions of each class that the language joins // to one class, the class too. aliases map[string][]string @@ -274,6 +302,7 @@ func newTables(indexes []*fileindex.Index, opts Options) *builder { defs: make(map[string]*fileindex.Definition, defs), reading: map[string]bool{}, stepping: map[nameKey]bool{}, + expanding: map[*scope]*wildcardRead{}, unitTypes: map[string]string{}, findingBases: map[string]bool{}, state: map[langcode.Code]any{}, @@ -346,10 +375,12 @@ func (b *builder) linkAll(ctx context.Context) error { } } // The classes are whole from here, so the members of a group of - // aliases can be one table. + // aliases can be one table. A read of the wildcard imports of a scope + // before this point can miss a class, so wildcardMods starts here. b.groupMembers = map[string]map[string]string{} b.groupRecords = map[string][]classRecord{} b.externalBases = map[string]string{} + b.wildcardMods = map[*scope]*wildcardMods{} for _, p := range b.paths { if err := ctx.Err(); err != nil { diff --git a/projectgraph/names.go b/projectgraph/names.go index d80b77c0..b8dc2e20 100644 --- a/projectgraph/names.go +++ b/projectgraph/names.go @@ -29,6 +29,7 @@ func (b *builder) resolveName(module, name string, hops int) (string, *failure) delete(b.visiting, k) if fail == nil || !fail.cut { b.names[k] = resolution{key: key, fail: fail} + b.memo(func() { delete(b.names, k) }) } return key, fail } @@ -223,6 +224,7 @@ func (b *builder) bound(key string) (string, bool) { return "", false } b.bindings[key] = target + b.memo(func() { delete(b.bindings, key) }) if b.g.Nodes[target] != nil { b.link(sc.ix.Language, key, target, b.siteOf(key), EdgeExport, ruleAlias) } diff --git a/projectgraph/resolve.go b/projectgraph/resolve.go index 7c2c60c0..96a64aee 100644 --- a/projectgraph/resolve.go +++ b/projectgraph/resolve.go @@ -472,16 +472,15 @@ func (b *builder) resolveScope(sc *scope, caller, target string) []resolution { } // wildcardImported returns the definitions of the name in the packages -// that the file imports with a Go dot import or a Java wildcard import, and -// the members of the name in the classes of a Java static wildcard import. +// that the file imports with a Go dot import, a Java wildcard import or a +// Rust glob use, and the members of the name in the classes of a Java +// static wildcard import. // A Java wildcard import of a package of the project names its class // exactly, so its edge is direct. func (b *builder) wildcardImported(sc *scope, name string) []string { var keys []string - for _, imp := range sc.wildcards { - mod, _, ok := b.resolveModule(sc.ix, imp.Module) + for _, mod := range b.wildcardModules(sc) { switch { - case !ok: case b.units[mod] != nil: keys = append(keys, b.units[mod].names[name]...) case b.isType(mod): @@ -493,6 +492,135 @@ func (b *builder) wildcardImported(sc *scope, name string) []string { return keys } +// wildcardRead is a read of the wildcard imports of a scope that a +// resolution makes now. mods holds the modules of the last whole pass, and +// read marks a pass whose resolutions read the same scope again. +type wildcardRead struct { + mods []string + read bool +} + +// wildcardMods holds the modules of the wildcard imports of a scope, and +// the Rust paths that the read of them asked the resolving guard for. +type wildcardMods struct { + mods []string + asked map[[2]string]bool +} + +// wildcardModules returns the modules of the wildcard imports of a scope, +// in the order of the imports. The resolution of a module can walk a unit +// whose name lookup reads the wildcard imports of the same scope, as the +// eight glob uses of src/sys.rs of time 0.1.45 do. If each such read +// resolved every import again, the work would grow with the orders of the +// imports, and the link step of a project with that file would not end. +// +// So a read of a scope that a resolution reads now gets the modules of the +// last whole pass, and the passes repeat until the modules stay the same. +// A module that only an import after it brings into scope thus resolves. +// A memo that a pass writes from the modules of the last pass can lack a +// module for the whole build. The MRO of a class whose base only the next +// pass brings into scope is such a memo, and a call of a method of the base +// then gets no edge. So a pass whose modules change undoes its memo writes. +// +// A cycle guard that an outer resolution holds can cut a read short. +// app/src/prelude.rs has pub use core_lib::*, and the resolution of that +// path reads the glob use again under its own resolving guard. A table +// that kept that list gave no module for the whole build, and a target +// under the crate read not-found. So the table keeps and gives a list only +// where uncut holds, and any other read resolves the imports again. +// +// A cycle of wildcard imports across files still costs time that grows +// with the number of files. A file that each other file of the cycle reads +// with a glob use of a name that no file defines is such a cycle. +func (b *builder) wildcardModules(sc *scope) []string { + if b.stopped.Load() { + return nil + } + if r := b.expanding[sc]; r != nil { + r.read = true + return r.mods + } + if w := b.wildcardMods[sc]; w != nil && b.uncut(w.asked) { + return w.mods + } + // A read inside another read adds the paths that it asks for to the + // record of the outer one. + outer := b.wildcardMods != nil && b.asked == nil + if outer { + b.asked = map[[2]string]bool{} + } + r := &wildcardRead{} + b.expanding[sc] = r + for range len(sc.wildcards) + 1 { + r.read = false + mark := len(b.tentative) + var mods []string + for _, imp := range sc.wildcards { + if mod, _, ok := b.resolveModule(sc.ix, imp.Module); ok { + mods = append(mods, mod) + } + } + same := slices.Equal(mods, r.mods) + r.mods = mods + if !r.read || same { + break + } + b.undo(mark) + } + delete(b.expanding, sc) + if len(b.expanding) == 0 { + clear(b.tentative) + b.tentative = b.tentative[:0] + } + if outer { + if b.uncut(b.asked) { + b.wildcardMods[sc] = &wildcardMods{mods: r.mods, asked: b.asked} + } + b.asked = nil + } + return r.mods +} + +// memo logs the undo step of a memo write while a read of wildcard imports +// is in progress. +func (b *builder) memo(undo func()) { + if len(b.expanding) > 0 { + b.tentative = append(b.tentative, undo) + } +} + +// undo reverts the memo writes after the mark, newest first. +func (b *builder) undo(mark int) { + for i := len(b.tentative) - 1; i >= mark; i-- { + b.tentative[i]() + } + clear(b.tentative[mark:]) + b.tentative = b.tentative[:mark] +} + +// uncut reports whether a read of the wildcard imports of a scope that +// asks the resolving guard for the paths gets no answer from a resolution +// in progress. Such a read gives the same modules each time. The guards +// are set and cleared in the order of a stack. So at the end of a read, a +// path in progress was set before the read, and the guard cut the read if +// the read asked for it. +// +// uncut compares the paths of the resolving guard only. On the Rust +// corpus, the reads under any other guard cost less than 3% of the read +// time. So any other state in progress fails the check. +func (b *builder) uncut(asked map[[2]string]bool) bool { + s := b.rustState() + if len(b.expanding)+len(b.visiting)+len(b.reading)+len(b.stepping)+len(b.findingBases)+len(s.routing)+b.ordering > 0 { + return false + } + for k := range s.resolving { + if asked[k] { + return false + } + } + return true +} + // superKeyword is the receiver of a call of a method of the base class, as // super().load() in Python and super.load() in JavaScript. A bare call of it // in JavaScript calls the constructor of the base class. diff --git a/projectgraph/rust.go b/projectgraph/rust.go index 9047eaed..786d07f8 100644 --- a/projectgraph/rust.go +++ b/projectgraph/rust.go @@ -448,6 +448,9 @@ func joinPath(module string, parts []string) string { func (b *builder) resolveRust(importer, written string) (string, bool) { s := b.rustState() k := [2]string{importer, written} + if b.asked != nil { + b.asked[k] = true + } if s.resolving[k] { return "", false } diff --git a/projectgraph/testdata/javascript/barrel-chain/graph.golden.json b/projectgraph/testdata/javascript/barrel-chain/graph.golden.json index 865bbc47..a4e90ffe 100644 --- a/projectgraph/testdata/javascript/barrel-chain/graph.golden.json +++ b/projectgraph/testdata/javascript/barrel-chain/graph.golden.json @@ -178,7 +178,7 @@ "src/main.js": "indexed" }, "stats": { - "version": "18", + "version": "19", "files": 4, "nodes": 7, "edges": 6, diff --git a/projectgraph/testdata/javascript/commonjs-require/graph.golden.json b/projectgraph/testdata/javascript/commonjs-require/graph.golden.json index 505db74a..8836aa06 100644 --- a/projectgraph/testdata/javascript/commonjs-require/graph.golden.json +++ b/projectgraph/testdata/javascript/commonjs-require/graph.golden.json @@ -141,7 +141,7 @@ "main.js": "indexed" }, "stats": { - "version": "18", + "version": "19", "files": 3, "nodes": 5, "edges": 4, diff --git a/projectgraph/testdata/javascript/default-import/graph.golden.json b/projectgraph/testdata/javascript/default-import/graph.golden.json index 8778c03b..15e7c262 100644 --- a/projectgraph/testdata/javascript/default-import/graph.golden.json +++ b/projectgraph/testdata/javascript/default-import/graph.golden.json @@ -141,7 +141,7 @@ "make.js": "indexed" }, "stats": { - "version": "18", + "version": "19", "files": 3, "nodes": 5, "edges": 4, diff --git a/projectgraph/testdata/javascript/esm-named-import/graph.golden.json b/projectgraph/testdata/javascript/esm-named-import/graph.golden.json index 0b8d3473..20ecfee1 100644 --- a/projectgraph/testdata/javascript/esm-named-import/graph.golden.json +++ b/projectgraph/testdata/javascript/esm-named-import/graph.golden.json @@ -169,7 +169,7 @@ "src/util.js": "indexed" }, "stats": { - "version": "18", + "version": "19", "files": 3, "nodes": 6, "edges": 5, diff --git a/projectgraph/testdata/javascript/export-star/graph.golden.json b/projectgraph/testdata/javascript/export-star/graph.golden.json index eeb6e5e1..67c4e5c3 100644 --- a/projectgraph/testdata/javascript/export-star/graph.golden.json +++ b/projectgraph/testdata/javascript/export-star/graph.golden.json @@ -281,7 +281,7 @@ "main.js": "indexed" }, "stats": { - "version": "18", + "version": "19", "files": 5, "nodes": 11, "edges": 10, diff --git a/projectgraph/testdata/javascript/exports-conditions/graph.golden.json b/projectgraph/testdata/javascript/exports-conditions/graph.golden.json index 7f9522d1..f78a5bde 100644 --- a/projectgraph/testdata/javascript/exports-conditions/graph.golden.json +++ b/projectgraph/testdata/javascript/exports-conditions/graph.golden.json @@ -148,7 +148,7 @@ "lib/src/feature/y.js": "indexed" }, "stats": { - "version": "18", + "version": "19", "files": 4, "nodes": 7, "edges": 4, diff --git a/projectgraph/testdata/javascript/unknown-receiver/graph.golden.json b/projectgraph/testdata/javascript/unknown-receiver/graph.golden.json index 769f397f..fdb2512d 100644 --- a/projectgraph/testdata/javascript/unknown-receiver/graph.golden.json +++ b/projectgraph/testdata/javascript/unknown-receiver/graph.golden.json @@ -125,7 +125,7 @@ "main.js": "indexed" }, "stats": { - "version": "18", + "version": "19", "files": 1, "nodes": 5, "edges": 3, diff --git a/projectgraph/testdata/javascript/workspaces/graph.golden.json b/projectgraph/testdata/javascript/workspaces/graph.golden.json index 38a159e4..67a6463f 100644 --- a/projectgraph/testdata/javascript/workspaces/graph.golden.json +++ b/projectgraph/testdata/javascript/workspaces/graph.golden.json @@ -130,7 +130,7 @@ "packages/core/util.js": "indexed" }, "stats": { - "version": "18", + "version": "19", "files": 3, "nodes": 6, "edges": 5, diff --git a/projectgraph/testdata/python/all-hides/graph.golden.json b/projectgraph/testdata/python/all-hides/graph.golden.json index 54549440..1734e12b 100644 --- a/projectgraph/testdata/python/all-hides/graph.golden.json +++ b/projectgraph/testdata/python/all-hides/graph.golden.json @@ -177,7 +177,7 @@ "pkg/a.py": "indexed" }, "stats": { - "version": "18", + "version": "19", "files": 3, "nodes": 7, "edges": 6, diff --git a/projectgraph/testdata/python/assignment/graph.golden.json b/projectgraph/testdata/python/assignment/graph.golden.json index 1036affb..1578e2a6 100644 --- a/projectgraph/testdata/python/assignment/graph.golden.json +++ b/projectgraph/testdata/python/assignment/graph.golden.json @@ -71,7 +71,7 @@ "main.py": "indexed" }, "stats": { - "version": "18", + "version": "19", "files": 1, "nodes": 3, "edges": 2, diff --git a/projectgraph/testdata/python/class-body/graph.golden.json b/projectgraph/testdata/python/class-body/graph.golden.json index 7b4cf804..47bbcdc2 100644 --- a/projectgraph/testdata/python/class-body/graph.golden.json +++ b/projectgraph/testdata/python/class-body/graph.golden.json @@ -225,7 +225,7 @@ "config.py": "indexed" }, "stats": { - "version": "18", + "version": "19", "files": 1, "nodes": 12, "edges": 7, diff --git a/projectgraph/testdata/python/decorators/graph.golden.json b/projectgraph/testdata/python/decorators/graph.golden.json index aeeb6bc2..2548a8f2 100644 --- a/projectgraph/testdata/python/decorators/graph.golden.json +++ b/projectgraph/testdata/python/decorators/graph.golden.json @@ -195,7 +195,7 @@ "app.py": "indexed" }, "stats": { - "version": "18", + "version": "19", "files": 1, "nodes": 9, "edges": 5, diff --git a/projectgraph/testdata/python/external/graph.golden.json b/projectgraph/testdata/python/external/graph.golden.json index 9bd2b241..09ebfb11 100644 --- a/projectgraph/testdata/python/external/graph.golden.json +++ b/projectgraph/testdata/python/external/graph.golden.json @@ -109,7 +109,7 @@ "main.py": "indexed" }, "stats": { - "version": "18", + "version": "19", "files": 1, "nodes": 5, "edges": 3, diff --git a/projectgraph/testdata/python/local-receiver/graph.golden.json b/projectgraph/testdata/python/local-receiver/graph.golden.json index 2e904a4f..53d28704 100644 --- a/projectgraph/testdata/python/local-receiver/graph.golden.json +++ b/projectgraph/testdata/python/local-receiver/graph.golden.json @@ -146,7 +146,7 @@ "main.py": "indexed" }, "stats": { - "version": "18", + "version": "19", "files": 1, "nodes": 5, "edges": 3, diff --git a/projectgraph/testdata/python/member-call/graph.golden.json b/projectgraph/testdata/python/member-call/graph.golden.json index d33e98aa..ba99aec7 100644 --- a/projectgraph/testdata/python/member-call/graph.golden.json +++ b/projectgraph/testdata/python/member-call/graph.golden.json @@ -261,7 +261,7 @@ "parser.py": "indexed" }, "stats": { - "version": "18", + "version": "19", "files": 3, "nodes": 9, "edges": 10, diff --git a/projectgraph/testdata/python/missing-file/graph.golden.json b/projectgraph/testdata/python/missing-file/graph.golden.json index dc98a83c..655943b8 100644 --- a/projectgraph/testdata/python/missing-file/graph.golden.json +++ b/projectgraph/testdata/python/missing-file/graph.golden.json @@ -56,7 +56,7 @@ "main.py": "cached" }, "stats": { - "version": "18", + "version": "19", "files": 2, "nodes": 2, "edges": 2, diff --git a/projectgraph/testdata/python/package-init/graph.golden.json b/projectgraph/testdata/python/package-init/graph.golden.json index 6739ceea..79cd482e 100644 --- a/projectgraph/testdata/python/package-init/graph.golden.json +++ b/projectgraph/testdata/python/package-init/graph.golden.json @@ -147,7 +147,7 @@ "pkg/loader.py": "indexed" }, "stats": { - "version": "18", + "version": "19", "files": 3, "nodes": 6, "edges": 5, diff --git a/projectgraph/testdata/python/reexport-cycle/graph.golden.json b/projectgraph/testdata/python/reexport-cycle/graph.golden.json index 402dc9f1..940e627c 100644 --- a/projectgraph/testdata/python/reexport-cycle/graph.golden.json +++ b/projectgraph/testdata/python/reexport-cycle/graph.golden.json @@ -108,7 +108,7 @@ "main.py": "indexed" }, "stats": { - "version": "18", + "version": "19", "files": 3, "nodes": 3, "edges": 3, diff --git a/projectgraph/testdata/python/relative-imports/graph.golden.json b/projectgraph/testdata/python/relative-imports/graph.golden.json index ff016eb1..11e53ed3 100644 --- a/projectgraph/testdata/python/relative-imports/graph.golden.json +++ b/projectgraph/testdata/python/relative-imports/graph.golden.json @@ -157,7 +157,7 @@ "pkg/sub/b.py": "indexed" }, "stats": { - "version": "18", + "version": "19", "files": 3, "nodes": 6, "edges": 4, diff --git a/projectgraph/testdata/python/sibling-import/graph.golden.json b/projectgraph/testdata/python/sibling-import/graph.golden.json index 22296c2b..63d16527 100644 --- a/projectgraph/testdata/python/sibling-import/graph.golden.json +++ b/projectgraph/testdata/python/sibling-import/graph.golden.json @@ -100,7 +100,7 @@ "main.py": "indexed" }, "stats": { - "version": "18", + "version": "19", "files": 2, "nodes": 4, "edges": 3, diff --git a/projectgraph/testdata/python/src-layout/graph.golden.json b/projectgraph/testdata/python/src-layout/graph.golden.json index 426b2304..7373e1be 100644 --- a/projectgraph/testdata/python/src-layout/graph.golden.json +++ b/projectgraph/testdata/python/src-layout/graph.golden.json @@ -102,7 +102,7 @@ "services/api/src/api/core.py": "indexed" }, "stats": { - "version": "18", + "version": "19", "files": 3, "nodes": 4, "edges": 2, diff --git a/projectgraph/testdata/python/sys-path/graph.golden.json b/projectgraph/testdata/python/sys-path/graph.golden.json index 15cfe389..de34821d 100644 --- a/projectgraph/testdata/python/sys-path/graph.golden.json +++ b/projectgraph/testdata/python/sys-path/graph.golden.json @@ -84,7 +84,7 @@ "lib/shared.py": "indexed" }, "stats": { - "version": "18", + "version": "19", "files": 2, "nodes": 3, "edges": 2, diff --git a/projectgraph/testdata/python/wildcard/graph.golden.json b/projectgraph/testdata/python/wildcard/graph.golden.json index a163f008..d7824985 100644 --- a/projectgraph/testdata/python/wildcard/graph.golden.json +++ b/projectgraph/testdata/python/wildcard/graph.golden.json @@ -114,7 +114,7 @@ "util.py": "indexed" }, "stats": { - "version": "18", + "version": "19", "files": 2, "nodes": 4, "edges": 3, diff --git a/projectgraph/testdata/roots/extra-rules/graph.golden.json b/projectgraph/testdata/roots/extra-rules/graph.golden.json index 7f7b79fe..e4e11268 100644 --- a/projectgraph/testdata/roots/extra-rules/graph.golden.json +++ b/projectgraph/testdata/roots/extra-rules/graph.golden.json @@ -108,7 +108,7 @@ "views.py": "indexed" }, "stats": { - "version": "18", + "version": "19", "files": 3, "nodes": 7, "edges": 0, diff --git a/projectgraph/testdata/roots/library-surface/graph.golden.json b/projectgraph/testdata/roots/library-surface/graph.golden.json index da844439..8a6ac8b6 100644 --- a/projectgraph/testdata/roots/library-surface/graph.golden.json +++ b/projectgraph/testdata/roots/library-surface/graph.golden.json @@ -84,7 +84,7 @@ "lib/test_api.py": "indexed" }, "stats": { - "version": "18", + "version": "19", "files": 2, "nodes": 5, "edges": 0, diff --git a/projectgraph/testdata/roots/main-guard/graph.golden.json b/projectgraph/testdata/roots/main-guard/graph.golden.json index 0fc5c998..0673501b 100644 --- a/projectgraph/testdata/roots/main-guard/graph.golden.json +++ b/projectgraph/testdata/roots/main-guard/graph.golden.json @@ -62,7 +62,7 @@ "lib.py": "indexed" }, "stats": { - "version": "18", + "version": "19", "files": 2, "nodes": 4, "edges": 1, diff --git a/projectgraph/testdata/roots/package-json-bin/graph.golden.json b/projectgraph/testdata/roots/package-json-bin/graph.golden.json index 1859dd4b..f2c54528 100644 --- a/projectgraph/testdata/roots/package-json-bin/graph.golden.json +++ b/projectgraph/testdata/roots/package-json-bin/graph.golden.json @@ -66,7 +66,7 @@ "lib/run.js": "indexed" }, "stats": { - "version": "18", + "version": "19", "files": 2, "nodes": 3, "edges": 2, diff --git a/projectgraph/testdata/roots/package-json-main/graph.golden.json b/projectgraph/testdata/roots/package-json-main/graph.golden.json index 4ab3c13a..da558b55 100644 --- a/projectgraph/testdata/roots/package-json-main/graph.golden.json +++ b/projectgraph/testdata/roots/package-json-main/graph.golden.json @@ -158,7 +158,7 @@ "parser.js": "indexed" }, "stats": { - "version": "18", + "version": "19", "files": 4, "nodes": 9, "edges": 3, diff --git a/projectgraph/testdata/roots/procfile-dockerfile/graph.golden.json b/projectgraph/testdata/roots/procfile-dockerfile/graph.golden.json index 210bb426..0dc095cf 100644 --- a/projectgraph/testdata/roots/procfile-dockerfile/graph.golden.json +++ b/projectgraph/testdata/roots/procfile-dockerfile/graph.golden.json @@ -114,7 +114,7 @@ "worker.py": "indexed" }, "stats": { - "version": "18", + "version": "19", "files": 6, "nodes": 7, "edges": 0, diff --git a/projectgraph/testdata/roots/pyproject-scripts/graph.golden.json b/projectgraph/testdata/roots/pyproject-scripts/graph.golden.json index a799a608..f26e273c 100644 --- a/projectgraph/testdata/roots/pyproject-scripts/graph.golden.json +++ b/projectgraph/testdata/roots/pyproject-scripts/graph.golden.json @@ -151,7 +151,7 @@ "src/app/tool.py": "indexed" }, "stats": { - "version": "18", + "version": "19", "files": 5, "nodes": 10, "edges": 0, diff --git a/projectgraph/testdata/roots/setup-py/graph.golden.json b/projectgraph/testdata/roots/setup-py/graph.golden.json index 0ad976ef..54508411 100644 --- a/projectgraph/testdata/roots/setup-py/graph.golden.json +++ b/projectgraph/testdata/roots/setup-py/graph.golden.json @@ -76,7 +76,7 @@ "tool/main.py": "indexed" }, "stats": { - "version": "18", + "version": "19", "files": 2, "nodes": 4, "edges": 0, diff --git a/projectgraph/testdata/roots/test-file/graph.golden.json b/projectgraph/testdata/roots/test-file/graph.golden.json index d355f567..9456863f 100644 --- a/projectgraph/testdata/roots/test-file/graph.golden.json +++ b/projectgraph/testdata/roots/test-file/graph.golden.json @@ -69,7 +69,7 @@ "tests/test_app.py": "indexed" }, "stats": { - "version": "18", + "version": "19", "files": 1, "nodes": 4, "edges": 0, diff --git a/projectgraph/testdata/typescript/js-specifier/graph.golden.json b/projectgraph/testdata/typescript/js-specifier/graph.golden.json index 22cb2426..de92b13e 100644 --- a/projectgraph/testdata/typescript/js-specifier/graph.golden.json +++ b/projectgraph/testdata/typescript/js-specifier/graph.golden.json @@ -84,7 +84,7 @@ "src/util.ts": "indexed" }, "stats": { - "version": "18", + "version": "19", "files": 2, "nodes": 3, "edges": 2, diff --git a/projectgraph/testdata/typescript/tsconfig-paths/graph.golden.json b/projectgraph/testdata/typescript/tsconfig-paths/graph.golden.json index c1e90122..41601674 100644 --- a/projectgraph/testdata/typescript/tsconfig-paths/graph.golden.json +++ b/projectgraph/testdata/typescript/tsconfig-paths/graph.golden.json @@ -141,7 +141,7 @@ "src/main.ts": "indexed" }, "stats": { - "version": "18", + "version": "19", "files": 3, "nodes": 5, "edges": 4, diff --git a/projectgraph/testdata/typescript/type-only/graph.golden.json b/projectgraph/testdata/typescript/type-only/graph.golden.json index a0be7328..2b8a3af9 100644 --- a/projectgraph/testdata/typescript/type-only/graph.golden.json +++ b/projectgraph/testdata/typescript/type-only/graph.golden.json @@ -100,7 +100,7 @@ "src/types.ts": "indexed" }, "stats": { - "version": "18", + "version": "19", "files": 3, "nodes": 5, "edges": 2, diff --git a/projectgraph/walk.go b/projectgraph/walk.go index 0d29fd49..46e4bf69 100644 --- a/projectgraph/walk.go +++ b/projectgraph/walk.go @@ -57,6 +57,9 @@ func (b *builder) walkFrom(r resolution, names []string) resolution { instance := r.virtual for i := 0; i < len(names); { name := names[i] + if b.stopped.Load() { + return resolution{fail: &failure{reason: fileindex.UnresolvedLimit, name: name, cut: true}} + } var consumed, done bool switch kind := b.kindOf(r.key); { case b.units[r.key] != nil: diff --git a/test/projectgraph/cases/go/dependency-build-files/summaries/go_github.com_acme_kit_v1.0.0.json b/test/projectgraph/cases/go/dependency-build-files/summaries/go_github.com_acme_kit_v1.0.0.json index d887082e..b87df19c 100644 --- a/test/projectgraph/cases/go/dependency-build-files/summaries/go_github.com_acme_kit_v1.0.0.json +++ b/test/projectgraph/cases/go/dependency-build-files/summaries/go_github.com_acme_kit_v1.0.0.json @@ -1,7 +1,7 @@ { "version": "3", "index_version": "16", - "link_version": "18", + "link_version": "19", "unit": "go:github.com/acme/kit@v1.0.0", "symbols": [ { diff --git a/test/projectgraph/cases/go/dependency-callback/summaries/go_github.com_acme_srv_v1.0.0.json b/test/projectgraph/cases/go/dependency-callback/summaries/go_github.com_acme_srv_v1.0.0.json index b9294936..fe5ebda6 100644 --- a/test/projectgraph/cases/go/dependency-callback/summaries/go_github.com_acme_srv_v1.0.0.json +++ b/test/projectgraph/cases/go/dependency-callback/summaries/go_github.com_acme_srv_v1.0.0.json @@ -1,7 +1,7 @@ { "version": "3", "index_version": "16", - "link_version": "18", + "link_version": "19", "unit": "go:github.com/acme/srv@v1.0.0", "symbols": [ { diff --git a/test/projectgraph/cases/go/dependency-data-reads/summaries/go_example.com_markup_v1.0.0.json b/test/projectgraph/cases/go/dependency-data-reads/summaries/go_example.com_markup_v1.0.0.json index bb22ae07..3367ae13 100644 --- a/test/projectgraph/cases/go/dependency-data-reads/summaries/go_example.com_markup_v1.0.0.json +++ b/test/projectgraph/cases/go/dependency-data-reads/summaries/go_example.com_markup_v1.0.0.json @@ -1,7 +1,7 @@ { "version": "3", "index_version": "16", - "link_version": "18", + "link_version": "19", "unit": "go:example.com/markup@v1.0.0", "symbols": [ { diff --git a/test/projectgraph/cases/go/dependency-data-reads/summaries/go_std_go1.25.1.json b/test/projectgraph/cases/go/dependency-data-reads/summaries/go_std_go1.25.1.json index 7c352d86..12040ab2 100644 --- a/test/projectgraph/cases/go/dependency-data-reads/summaries/go_std_go1.25.1.json +++ b/test/projectgraph/cases/go/dependency-data-reads/summaries/go_std_go1.25.1.json @@ -1,7 +1,7 @@ { "version": "3", "index_version": "16", - "link_version": "18", + "link_version": "19", "unit": "go:std@go1.25.1", "symbols": [ { diff --git a/test/projectgraph/cases/go/dependency-failed-callback/summaries/go_github.com_acme_srv_v1.0.0.json b/test/projectgraph/cases/go/dependency-failed-callback/summaries/go_github.com_acme_srv_v1.0.0.json index 45cfa721..d7ea90bb 100644 --- a/test/projectgraph/cases/go/dependency-failed-callback/summaries/go_github.com_acme_srv_v1.0.0.json +++ b/test/projectgraph/cases/go/dependency-failed-callback/summaries/go_github.com_acme_srv_v1.0.0.json @@ -1,7 +1,7 @@ { "version": "3", "index_version": "16", - "link_version": "18", + "link_version": "19", "unit": "go:github.com/acme/srv@v1.0.0", "symbols": [ { diff --git a/test/projectgraph/cases/go/dependency-function-table/summaries/go_github.com_acme_a_v1.0.0.json b/test/projectgraph/cases/go/dependency-function-table/summaries/go_github.com_acme_a_v1.0.0.json index f8674b04..da9cc6d1 100644 --- a/test/projectgraph/cases/go/dependency-function-table/summaries/go_github.com_acme_a_v1.0.0.json +++ b/test/projectgraph/cases/go/dependency-function-table/summaries/go_github.com_acme_a_v1.0.0.json @@ -1,7 +1,7 @@ { "version": "3", "index_version": "16", - "link_version": "18", + "link_version": "19", "unit": "go:github.com/acme/a@v1.0.0", "symbols": [ { diff --git a/test/projectgraph/cases/go/dependency-function-table/summaries/go_github.com_acme_b_v1.0.0.json b/test/projectgraph/cases/go/dependency-function-table/summaries/go_github.com_acme_b_v1.0.0.json index be8b4d52..84bf2d3d 100644 --- a/test/projectgraph/cases/go/dependency-function-table/summaries/go_github.com_acme_b_v1.0.0.json +++ b/test/projectgraph/cases/go/dependency-function-table/summaries/go_github.com_acme_b_v1.0.0.json @@ -1,7 +1,7 @@ { "version": "3", "index_version": "16", - "link_version": "18", + "link_version": "19", "unit": "go:github.com/acme/b@v1.0.0", "symbols": [ { diff --git a/test/projectgraph/cases/go/dependency-generated-code/summaries/go_github.com_acme_kit_v1.0.0.json b/test/projectgraph/cases/go/dependency-generated-code/summaries/go_github.com_acme_kit_v1.0.0.json index 522906e2..989ceb3e 100644 --- a/test/projectgraph/cases/go/dependency-generated-code/summaries/go_github.com_acme_kit_v1.0.0.json +++ b/test/projectgraph/cases/go/dependency-generated-code/summaries/go_github.com_acme_kit_v1.0.0.json @@ -1,7 +1,7 @@ { "version": "3", "index_version": "16", - "link_version": "18", + "link_version": "19", "unit": "go:github.com/acme/kit@v1.0.0", "symbols": [ { diff --git a/test/projectgraph/cases/go/dependency-generated-table/summaries/go_github.com_acme_kit_v1.0.0.json b/test/projectgraph/cases/go/dependency-generated-table/summaries/go_github.com_acme_kit_v1.0.0.json index acd42af3..69e5a026 100644 --- a/test/projectgraph/cases/go/dependency-generated-table/summaries/go_github.com_acme_kit_v1.0.0.json +++ b/test/projectgraph/cases/go/dependency-generated-table/summaries/go_github.com_acme_kit_v1.0.0.json @@ -1,7 +1,7 @@ { "version": "3", "index_version": "16", - "link_version": "18", + "link_version": "19", "unit": "go:github.com/acme/kit@v1.0.0", "symbols": [ { diff --git a/test/projectgraph/cases/go/dependency-implements-interface/summaries/go_github.com_acme_dep_v1.0.0.json b/test/projectgraph/cases/go/dependency-implements-interface/summaries/go_github.com_acme_dep_v1.0.0.json index ddf7042e..9048c967 100644 --- a/test/projectgraph/cases/go/dependency-implements-interface/summaries/go_github.com_acme_dep_v1.0.0.json +++ b/test/projectgraph/cases/go/dependency-implements-interface/summaries/go_github.com_acme_dep_v1.0.0.json @@ -1,7 +1,7 @@ { "version": "3", "index_version": "16", - "link_version": "18", + "link_version": "19", "unit": "go:github.com/acme/dep@v1.0.0", "symbols": [ { diff --git a/test/projectgraph/cases/go/dependency-internal-call/summaries/go_github.com_acme_kit_v1.0.0.json b/test/projectgraph/cases/go/dependency-internal-call/summaries/go_github.com_acme_kit_v1.0.0.json index 50b88ae8..b4d95adb 100644 --- a/test/projectgraph/cases/go/dependency-internal-call/summaries/go_github.com_acme_kit_v1.0.0.json +++ b/test/projectgraph/cases/go/dependency-internal-call/summaries/go_github.com_acme_kit_v1.0.0.json @@ -1,7 +1,7 @@ { "version": "3", "index_version": "16", - "link_version": "18", + "link_version": "19", "unit": "go:github.com/acme/kit@v1.0.0", "symbols": [ { diff --git a/test/projectgraph/cases/go/dependency-internal-package/summaries/go_github.com_acme_kit_v1.0.0.json b/test/projectgraph/cases/go/dependency-internal-package/summaries/go_github.com_acme_kit_v1.0.0.json index 3e6c48d2..f2135c1e 100644 --- a/test/projectgraph/cases/go/dependency-internal-package/summaries/go_github.com_acme_kit_v1.0.0.json +++ b/test/projectgraph/cases/go/dependency-internal-package/summaries/go_github.com_acme_kit_v1.0.0.json @@ -1,7 +1,7 @@ { "version": "3", "index_version": "16", - "link_version": "18", + "link_version": "19", "unit": "go:github.com/acme/kit@v1.0.0", "symbols": [ { diff --git a/test/projectgraph/cases/go/dependency-module/summaries/go_github.com_acme_yamlish_v1.2.0.json b/test/projectgraph/cases/go/dependency-module/summaries/go_github.com_acme_yamlish_v1.2.0.json index e285c37d..b8911ade 100644 --- a/test/projectgraph/cases/go/dependency-module/summaries/go_github.com_acme_yamlish_v1.2.0.json +++ b/test/projectgraph/cases/go/dependency-module/summaries/go_github.com_acme_yamlish_v1.2.0.json @@ -1,7 +1,7 @@ { "version": "3", "index_version": "16", - "link_version": "18", + "link_version": "19", "unit": "go:github.com/acme/yamlish@v1.2.0", "symbols": [ { diff --git a/test/projectgraph/cases/go/dependency-no-unit/summaries/go_github.com_acme_kit_v1.0.0.json b/test/projectgraph/cases/go/dependency-no-unit/summaries/go_github.com_acme_kit_v1.0.0.json index aaa90ac4..222bc432 100644 --- a/test/projectgraph/cases/go/dependency-no-unit/summaries/go_github.com_acme_kit_v1.0.0.json +++ b/test/projectgraph/cases/go/dependency-no-unit/summaries/go_github.com_acme_kit_v1.0.0.json @@ -1,7 +1,7 @@ { "version": "3", "index_version": "16", - "link_version": "18", + "link_version": "19", "unit": "go:github.com/acme/kit@v1.0.0", "symbols": [ { diff --git a/test/projectgraph/cases/go/dependency-platform-files/summaries/go_github.com_acme_kit_v1.0.0.json b/test/projectgraph/cases/go/dependency-platform-files/summaries/go_github.com_acme_kit_v1.0.0.json index 522906e2..989ceb3e 100644 --- a/test/projectgraph/cases/go/dependency-platform-files/summaries/go_github.com_acme_kit_v1.0.0.json +++ b/test/projectgraph/cases/go/dependency-platform-files/summaries/go_github.com_acme_kit_v1.0.0.json @@ -1,7 +1,7 @@ { "version": "3", "index_version": "16", - "link_version": "18", + "link_version": "19", "unit": "go:github.com/acme/kit@v1.0.0", "symbols": [ { diff --git a/test/projectgraph/cases/go/dependency-platform-results/summaries/go_github.com_acme_kit_v1.0.0.json b/test/projectgraph/cases/go/dependency-platform-results/summaries/go_github.com_acme_kit_v1.0.0.json index d77e0b19..4504b1f5 100644 --- a/test/projectgraph/cases/go/dependency-platform-results/summaries/go_github.com_acme_kit_v1.0.0.json +++ b/test/projectgraph/cases/go/dependency-platform-results/summaries/go_github.com_acme_kit_v1.0.0.json @@ -1,7 +1,7 @@ { "version": "3", "index_version": "16", - "link_version": "18", + "link_version": "19", "unit": "go:github.com/acme/kit@v1.0.0", "symbols": [ { diff --git a/test/projectgraph/cases/go/dependency-result-types/summaries/go_example.com_markup_v1.0.0.json b/test/projectgraph/cases/go/dependency-result-types/summaries/go_example.com_markup_v1.0.0.json index 6e5f7d2e..f2a787c6 100644 --- a/test/projectgraph/cases/go/dependency-result-types/summaries/go_example.com_markup_v1.0.0.json +++ b/test/projectgraph/cases/go/dependency-result-types/summaries/go_example.com_markup_v1.0.0.json @@ -1,7 +1,7 @@ { "version": "3", "index_version": "16", - "link_version": "18", + "link_version": "19", "unit": "go:example.com/markup@v1.0.0", "symbols": [ { diff --git a/test/projectgraph/cases/go/dependency-result-types/summaries/go_std_go1.25.1.json b/test/projectgraph/cases/go/dependency-result-types/summaries/go_std_go1.25.1.json index ac5cfad1..6ac542fd 100644 --- a/test/projectgraph/cases/go/dependency-result-types/summaries/go_std_go1.25.1.json +++ b/test/projectgraph/cases/go/dependency-result-types/summaries/go_std_go1.25.1.json @@ -1,7 +1,7 @@ { "version": "3", "index_version": "16", - "link_version": "18", + "link_version": "19", "unit": "go:std@go1.25.1", "symbols": [ { diff --git a/test/projectgraph/cases/go/panic-value/summaries/go_github.com_acme_kit_v1.0.0.json b/test/projectgraph/cases/go/panic-value/summaries/go_github.com_acme_kit_v1.0.0.json index 3a3c78da..c165d791 100644 --- a/test/projectgraph/cases/go/panic-value/summaries/go_github.com_acme_kit_v1.0.0.json +++ b/test/projectgraph/cases/go/panic-value/summaries/go_github.com_acme_kit_v1.0.0.json @@ -1,7 +1,7 @@ { "version": "3", "index_version": "16", - "link_version": "18", + "link_version": "19", "unit": "go:github.com/acme/kit@v1.0.0", "symbols": [ { diff --git a/test/projectgraph/cases/go/plugin-lookup-std/summaries/go_std_go1.25.1.json b/test/projectgraph/cases/go/plugin-lookup-std/summaries/go_std_go1.25.1.json index f978ead0..5c50028c 100644 --- a/test/projectgraph/cases/go/plugin-lookup-std/summaries/go_std_go1.25.1.json +++ b/test/projectgraph/cases/go/plugin-lookup-std/summaries/go_std_go1.25.1.json @@ -1,7 +1,7 @@ { "version": "3", "index_version": "16", - "link_version": "18", + "link_version": "19", "unit": "go:std@go1.25.1", "symbols": [ { diff --git a/test/projectgraph/cases/go/stdlib-callback-scope/summaries/go_github.com_acme_kit_v1.0.0.json b/test/projectgraph/cases/go/stdlib-callback-scope/summaries/go_github.com_acme_kit_v1.0.0.json index bcb0ba67..08655323 100644 --- a/test/projectgraph/cases/go/stdlib-callback-scope/summaries/go_github.com_acme_kit_v1.0.0.json +++ b/test/projectgraph/cases/go/stdlib-callback-scope/summaries/go_github.com_acme_kit_v1.0.0.json @@ -1,7 +1,7 @@ { "version": "3", "index_version": "16", - "link_version": "18", + "link_version": "19", "unit": "go:github.com/acme/kit@v1.0.0", "symbols": [ { diff --git a/test/projectgraph/cases/go/stdlib-callback/summaries/go_github.com_acme_ws_v1.0.0.json b/test/projectgraph/cases/go/stdlib-callback/summaries/go_github.com_acme_ws_v1.0.0.json index 014417f5..27d42dbb 100644 --- a/test/projectgraph/cases/go/stdlib-callback/summaries/go_github.com_acme_ws_v1.0.0.json +++ b/test/projectgraph/cases/go/stdlib-callback/summaries/go_github.com_acme_ws_v1.0.0.json @@ -1,7 +1,7 @@ { "version": "3", "index_version": "16", - "link_version": "18", + "link_version": "19", "unit": "go:github.com/acme/ws@v1.0.0", "symbols": [ { diff --git a/test/projectgraph/cases/java/static-wildcard-nested-class/expect.yaml b/test/projectgraph/cases/java/static-wildcard-nested-class/expect.yaml new file mode 100644 index 00000000..aa874511 --- /dev/null +++ b/test/projectgraph/cases/java/static-wildcard-nested-class/expect.yaml @@ -0,0 +1,75 @@ +source: safedep:hand +description: >- + Outer extends Base of com.y, and Outer.java has import com.y.* and import static + com.x.Outer.Inner.*. A extends Outer, and A.java comes first. The read of the static import + resolves Outer.Inner, which builds the MRO of Outer. The MRO looks up the base Base through the same + wildcard imports while that read is in progress. The call baseMethod() in Outer.run has a member edge + to Base.baseMethod. A link step that keeps the MRO made from the imports of a pass that has not + ended gives a cha edge and a no-definition record instead. +roots: + - key: com/x/A.java//A//main + kind: main + rule: java.main +exact_edges: true +edges: + - from: com/x/A.java//A//main + to: com/x/A.java//A + kind: direct + confidence: high + site: com/x/A.java:5 + - from: com/x/A.java//A//main + to: com/x/A.java//A//go + kind: member + confidence: high + site: com/x/A.java:5 + - from: com/x/A.java//A//go + to: com/y/Base.java//Base//baseMethod + kind: member + confidence: high + site: com/x/A.java:9 + - from: com/x/Outer.java//Outer//run + to: com/y/Base.java//Base//baseMethod + kind: member + confidence: high + site: com/x/Outer.java:12 + - from: com/x/Outer.java//Outer//run + to: com/x/Outer.java//Outer//Inner//help + kind: direct + confidence: high + site: com/x/Outer.java:13 + - from: com/y/Base.java//Base//baseMethod + to: com/y/Danger.java//Danger//run + kind: member + confidence: high + site: com/y/Base.java:5 + - from: com/y/Danger.java//Danger//run + to: org//danger//Lib//call + kind: direct + confidence: high + site: com/y/Danger.java:5 +unresolved: [] +results: + - target: org//danger//Lib//call + status: found + path: + - key: com/x/A.java//A//main + - key: com/x/A.java//A//go + site: com/x/A.java:5 + kind: member + confidence: high + - key: com/y/Base.java//Base//baseMethod + site: com/x/A.java:9 + kind: member + confidence: high + - key: com/y/Danger.java//Danger//run + site: com/y/Base.java:5 + kind: member + confidence: high + - key: org//danger//Lib//call + site: com/y/Danger.java:5 + kind: direct + confidence: high + call_sites: + - caller: com/y/Danger.java//Danger//run + site: com/y/Danger.java:5 + reached: true diff --git a/test/projectgraph/cases/java/static-wildcard-nested-class/project/com/x/A.java b/test/projectgraph/cases/java/static-wildcard-nested-class/project/com/x/A.java new file mode 100644 index 00000000..4ee2abac --- /dev/null +++ b/test/projectgraph/cases/java/static-wildcard-nested-class/project/com/x/A.java @@ -0,0 +1,11 @@ +package com.x; + +public class A extends Outer { + public static void main(String[] args) { + new A().go(); + } + + void go() { + baseMethod(); + } +} diff --git a/test/projectgraph/cases/java/static-wildcard-nested-class/project/com/x/Outer.java b/test/projectgraph/cases/java/static-wildcard-nested-class/project/com/x/Outer.java new file mode 100644 index 00000000..f3426720 --- /dev/null +++ b/test/projectgraph/cases/java/static-wildcard-nested-class/project/com/x/Outer.java @@ -0,0 +1,15 @@ +package com.x; + +import com.y.*; +import static com.x.Outer.Inner.*; + +public class Outer extends Base { + public static class Inner { + public static void help() {} + } + + void run() { + baseMethod(); + help(); + } +} diff --git a/test/projectgraph/cases/java/static-wildcard-nested-class/project/com/y/Base.java b/test/projectgraph/cases/java/static-wildcard-nested-class/project/com/y/Base.java new file mode 100644 index 00000000..7b33f426 --- /dev/null +++ b/test/projectgraph/cases/java/static-wildcard-nested-class/project/com/y/Base.java @@ -0,0 +1,7 @@ +package com.y; + +public class Base { + public void baseMethod() { + Danger.run(); + } +} diff --git a/test/projectgraph/cases/java/static-wildcard-nested-class/project/com/y/Danger.java b/test/projectgraph/cases/java/static-wildcard-nested-class/project/com/y/Danger.java new file mode 100644 index 00000000..f6c5a8de --- /dev/null +++ b/test/projectgraph/cases/java/static-wildcard-nested-class/project/com/y/Danger.java @@ -0,0 +1,7 @@ +package com.y; + +public class Danger { + public static void run() { + org.danger.Lib.call(); + } +} diff --git a/test/projectgraph/cases/javascript/builtin-chain/summaries/npm_plug_1.0.0.json b/test/projectgraph/cases/javascript/builtin-chain/summaries/npm_plug_1.0.0.json index 7b95c886..c4c68898 100644 --- a/test/projectgraph/cases/javascript/builtin-chain/summaries/npm_plug_1.0.0.json +++ b/test/projectgraph/cases/javascript/builtin-chain/summaries/npm_plug_1.0.0.json @@ -1,7 +1,7 @@ { "version": "3", "index_version": "16", - "link_version": "18", + "link_version": "19", "unit": "npm:plug@1.0.0", "symbols": [ { diff --git a/test/projectgraph/cases/javascript/dependency-candidates/summaries/npm_store-kit_1.0.0.json b/test/projectgraph/cases/javascript/dependency-candidates/summaries/npm_store-kit_1.0.0.json index b8b95a3f..a52e9868 100644 --- a/test/projectgraph/cases/javascript/dependency-candidates/summaries/npm_store-kit_1.0.0.json +++ b/test/projectgraph/cases/javascript/dependency-candidates/summaries/npm_store-kit_1.0.0.json @@ -1,7 +1,7 @@ { "version": "3", "index_version": "16", - "link_version": "18", + "link_version": "19", "unit": "npm:store-kit@1.0.0", "symbols": [ { diff --git a/test/projectgraph/cases/javascript/dependency-exports-import/summaries/npm_kit_1.0.0.json b/test/projectgraph/cases/javascript/dependency-exports-import/summaries/npm_kit_1.0.0.json index b6fd33e3..c59cf4f8 100644 --- a/test/projectgraph/cases/javascript/dependency-exports-import/summaries/npm_kit_1.0.0.json +++ b/test/projectgraph/cases/javascript/dependency-exports-import/summaries/npm_kit_1.0.0.json @@ -1,7 +1,7 @@ { "version": "3", "index_version": "16", - "link_version": "18", + "link_version": "19", "unit": "npm:kit@1.0.0", "symbols": [ { diff --git a/test/projectgraph/cases/javascript/dependency-exports-require/summaries/npm_kit_1.0.0.json b/test/projectgraph/cases/javascript/dependency-exports-require/summaries/npm_kit_1.0.0.json index b6fd33e3..c59cf4f8 100644 --- a/test/projectgraph/cases/javascript/dependency-exports-require/summaries/npm_kit_1.0.0.json +++ b/test/projectgraph/cases/javascript/dependency-exports-require/summaries/npm_kit_1.0.0.json @@ -1,7 +1,7 @@ { "version": "3", "index_version": "16", - "link_version": "18", + "link_version": "19", "unit": "npm:kit@1.0.0", "symbols": [ { diff --git a/test/projectgraph/cases/javascript/dependency-method-name/summaries/npm_plug_1.0.0.json b/test/projectgraph/cases/javascript/dependency-method-name/summaries/npm_plug_1.0.0.json index fb9f4de1..a14fade4 100644 --- a/test/projectgraph/cases/javascript/dependency-method-name/summaries/npm_plug_1.0.0.json +++ b/test/projectgraph/cases/javascript/dependency-method-name/summaries/npm_plug_1.0.0.json @@ -1,7 +1,7 @@ { "version": "3", "index_version": "16", - "link_version": "18", + "link_version": "19", "unit": "npm:plug@1.0.0", "symbols": [ { diff --git a/test/projectgraph/cases/javascript/dependency-same-path/summaries/npm_util-kit_1.0.0.json b/test/projectgraph/cases/javascript/dependency-same-path/summaries/npm_util-kit_1.0.0.json index ff8dc49b..2e8d0346 100644 --- a/test/projectgraph/cases/javascript/dependency-same-path/summaries/npm_util-kit_1.0.0.json +++ b/test/projectgraph/cases/javascript/dependency-same-path/summaries/npm_util-kit_1.0.0.json @@ -1,7 +1,7 @@ { "version": "3", "index_version": "16", - "link_version": "18", + "link_version": "19", "unit": "npm:util-kit@1.0.0", "symbols": [ { diff --git a/test/projectgraph/cases/javascript/dependency-transitive/summaries/npm_lodash._reinterpolate_3.0.0.json b/test/projectgraph/cases/javascript/dependency-transitive/summaries/npm_lodash._reinterpolate_3.0.0.json index 6da5f9d8..f3b26e6c 100644 --- a/test/projectgraph/cases/javascript/dependency-transitive/summaries/npm_lodash._reinterpolate_3.0.0.json +++ b/test/projectgraph/cases/javascript/dependency-transitive/summaries/npm_lodash._reinterpolate_3.0.0.json @@ -1,7 +1,7 @@ { "version": "3", "index_version": "16", - "link_version": "18", + "link_version": "19", "unit": "npm:lodash._reinterpolate@3.0.0", "symbols": [ { diff --git a/test/projectgraph/cases/javascript/dependency-transitive/summaries/npm_lodash_4.17.21.json b/test/projectgraph/cases/javascript/dependency-transitive/summaries/npm_lodash_4.17.21.json index a10bbbcc..584208a0 100644 --- a/test/projectgraph/cases/javascript/dependency-transitive/summaries/npm_lodash_4.17.21.json +++ b/test/projectgraph/cases/javascript/dependency-transitive/summaries/npm_lodash_4.17.21.json @@ -1,7 +1,7 @@ { "version": "3", "index_version": "16", - "link_version": "18", + "link_version": "19", "unit": "npm:lodash@4.17.21", "symbols": [ { diff --git a/test/projectgraph/cases/python/dependency-compiled-module/summaries/pypi_speedy_1.0.0.json b/test/projectgraph/cases/python/dependency-compiled-module/summaries/pypi_speedy_1.0.0.json index 78254678..0d53d13f 100644 --- a/test/projectgraph/cases/python/dependency-compiled-module/summaries/pypi_speedy_1.0.0.json +++ b/test/projectgraph/cases/python/dependency-compiled-module/summaries/pypi_speedy_1.0.0.json @@ -1,7 +1,7 @@ { "version": "3", "index_version": "16", - "link_version": "18", + "link_version": "19", "unit": "pypi:speedy@1.0.0", "symbols": [ { diff --git a/test/projectgraph/cases/python/dependency-dark-unit-record/summaries/pypi_PyYAML_6.0.1.json b/test/projectgraph/cases/python/dependency-dark-unit-record/summaries/pypi_PyYAML_6.0.1.json index c185c149..0a8677f0 100644 --- a/test/projectgraph/cases/python/dependency-dark-unit-record/summaries/pypi_PyYAML_6.0.1.json +++ b/test/projectgraph/cases/python/dependency-dark-unit-record/summaries/pypi_PyYAML_6.0.1.json @@ -1,7 +1,7 @@ { "version": "3", "index_version": "16", - "link_version": "18", + "link_version": "19", "unit": "pypi:PyYAML@6.0.1", "symbols": [ { diff --git a/test/projectgraph/cases/python/dependency-dark-unit/summaries/pypi_PyYAML_6.0.1.json b/test/projectgraph/cases/python/dependency-dark-unit/summaries/pypi_PyYAML_6.0.1.json index 2fd267bc..71bf9342 100644 --- a/test/projectgraph/cases/python/dependency-dark-unit/summaries/pypi_PyYAML_6.0.1.json +++ b/test/projectgraph/cases/python/dependency-dark-unit/summaries/pypi_PyYAML_6.0.1.json @@ -1,7 +1,7 @@ { "version": "3", "index_version": "16", - "link_version": "18", + "link_version": "19", "unit": "pypi:PyYAML@6.0.1", "symbols": [ { diff --git a/test/projectgraph/cases/python/dependency-failed-reached/summaries/pypi_badpkg_1.0.0.json b/test/projectgraph/cases/python/dependency-failed-reached/summaries/pypi_badpkg_1.0.0.json index b82d1f86..65724707 100644 --- a/test/projectgraph/cases/python/dependency-failed-reached/summaries/pypi_badpkg_1.0.0.json +++ b/test/projectgraph/cases/python/dependency-failed-reached/summaries/pypi_badpkg_1.0.0.json @@ -1,7 +1,7 @@ { "version": "3", "index_version": "16", - "link_version": "18", + "link_version": "19", "unit": "pypi:badpkg@1.0.0", "symbols": [ { diff --git a/test/projectgraph/cases/python/dependency-failed-reached/summaries/pypi_okpkg_1.0.0.json b/test/projectgraph/cases/python/dependency-failed-reached/summaries/pypi_okpkg_1.0.0.json index 571e973e..c6085da1 100644 --- a/test/projectgraph/cases/python/dependency-failed-reached/summaries/pypi_okpkg_1.0.0.json +++ b/test/projectgraph/cases/python/dependency-failed-reached/summaries/pypi_okpkg_1.0.0.json @@ -1,7 +1,7 @@ { "version": "3", "index_version": "16", - "link_version": "18", + "link_version": "19", "unit": "pypi:okpkg@1.0.0", "symbols": [ { diff --git a/test/projectgraph/cases/python/dependency-failed-unreached/summaries/pypi_badpkg_1.0.0.json b/test/projectgraph/cases/python/dependency-failed-unreached/summaries/pypi_badpkg_1.0.0.json index b82d1f86..65724707 100644 --- a/test/projectgraph/cases/python/dependency-failed-unreached/summaries/pypi_badpkg_1.0.0.json +++ b/test/projectgraph/cases/python/dependency-failed-unreached/summaries/pypi_badpkg_1.0.0.json @@ -1,7 +1,7 @@ { "version": "3", "index_version": "16", - "link_version": "18", + "link_version": "19", "unit": "pypi:badpkg@1.0.0", "symbols": [ { diff --git a/test/projectgraph/cases/python/dependency-failed-unreached/summaries/pypi_okpkg_1.0.0.json b/test/projectgraph/cases/python/dependency-failed-unreached/summaries/pypi_okpkg_1.0.0.json index 571e973e..c6085da1 100644 --- a/test/projectgraph/cases/python/dependency-failed-unreached/summaries/pypi_okpkg_1.0.0.json +++ b/test/projectgraph/cases/python/dependency-failed-unreached/summaries/pypi_okpkg_1.0.0.json @@ -1,7 +1,7 @@ { "version": "3", "index_version": "16", - "link_version": "18", + "link_version": "19", "unit": "pypi:okpkg@1.0.0", "symbols": [ { diff --git a/test/projectgraph/cases/python/dependency-namespace-two-dists/summaries/pypi_google-auth_2.0.0.json b/test/projectgraph/cases/python/dependency-namespace-two-dists/summaries/pypi_google-auth_2.0.0.json index cb2b0b6b..9a94e4f5 100644 --- a/test/projectgraph/cases/python/dependency-namespace-two-dists/summaries/pypi_google-auth_2.0.0.json +++ b/test/projectgraph/cases/python/dependency-namespace-two-dists/summaries/pypi_google-auth_2.0.0.json @@ -1,7 +1,7 @@ { "version": "3", "index_version": "16", - "link_version": "18", + "link_version": "19", "unit": "pypi:google-auth@2.0.0", "symbols": [ { diff --git a/test/projectgraph/cases/python/dependency-namespace-two-dists/summaries/pypi_google-cloud-storage_2.1.0.json b/test/projectgraph/cases/python/dependency-namespace-two-dists/summaries/pypi_google-cloud-storage_2.1.0.json index c7329383..312a4125 100644 --- a/test/projectgraph/cases/python/dependency-namespace-two-dists/summaries/pypi_google-cloud-storage_2.1.0.json +++ b/test/projectgraph/cases/python/dependency-namespace-two-dists/summaries/pypi_google-cloud-storage_2.1.0.json @@ -1,7 +1,7 @@ { "version": "3", "index_version": "16", - "link_version": "18", + "link_version": "19", "unit": "pypi:google-cloud-storage@2.1.0", "symbols": [ { diff --git a/test/projectgraph/cases/python/dependency-package-dir/summaries/pypi_outer_1.0.0.json b/test/projectgraph/cases/python/dependency-package-dir/summaries/pypi_outer_1.0.0.json index 65c4753a..ec7f1191 100644 --- a/test/projectgraph/cases/python/dependency-package-dir/summaries/pypi_outer_1.0.0.json +++ b/test/projectgraph/cases/python/dependency-package-dir/summaries/pypi_outer_1.0.0.json @@ -1,7 +1,7 @@ { "version": "3", "index_version": "16", - "link_version": "18", + "link_version": "19", "unit": "pypi:outer@1.0.0", "symbols": [ { diff --git a/test/projectgraph/cases/python/dependency-record-import-name/summaries/pypi_PyYAML_6.0.1.json b/test/projectgraph/cases/python/dependency-record-import-name/summaries/pypi_PyYAML_6.0.1.json index 2fd267bc..71bf9342 100644 --- a/test/projectgraph/cases/python/dependency-record-import-name/summaries/pypi_PyYAML_6.0.1.json +++ b/test/projectgraph/cases/python/dependency-record-import-name/summaries/pypi_PyYAML_6.0.1.json @@ -1,7 +1,7 @@ { "version": "3", "index_version": "16", - "link_version": "18", + "link_version": "19", "unit": "pypi:PyYAML@6.0.1", "symbols": [ { diff --git a/test/projectgraph/cases/python/dependency-site-packages/summaries/pypi_requests_2.31.0.json b/test/projectgraph/cases/python/dependency-site-packages/summaries/pypi_requests_2.31.0.json index a22d03c2..18461637 100644 --- a/test/projectgraph/cases/python/dependency-site-packages/summaries/pypi_requests_2.31.0.json +++ b/test/projectgraph/cases/python/dependency-site-packages/summaries/pypi_requests_2.31.0.json @@ -1,7 +1,7 @@ { "version": "3", "index_version": "16", - "link_version": "18", + "link_version": "19", "unit": "pypi:requests@2.31.0", "symbols": [ { diff --git a/test/projectgraph/cases/python/dependency-site-packages/summaries/pypi_urllib3_2.0.7.json b/test/projectgraph/cases/python/dependency-site-packages/summaries/pypi_urllib3_2.0.7.json index f7671ddd..22b9b6ff 100644 --- a/test/projectgraph/cases/python/dependency-site-packages/summaries/pypi_urllib3_2.0.7.json +++ b/test/projectgraph/cases/python/dependency-site-packages/summaries/pypi_urllib3_2.0.7.json @@ -1,7 +1,7 @@ { "version": "3", "index_version": "16", - "link_version": "18", + "link_version": "19", "unit": "pypi:urllib3@2.0.7", "symbols": [ { diff --git a/test/projectgraph/cases/python/dependency-stdlib/summaries/python_std_3.12.3.json b/test/projectgraph/cases/python/dependency-stdlib/summaries/python_std_3.12.3.json index a8ed36ca..720fcc94 100644 --- a/test/projectgraph/cases/python/dependency-stdlib/summaries/python_std_3.12.3.json +++ b/test/projectgraph/cases/python/dependency-stdlib/summaries/python_std_3.12.3.json @@ -1,7 +1,7 @@ { "version": "3", "index_version": "16", - "link_version": "18", + "link_version": "19", "unit": "python:std@3.12.3", "symbols": [ { diff --git a/test/projectgraph/cases/python/dependency-typed-return/summaries/pypi_dep_1.0.0.json b/test/projectgraph/cases/python/dependency-typed-return/summaries/pypi_dep_1.0.0.json index 33e4eca4..4021d152 100644 --- a/test/projectgraph/cases/python/dependency-typed-return/summaries/pypi_dep_1.0.0.json +++ b/test/projectgraph/cases/python/dependency-typed-return/summaries/pypi_dep_1.0.0.json @@ -1,7 +1,7 @@ { "version": "3", "index_version": "16", - "link_version": "18", + "link_version": "19", "unit": "pypi:dep@1.0.0", "symbols": [ { diff --git a/test/projectgraph/cases/python/typed-base-subclass/summaries/pypi_dep_1.0.0.json b/test/projectgraph/cases/python/typed-base-subclass/summaries/pypi_dep_1.0.0.json index 33e4eca4..4021d152 100644 --- a/test/projectgraph/cases/python/typed-base-subclass/summaries/pypi_dep_1.0.0.json +++ b/test/projectgraph/cases/python/typed-base-subclass/summaries/pypi_dep_1.0.0.json @@ -1,7 +1,7 @@ { "version": "3", "index_version": "16", - "link_version": "18", + "link_version": "19", "unit": "pypi:dep@1.0.0", "symbols": [ { diff --git a/test/projectgraph/cases/rust/crate-bindings/summaries/cargo_kit_1.0.0.json b/test/projectgraph/cases/rust/crate-bindings/summaries/cargo_kit_1.0.0.json index 49d0517f..3e168d70 100644 --- a/test/projectgraph/cases/rust/crate-bindings/summaries/cargo_kit_1.0.0.json +++ b/test/projectgraph/cases/rust/crate-bindings/summaries/cargo_kit_1.0.0.json @@ -1,7 +1,7 @@ { "version": "3", "index_version": "16", - "link_version": "18", + "link_version": "19", "unit": "cargo:kit@1.0.0", "symbols": [ { diff --git a/test/projectgraph/cases/rust/dependency-crate/summaries/cargo_kit_1.0.0.json b/test/projectgraph/cases/rust/dependency-crate/summaries/cargo_kit_1.0.0.json index 0fc6f041..1ef40a7f 100644 --- a/test/projectgraph/cases/rust/dependency-crate/summaries/cargo_kit_1.0.0.json +++ b/test/projectgraph/cases/rust/dependency-crate/summaries/cargo_kit_1.0.0.json @@ -1,7 +1,7 @@ { "version": "3", "index_version": "16", - "link_version": "18", + "link_version": "19", "unit": "cargo:kit@1.0.0", "symbols": [ { diff --git a/test/projectgraph/cases/rust/dependency-internal-call/summaries/cargo_kit_1.0.0.json b/test/projectgraph/cases/rust/dependency-internal-call/summaries/cargo_kit_1.0.0.json index 8308d1c4..d5029bbf 100644 --- a/test/projectgraph/cases/rust/dependency-internal-call/summaries/cargo_kit_1.0.0.json +++ b/test/projectgraph/cases/rust/dependency-internal-call/summaries/cargo_kit_1.0.0.json @@ -1,7 +1,7 @@ { "version": "3", "index_version": "16", - "link_version": "18", + "link_version": "19", "unit": "cargo:kit@1.0.0", "symbols": [ { diff --git a/test/projectgraph/cases/rust/dependency-renamed/summaries/cargo_kit_1.0.0.json b/test/projectgraph/cases/rust/dependency-renamed/summaries/cargo_kit_1.0.0.json index 8308d1c4..d5029bbf 100644 --- a/test/projectgraph/cases/rust/dependency-renamed/summaries/cargo_kit_1.0.0.json +++ b/test/projectgraph/cases/rust/dependency-renamed/summaries/cargo_kit_1.0.0.json @@ -1,7 +1,7 @@ { "version": "3", "index_version": "16", - "link_version": "18", + "link_version": "19", "unit": "cargo:kit@1.0.0", "symbols": [ { diff --git a/test/projectgraph/cases/rust/glob-use-enum-variants/expect.yaml b/test/projectgraph/cases/rust/glob-use-enum-variants/expect.yaml new file mode 100644 index 00000000..65ccb733 --- /dev/null +++ b/test/projectgraph/cases/rust/glob-use-enum-variants/expect.yaml @@ -0,0 +1,71 @@ +source: safedep:hand +description: >- + src/main.rs has pub use kinds::* and pub use kinds::Kind::*. src/kinds.rs has pub use + crate::Mode::*, so a read of the glob uses of kinds.rs reads the glob uses of main.rs, and that read + reads kinds.rs again. Kind implements the trait Tr of src/traits.rs, and run calls k.area(), so the + call has a member edge to Tr::area, and dep::danger is found. A link step that keeps a result made + from the modules of a pass that has not ended loses the module of traits.rs for the build. The call + then gets a no-definition record and no edge. +roots: + - key: src/main.rs + kind: main + rule: rust.main + - key: src/main.rs//main + kind: main + rule: rust.main +exact_edges: true +edges: + - from: src/main.rs//main + to: src/app.rs//start + kind: direct + confidence: high + site: src/main.rs:8 + - from: src/app.rs//start + to: crate//kinds//Fast + kind: reference + confidence: low + site: src/app.rs:5 + - from: src/app.rs//start + to: src/kinds.rs//run + kind: direct + confidence: high + site: src/app.rs:6 + - from: src/kinds.rs//run + to: src/traits.rs//Tr//area + kind: member + confidence: high + site: src/kinds.rs:10 + - from: src/traits.rs//Tr//area + to: dep//danger + kind: direct + confidence: high + site: src/traits.rs:3 +unresolved: + - caller: src/app.rs + site: src/app.rs:1 + reason: no-definition +results: + - target: dep//danger + status: found + path: + - key: src/main.rs//main + - key: src/app.rs//start + site: src/main.rs:8 + kind: direct + confidence: high + - key: src/kinds.rs//run + site: src/app.rs:6 + kind: direct + confidence: high + - key: src/traits.rs//Tr//area + site: src/kinds.rs:10 + kind: member + confidence: high + - key: dep//danger + site: src/traits.rs:3 + kind: direct + confidence: high + call_sites: + - caller: src/traits.rs//Tr//area + site: src/traits.rs:3 + reached: true diff --git a/test/projectgraph/cases/rust/glob-use-enum-variants/project/Cargo.toml b/test/projectgraph/cases/rust/glob-use-enum-variants/project/Cargo.toml new file mode 100644 index 00000000..730014fa --- /dev/null +++ b/test/projectgraph/cases/rust/glob-use-enum-variants/project/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "app" +version = "0.1.0" +edition = "2021" + +[dependencies] +dep = "1.0.0" diff --git a/test/projectgraph/cases/rust/glob-use-enum-variants/project/src/app.rs b/test/projectgraph/cases/rust/glob-use-enum-variants/project/src/app.rs new file mode 100644 index 00000000..09e4cfad --- /dev/null +++ b/test/projectgraph/cases/rust/glob-use-enum-variants/project/src/app.rs @@ -0,0 +1,7 @@ +use crate::kinds::Fast; +use crate::kinds::Kind; + +pub fn start(k: Kind) { + let _m = Fast; + crate::kinds::run(k); +} diff --git a/test/projectgraph/cases/rust/glob-use-enum-variants/project/src/kinds.rs b/test/projectgraph/cases/rust/glob-use-enum-variants/project/src/kinds.rs new file mode 100644 index 00000000..907b206d --- /dev/null +++ b/test/projectgraph/cases/rust/glob-use-enum-variants/project/src/kinds.rs @@ -0,0 +1,11 @@ +use crate::traits::*; +pub use crate::Mode::*; + +pub enum Mode { Fast, Slow } +pub enum Kind { A, B } + +impl Tr for Kind {} + +pub fn run(k: Kind) { + k.area(); +} diff --git a/test/projectgraph/cases/rust/glob-use-enum-variants/project/src/main.rs b/test/projectgraph/cases/rust/glob-use-enum-variants/project/src/main.rs new file mode 100644 index 00000000..0443d719 --- /dev/null +++ b/test/projectgraph/cases/rust/glob-use-enum-variants/project/src/main.rs @@ -0,0 +1,9 @@ +mod app; +mod kinds; +mod traits; +pub use kinds::*; +pub use kinds::Kind::*; + +fn main() { + app::start(Kind::A); +} diff --git a/test/projectgraph/cases/rust/glob-use-enum-variants/project/src/traits.rs b/test/projectgraph/cases/rust/glob-use-enum-variants/project/src/traits.rs new file mode 100644 index 00000000..174d5502 --- /dev/null +++ b/test/projectgraph/cases/rust/glob-use-enum-variants/project/src/traits.rs @@ -0,0 +1,5 @@ +pub trait Tr { + fn area(&self) { + dep::danger(); + } +} diff --git a/test/projectgraph/cases/rust/glob-use-many/expect.yaml b/test/projectgraph/cases/rust/glob-use-many/expect.yaml new file mode 100644 index 00000000..aa5d7059 --- /dev/null +++ b/test/projectgraph/cases/rust/glob-use-many/expect.yaml @@ -0,0 +1,55 @@ +source: safedep:hand +description: >- + src/sys.rs has eight glob uses, as src/sys.rs of time 0.1.45 has. The glob use of the module inner + brings now of the inline module unix into scope through a second glob use, so main calls + sys::now, and std::fs::remove_file is found. The six glob uses of crates in unix and the two in mac + name no crate that the project gives. The lookup of each name that the file does not define reads + the glob uses of the file, and the resolution of each glob use walks the file again. A link step + that resolves the glob uses again on each such read does work that grows with the orders of the + eight glob uses, and the case does not end. The calls of names that only a glob use of a crate can + bring stay records. +roots: + - key: src/main.rs + kind: main + rule: rust.main + - key: src/main.rs//main + kind: main + rule: rust.main +exact_edges: true +edges: + - from: src/main.rs//main + to: src/sys.rs//inner//unix//now + kind: direct + confidence: high + site: src/main.rs:4 + - from: src/sys.rs//inner//unix//now + to: std//fs//remove_file + kind: direct + confidence: high + site: src/sys.rs:26 +unresolved: + - caller: src/sys.rs//inner//mac//ticks + site: src/sys.rs:12 + reason: unknown-receiver + method: mach_absolute_time + - caller: src/sys.rs//inner//unix//now + site: src/sys.rs:25 + reason: unknown-receiver + method: clock_gettime +results: + - target: std//fs//remove_file + status: found + path: + - key: src/main.rs//main + - key: src/sys.rs//inner//unix//now + site: src/main.rs:4 + kind: direct + confidence: high + - key: std//fs//remove_file + site: src/sys.rs:26 + kind: direct + confidence: high + call_sites: + - caller: src/sys.rs//inner//unix//now + site: src/sys.rs:26 + reached: true diff --git a/test/projectgraph/cases/rust/glob-use-many/project/Cargo.toml b/test/projectgraph/cases/rust/glob-use-many/project/Cargo.toml new file mode 100644 index 00000000..0d44349a --- /dev/null +++ b/test/projectgraph/cases/rust/glob-use-many/project/Cargo.toml @@ -0,0 +1,4 @@ +[package] +name = "app" +version = "0.1.0" +edition = "2021" diff --git a/test/projectgraph/cases/rust/glob-use-many/project/src/main.rs b/test/projectgraph/cases/rust/glob-use-many/project/src/main.rs new file mode 100644 index 00000000..bc8c370c --- /dev/null +++ b/test/projectgraph/cases/rust/glob-use-many/project/src/main.rs @@ -0,0 +1,5 @@ +mod sys; + +fn main() { + sys::now(); +} diff --git a/test/projectgraph/cases/rust/glob-use-many/project/src/sys.rs b/test/projectgraph/cases/rust/glob-use-many/project/src/sys.rs new file mode 100644 index 00000000..e71c8466 --- /dev/null +++ b/test/projectgraph/cases/rust/glob-use-many/project/src/sys.rs @@ -0,0 +1,29 @@ +pub use self::inner::*; + +mod inner { + pub use self::mac::*; + pub use self::unix::*; + + mod mac { + use libc::mach::*; + use libc::time::*; + + pub fn ticks() -> u64 { + mach_absolute_time() + } + } + + mod unix { + use libc::clock::*; + use libc::posix::*; + use libc::signal::*; + use libc::stat::*; + use libc::types::*; + use libc::wait::*; + + pub fn now() { + clock_gettime(); + let _ = std::fs::remove_file("x"); + } + } +} diff --git a/test/projectgraph/cases/rust/glob-use-workspace-crate/expect.yaml b/test/projectgraph/cases/rust/glob-use-workspace-crate/expect.yaml new file mode 100644 index 00000000..979251b6 --- /dev/null +++ b/test/projectgraph/cases/rust/glob-use-workspace-crate/expect.yaml @@ -0,0 +1,54 @@ +source: safedep:hand +description: >- + The workspace has the crates app and core_lib. app/src/prelude.rs has pub use core_lib::*, and + run in app/src/work.rs calls crate::prelude::helper. helper of core_lib calls dep::danger, so + dep::danger is found. The link step reads the glob use of prelude.rs while it resolves the path + core_lib of that same glob use. The guard of that resolution gives no module for the glob use at + that point. A link step that keeps such a list of modules for the whole build sends the call to + the external key crate//prelude//helper with no record, and dep::danger reads not-found. +roots: + - key: app/src/main.rs + kind: main + rule: rust.main + - key: app/src/main.rs//main + kind: main + rule: rust.main +exact_edges: true +edges: + - from: app/src/main.rs//main + to: app/src/work.rs//run + kind: direct + confidence: high + site: app/src/main.rs:5 + - from: app/src/work.rs//run + to: core_lib/src/lib.rs//helper + kind: direct + confidence: high + site: app/src/work.rs:2 + - from: core_lib/src/lib.rs//helper + to: dep//danger + kind: direct + confidence: high + site: core_lib/src/lib.rs:2 +unresolved: [] +results: + - target: dep//danger + status: found + path: + - key: app/src/main.rs//main + - key: app/src/work.rs//run + site: app/src/main.rs:5 + kind: direct + confidence: high + - key: core_lib/src/lib.rs//helper + site: app/src/work.rs:2 + kind: direct + confidence: high + - key: dep//danger + site: core_lib/src/lib.rs:2 + kind: direct + confidence: high + call_sites: + - caller: core_lib/src/lib.rs//helper + site: core_lib/src/lib.rs:2 + reached: true diff --git a/test/projectgraph/cases/rust/glob-use-workspace-crate/project/Cargo.toml b/test/projectgraph/cases/rust/glob-use-workspace-crate/project/Cargo.toml new file mode 100644 index 00000000..b5eaf363 --- /dev/null +++ b/test/projectgraph/cases/rust/glob-use-workspace-crate/project/Cargo.toml @@ -0,0 +1,2 @@ +[workspace] +members = ["app", "core_lib"] diff --git a/test/projectgraph/cases/rust/glob-use-workspace-crate/project/app/Cargo.toml b/test/projectgraph/cases/rust/glob-use-workspace-crate/project/app/Cargo.toml new file mode 100644 index 00000000..110f096f --- /dev/null +++ b/test/projectgraph/cases/rust/glob-use-workspace-crate/project/app/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "app" +version = "0.1.0" +edition = "2021" + +[dependencies] +core_lib = { path = "../core_lib" } diff --git a/test/projectgraph/cases/rust/glob-use-workspace-crate/project/app/src/main.rs b/test/projectgraph/cases/rust/glob-use-workspace-crate/project/app/src/main.rs new file mode 100644 index 00000000..27d9ee8f --- /dev/null +++ b/test/projectgraph/cases/rust/glob-use-workspace-crate/project/app/src/main.rs @@ -0,0 +1,6 @@ +mod prelude; +mod work; + +fn main() { + work::run(); +} diff --git a/test/projectgraph/cases/rust/glob-use-workspace-crate/project/app/src/prelude.rs b/test/projectgraph/cases/rust/glob-use-workspace-crate/project/app/src/prelude.rs new file mode 100644 index 00000000..ce2e50e4 --- /dev/null +++ b/test/projectgraph/cases/rust/glob-use-workspace-crate/project/app/src/prelude.rs @@ -0,0 +1 @@ +pub use core_lib::*; diff --git a/test/projectgraph/cases/rust/glob-use-workspace-crate/project/app/src/work.rs b/test/projectgraph/cases/rust/glob-use-workspace-crate/project/app/src/work.rs new file mode 100644 index 00000000..c25f0736 --- /dev/null +++ b/test/projectgraph/cases/rust/glob-use-workspace-crate/project/app/src/work.rs @@ -0,0 +1,3 @@ +pub fn run() { + crate::prelude::helper(); +} diff --git a/test/projectgraph/cases/rust/glob-use-workspace-crate/project/core_lib/Cargo.toml b/test/projectgraph/cases/rust/glob-use-workspace-crate/project/core_lib/Cargo.toml new file mode 100644 index 00000000..29ce900c --- /dev/null +++ b/test/projectgraph/cases/rust/glob-use-workspace-crate/project/core_lib/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "core_lib" +version = "0.1.0" +edition = "2021" + +[dependencies] +dep = "1.0.0" diff --git a/test/projectgraph/cases/rust/glob-use-workspace-crate/project/core_lib/src/lib.rs b/test/projectgraph/cases/rust/glob-use-workspace-crate/project/core_lib/src/lib.rs new file mode 100644 index 00000000..1a000e8c --- /dev/null +++ b/test/projectgraph/cases/rust/glob-use-workspace-crate/project/core_lib/src/lib.rs @@ -0,0 +1,3 @@ +pub fn helper() { + dep::danger(); +} diff --git a/test/projectgraph/cases/rust/glob-use/summaries/cargo_dep_1.2.0.json b/test/projectgraph/cases/rust/glob-use/summaries/cargo_dep_1.2.0.json index a88279ec..9e9f91b1 100644 --- a/test/projectgraph/cases/rust/glob-use/summaries/cargo_dep_1.2.0.json +++ b/test/projectgraph/cases/rust/glob-use/summaries/cargo_dep_1.2.0.json @@ -1,7 +1,7 @@ { "version": "3", "index_version": "16", - "link_version": "18", + "link_version": "19", "unit": "cargo:dep@1.2.0", "symbols": [ { diff --git a/test/projectgraph/cases/rust/into-dependency/summaries/cargo_kit_1.0.0.json b/test/projectgraph/cases/rust/into-dependency/summaries/cargo_kit_1.0.0.json index 6fac9200..61ee1f2d 100644 --- a/test/projectgraph/cases/rust/into-dependency/summaries/cargo_kit_1.0.0.json +++ b/test/projectgraph/cases/rust/into-dependency/summaries/cargo_kit_1.0.0.json @@ -1,7 +1,7 @@ { "version": "3", "index_version": "16", - "link_version": "18", + "link_version": "19", "unit": "cargo:kit@1.0.0", "symbols": [ { diff --git a/test/projectgraph/cases/rust/library-build-script/summaries/cargo_kit_1.0.0.json b/test/projectgraph/cases/rust/library-build-script/summaries/cargo_kit_1.0.0.json index 1109a3ed..892b7283 100644 --- a/test/projectgraph/cases/rust/library-build-script/summaries/cargo_kit_1.0.0.json +++ b/test/projectgraph/cases/rust/library-build-script/summaries/cargo_kit_1.0.0.json @@ -1,7 +1,7 @@ { "version": "3", "index_version": "16", - "link_version": "18", + "link_version": "19", "unit": "cargo:kit@1.0.0", "symbols": [ { diff --git a/test/projectgraph/cases/rust/macro-import/summaries/cargo_dep_1.2.0.json b/test/projectgraph/cases/rust/macro-import/summaries/cargo_dep_1.2.0.json index 48a89996..58d56bc3 100644 --- a/test/projectgraph/cases/rust/macro-import/summaries/cargo_dep_1.2.0.json +++ b/test/projectgraph/cases/rust/macro-import/summaries/cargo_dep_1.2.0.json @@ -1,7 +1,7 @@ { "version": "3", "index_version": "16", - "link_version": "18", + "link_version": "19", "unit": "cargo:dep@1.2.0", "symbols": [ { diff --git a/test/projectgraph/cases/rust/trait-object-shadowed/summaries/cargo_dep_1.2.0.json b/test/projectgraph/cases/rust/trait-object-shadowed/summaries/cargo_dep_1.2.0.json index 7eca2165..a0c68e22 100644 --- a/test/projectgraph/cases/rust/trait-object-shadowed/summaries/cargo_dep_1.2.0.json +++ b/test/projectgraph/cases/rust/trait-object-shadowed/summaries/cargo_dep_1.2.0.json @@ -1,7 +1,7 @@ { "version": "3", "index_version": "16", - "link_version": "18", + "link_version": "19", "unit": "cargo:dep@1.2.0", "symbols": [ { diff --git a/test/projectgraph/cases/rust/trait-object/summaries/cargo_dep_1.2.0.json b/test/projectgraph/cases/rust/trait-object/summaries/cargo_dep_1.2.0.json index a74e9419..37ffff09 100644 --- a/test/projectgraph/cases/rust/trait-object/summaries/cargo_dep_1.2.0.json +++ b/test/projectgraph/cases/rust/trait-object/summaries/cargo_dep_1.2.0.json @@ -1,7 +1,7 @@ { "version": "3", "index_version": "16", - "link_version": "18", + "link_version": "19", "unit": "cargo:dep@1.2.0", "symbols": [ { diff --git a/test/projectgraph/cases/rust/use-binding-path/summaries/cargo_dep_1.0.0.json b/test/projectgraph/cases/rust/use-binding-path/summaries/cargo_dep_1.0.0.json index beaba435..5bdf2f40 100644 --- a/test/projectgraph/cases/rust/use-binding-path/summaries/cargo_dep_1.0.0.json +++ b/test/projectgraph/cases/rust/use-binding-path/summaries/cargo_dep_1.0.0.json @@ -1,7 +1,7 @@ { "version": "3", "index_version": "16", - "link_version": "18", + "link_version": "19", "unit": "cargo:dep@1.0.0", "symbols": [ { diff --git a/test/projectgraph/cases/rust/use-dependency-item/summaries/cargo_dep_1.0.0.json b/test/projectgraph/cases/rust/use-dependency-item/summaries/cargo_dep_1.0.0.json index f209d93e..ed1c0b55 100644 --- a/test/projectgraph/cases/rust/use-dependency-item/summaries/cargo_dep_1.0.0.json +++ b/test/projectgraph/cases/rust/use-dependency-item/summaries/cargo_dep_1.0.0.json @@ -1,7 +1,7 @@ { "version": "3", "index_version": "16", - "link_version": "18", + "link_version": "19", "unit": "cargo:dep@1.0.0", "symbols": [ { diff --git a/test/projectgraph/deadline_test.go b/test/projectgraph/deadline_test.go new file mode 100644 index 00000000..4dd72c1c --- /dev/null +++ b/test/projectgraph/deadline_test.go @@ -0,0 +1,56 @@ +package projectgraph + +import ( + "context" + "fmt" + "os" + "path/filepath" + "strings" + "testing" + "time" + + codefs "github.com/safedep/code/fs" + "github.com/safedep/code/plugin/indexer" + "github.com/safedep/code/projectgraph" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +// TestBuildStopsAtTheDeadline links ten Rust files that each glob use a +// name of every other file that no file defines. Each lookup of a name that +// a file does not define walks the glob uses of the other files, and the +// work grows with the orders of the files. The build must end soon after +// its deadline, as a scan gives the link step a budget. +func TestBuildStopsAtTheDeadline(t *testing.T) { + const files = 10 + dir := t.TempDir() + write := func(name, text string) { + require.NoError(t, os.MkdirAll(filepath.Dir(filepath.Join(dir, name)), 0o755)) + require.NoError(t, os.WriteFile(filepath.Join(dir, name), []byte(text), 0o644)) + } + write("Cargo.toml", "[package]\nname = \"app\"\nversion = \"0.1.0\"\n") + var lib strings.Builder + for i := range files { + fmt.Fprintf(&lib, "pub mod f%d;\n", i) + var file strings.Builder + for j := range files { + if j != i { + fmt.Fprintf(&file, "pub use crate::f%d::E::*;\n", j) + } + } + file.WriteString("pub fn run() {\n missing();\n}\n") + write(fmt.Sprintf("src/f%d.rs", i), file.String()) + } + write("src/lib.rs", lib.String()) + + fsys, err := codefs.NewLocalFileSystem(codefs.LocalFileSystemConfig{AppDirectories: []string{dir}}) + require.NoError(t, err) + indexed := indexProject(t, fsys, indexer.Options{Languages: caseLanguages(t)}) + + ctx, cancel := context.WithTimeout(context.Background(), 200*time.Millisecond) + defer cancel() + start := time.Now() + _, err = projectgraph.Build(ctx, indexed.Indexes, projectgraph.Options{Root: os.DirFS(dir), Files: indexed.Statuses(), Languages: indexed.Languages}) + assert.ErrorIs(t, err, context.DeadlineExceeded) + assert.Less(t, time.Since(start), 10*time.Second) +} diff --git a/test/projectgraph/version_test.go b/test/projectgraph/version_test.go index 78446241..b65348dc 100644 --- a/test/projectgraph/version_test.go +++ b/test/projectgraph/version_test.go @@ -33,6 +33,7 @@ var graphHashes = map[string]string{ "14/16": "823b1f82c4aed8ba27d19275505c8d1dee755086be48fcda64d323f55b4c62a5", "15/17": "d823ce8ba221c534ab062f7e48abfe91d1c90d50b2a2fdb00d41183dc0e9da09", "16/18": "bb92620bf9903e8d19b52b62198a0bfd69d67856f9db226112b2cedf537b312b", + "16/19": "51ba3e925c628602b3a53c1a6e68b379022a410bb5b749062b3045fef082ac8f", } // resultHashes records the hash of the reach results of every case for @@ -50,6 +51,7 @@ var resultHashes = map[string]string{ "14/16/3": "13b6eecb686ddec3c2ba470fc9752ea66cff445d5e18e0772a71b15ae7fe1c9c", "15/17/4": "1b32d7c1dbb0a4637853eb7a00b0db91a0a4e1a31f221b37ed0d0654a66ed13e", "16/18/5": "e0c6093df3a85353ee15c8a90ef7c2a441f23348ce80c9d49793c256bddeffc5", + "16/19/5": "a935650f8e4d01c0abdceeefb3332bf779927693a1c48b28263da5365db752cd", } // summaryHashes records the hash of the golden summaries of the cases for @@ -68,6 +70,7 @@ var summaryHashes = map[string]string{ "14/16/2": "fb678202978212aae932e50a56a0d3dc7f0f794ce908988bf605ce9a6e04bc51", "15/17/2": "00a6bd5871f70459a617079f431939ef7c92e4b3f360013c1dedd017fe1146be", "16/18/3": "694efb5f72075356359031d449d7b4ecbdca2ddd5099dacbcd2adad745ac6e19", + "16/19/3": "13c72bf9eb60fc0a38bc600906fc02028d5cb60cb2aefbec0f0721779c429d80", } func TestGraphHashFollowsVersion(t *testing.T) {