Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/Strategy/Cargo.hs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ import Effect.Grapher (
import Effect.ReadFS (ReadFS, doesFileExist, readContentsToml)
import Errata (Errata (..))
import GHC.Generics (Generic)
import Graphing (Graphing, stripRoot)
import Graphing (Graphing, shrinkRoots)
import Path (Abs, Dir, File, Path, mkRelFile, parent, parseRelFile, toFilePath, (</>))
import Text.Megaparsec (
Parsec,
Expand Down Expand Up @@ -434,7 +434,10 @@ addEdge node = do
edge parentId $ nodePkg dep

buildGraph :: CargoMetadata -> Graphing Dependency
buildGraph meta = stripRoot $
-- By construction, workspace members are the root nodes in the graph.
-- Use shrinkRoots to remove them and promote their direct dependencies to the
-- direct dependencies we report for the project.
buildGraph meta = shrinkRoots $
run . withLabeling toDependency $ do
traverse_ direct $ metadataWorkspaceMembers meta
traverse_ addEdge $ resolvedNodes $ metadataResolve meta
Expand Down
5 changes: 2 additions & 3 deletions test/Cargo/MetadataSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import Data.Text (Text)
import Data.Text qualified as Text
import DepTypes
import GraphUtil
import Graphing
import Strategy.Cargo
import Test.Hspec qualified as Test

Expand Down Expand Up @@ -66,7 +65,7 @@ spec = do
Right result -> result `Test.shouldBe` expectedMetadataPre1_77

Test.it "should build the correct graph" $ do
let graph = pruneUnreachable $ buildGraph expectedMetadataPre1_77
let graph = buildGraph expectedMetadataPre1_77
expectDeps [ansiTermDep, clapDep] graph
expectEdges [(clapDep, ansiTermDep)] graph
expectDirect [clapDep] graph
Expand Down Expand Up @@ -120,7 +119,7 @@ post1_77MetadataParseSpec =
Right result -> result `Test.shouldBe` expectedMetadataPost1_77

Test.it "should build the correct graph" $ do
let graph = pruneUnreachable $ buildGraph expectedMetadataPost1_77
let graph = buildGraph expectedMetadataPost1_77
expectDeps [ansiTermDep, clapDep, fooDep, barDep] graph
expectEdges [(clapDep, ansiTermDep)] graph
expectDirect [clapDep, fooDep, barDep] graph
Loading