Skip to content

Commit

Permalink
fix: trim the error message before censoring
Browse files Browse the repository at this point in the history
  • Loading branch information
SaravananM31 committed Mar 11, 2024
1 parent c533268 commit a2189a8
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Spago/Psa.purs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ shouldPrintWarning = case _ of
let
tests = arr <#> case _ of
ByCode c -> \code _ -> c == code
ByMessagePrefix prefix -> \_ msg -> isJust $ String.stripPrefix (String.Pattern prefix) msg
ByMessagePrefix prefix -> \_ msg -> isJust $ String.stripPrefix (String.Pattern $ String.trim prefix) (String.trim msg)
-- We return `true` to print the warning.
-- If an element was found (i.e. `Just` is returned), then one of the tests succeeded,
-- so we should not print the warning and return false here.
Expand Down
12 changes: 12 additions & 0 deletions test-fixtures/censor-warnings.purs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module Main where

import Prelude

import Effect
import Effect.Console (log)

main :: Effect Unit
main = do
let unused_var = 1
log "hello"

16 changes: 16 additions & 0 deletions test-fixtures/censor-warnings.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package:
name: foo
dependencies:
- console
- effect
- prelude
build:
strict: true
censor_project_warnings:
- by_prefix: "Module Prelude"
- by_prefix: "Module Eff"
- "UnusedName"

workspace:
package_set:
registry: 41.5.0
17 changes: 17 additions & 0 deletions test/Spago/Build.purs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,23 @@ spec = Spec.around withTempDir do
}
spago [ "build" ] >>= shouldBeFailure

Spec.it "should censor warnings with given errorcode and prefix messsage" \{spago, fixture} -> do
spago [ "init" ] >>= shouldBeSuccess
let
srcMain = Path.concat [ "src" , "Main.purs" ]
spagoYaml = "spago.yaml"
FSA.unlink srcMain
FS.copyFile
{ src : fixture "censor-warnings.purs"
, dst : srcMain
}
FSA.unlink spagoYaml
FS.copyFile
{ src : fixture "censor-warnings.yaml"
, dst : spagoYaml
}
spago [ "build" ] >>= shouldBeSuccess

Spec.it "building with a lockfile doesn't need the Registry repo" \{ spago, fixture } -> do
spago [ "init", "--name", "aaa", "--package-set", "33.0.0" ] >>= shouldBeSuccess
spago [ "build" ] >>= shouldBeSuccess
Expand Down

0 comments on commit a2189a8

Please sign in to comment.