Skip to content

Commit

Permalink
fix: test accounts for stderr being separated by crlf on windows.
Browse files Browse the repository at this point in the history
add contrarian newlines to the long list of problems bill gates is
responsible for cursing us with on this godforsaken hellscape we call
Earth.
  • Loading branch information
cakekindel committed Nov 2, 2024
1 parent bab00b5 commit 9561f44
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
15 changes: 15 additions & 0 deletions test-fixtures/purs-not-ok.win.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Reading Spago workspace configuration...

✓ Selecting package to build: aaa

Downloading dependencies...
No lockfile found, generating it...
Lockfile written to spago.lock. Please commit this file.
Building...
Invalid option `--non-existent'

Usage: purs COMMAND

The PureScript compiler and tools

✘ purs exited with non-ok status code: Normally 1
18 changes: 9 additions & 9 deletions test/Spago/Build.purs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ module Test.Spago.Build where

import Test.Prelude

import Control.Monad.Error.Class (liftMaybe)
import Data.Foldable (fold)
import Data.String as String
import Effect.Exception (error)
import Node.FS.Aff as FSA
import Node.Path as Path
import Node.Platform as Platform
Expand Down Expand Up @@ -34,15 +36,13 @@ spec = Spec.around withTempDir do

Spec.it "exits when purs exits non-ok" \{ spago, fixture } -> do
spago [ "init", "--name", "aaa" ] >>= shouldBeSuccess
spago [ "build", "--purs-args", "--non-existent" ] >>=
checkOutputs'
{ stdoutFile: Nothing
, stderrFile: Just (fixture "purs-not-ok.txt")
, result: isLeft
, sanitize: String.trim
>>> String.replace (String.Pattern "Usage: purs.bin") (String.Replacement "Usage: purs")
>>> String.replace (String.Pattern "\r\n") (String.Replacement "\n")
}
fixture' <-
Process.platform
<#> case _ of
Platform.Win32 -> fixture "purs-not-ok.win.txt"
_ -> fixture "purs-not-ok.txt"
# liftMaybe (error "unreachable")
spago [ "build", "--purs-args", "--non-existent" ] >>= shouldBeFailureErr fixture'

Spec.it "passes options to purs" \{ spago } -> do
spago [ "init" ] >>= shouldBeSuccess
Expand Down

0 comments on commit 9561f44

Please sign in to comment.