Skip to content

Commit

Permalink
Merge branch 'master' into jam/update-node-deps
Browse files Browse the repository at this point in the history
  • Loading branch information
JordanMartinez authored Dec 3, 2023
2 parents 026bf4f + c49c161 commit 9dbed59
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Spago/Command/Build.purs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ run opts = do
let reportTest = pedanticPackages || (fromMaybe false $ p.package.test >>= _.pedantic_packages)
Alternative.guard (reportSrc || reportTest)
pure $ Tuple p { reportSrc, reportTest }
unless (Array.null pedanticPkgs) do
unless (Array.null pedanticPkgs || opts.depsOnly) do
logInfo $ "Looking for unused and undeclared transitive dependencies..."
eitherGraph <- Graph.runGraph globs opts.pursArgs
graph <- either die pure eitherGraph
Expand Down
24 changes: 24 additions & 0 deletions test-fixtures/pedantic/pedantic-instructions-initial-failure.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Reading Spago workspace configuration...
Read the package set from the registry

✅ Selecting package to build: pedantic

Downloading dependencies...
Building...
Src Lib All
Warnings 0 0 0
Errors 0 0 0

✅ Build succeeded.

Looking for unused and undeclared transitive dependencies...

❌ Found unused and/or undeclared transitive dependencies:

Sources for package 'pedantic' import the following transitive dependencies - please add them to the project dependencies, or remove the imports:
effect
from `Main`, which imports:
Effect

These errors can be fixed by running the below command(s):
spago install -p pedantic effect
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Reading Spago workspace configuration...
Read the package set from the registry

✅ Selecting package to build: pedantic

Adding 1 packages to the config in spago.yaml
Downloading dependencies...
Building...
Src Lib All
Warnings 0 0 0
Errors 0 0 0

✅ Build succeeded.
28 changes: 28 additions & 0 deletions test/Spago/Build/Pedantic.purs
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,34 @@ spec =
editSpagoYaml (addPedanticFlagToSrc >>> addPedanticFlagToTest)
spago [ "build" ] >>= shouldBeFailureErr (fixture "pedantic/check-pedantic-packages.txt")

-- A dependency on `console` will include `effect` as a transitive dependency.
-- So, if we don't have `effect` as a direct dependency, we'll get a pedantic error
-- where the fix is to install that missing package.
-- Following those instructions shouldn't cause an error.
Spec.it "following installation instructions does not fail with an unrelated pedantic error" \{ spago, fixture } -> do
setup spago
( defaultSetupConfig
{ installSourcePackages = [ "prelude", "console" ]
, installTestPackages = []
, main = Just
[ "import Prelude"
, ""
, "import Effect"
, "import Effect.Console as Console"
, ""
, "main :: Effect Unit"
, "main = Console.log \"wat\""
]
, testMain = Nothing
}
)
spago [ "uninstall", "effect" ] >>= shouldBeSuccess
-- Get rid of "Compiling..." messages
spago [ "build" ] >>= shouldBeSuccess
editSpagoYaml (addPedanticFlagToSrc)
spago [ "build" ] >>= shouldBeFailureErr (fixture "pedantic/pedantic-instructions-initial-failure.txt")
spago [ "install", "-p", "pedantic", "effect" ] >>= shouldBeSuccessErr (fixture "pedantic/pedantic-instructions-installation-result.txt")

addPedanticFlagToSrc :: Config -> Config
addPedanticFlagToSrc config = config
{ package = config.package <#> \r -> r
Expand Down

0 comments on commit 9dbed59

Please sign in to comment.