Skip to content

Commit

Permalink
fix tests on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
daanx committed Dec 30, 2023
1 parent 08589b2 commit 7b24c58
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions test/Spec.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Control.Monad
import Control.Monad.IO.Class
import Data.Maybe
import Data.Char
import Data.List
import Data.List.Extra (replace, trim)
import System.Directory
Expand Down Expand Up @@ -105,7 +106,10 @@ testSanitize kokaDir
-- . sub ": [[:digit:]]+([,\\)])" ": 0\\1"
. if null kokaDir then id else replace xkokaDir "..."
where
xkokaDir = map (\c -> if c == '\\' then '/' else c) kokaDir
xkokaDir = case map (\c -> if c == '\\' then '/' else c) kokaDir of
(c:':':rest) -> [toLower c] ++ ":" ++ rest
path -> path

sub re = flip (subRegex (mkRegex re))
-- limitTo n s | length s > n = take n s ++ "... (and more)"
-- | otherwise = s
Expand All @@ -122,14 +126,14 @@ runKoka cfg kokaDir fp
kokaFlags = optFlag ++ flags cfg ++ caseFlags
if (cabal (options cfg))
then do let argv = ["new-run", "koka", "--"] ++ kokaFlags ++ [relTest]
(exitCode, stdout, sterr) <- readProcessWithExitCode "cabal" argv ""
return (testSanitize kokaDir stdout)
(exitCode, stdout, sterr) <- readProcessWithExitCode "cabal" argv ""
return (testSanitize kokaDir stdout)
else do let stackFlags = if (sysghc (options cfg)) then ["--system-ghc","--skip-ghc-check"] else []
argv = ["exec","koka"] ++ stackFlags ++ ["--"] ++ kokaFlags ++ [relTest]
(exitCode, stdout, sterr) <- readProcessWithExitCode "stack" argv ""
return (testSanitize kokaDir stdout)



makeTest :: Cfg -> FilePath -> Spec
makeTest cfg fp
Expand Down
2 changes: 1 addition & 1 deletion test/medium/caesar.kk.out
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ medium/caesar/caesar: (s : string) -> string
medium/caesar/chisqr: (xs : list<float64>, ys : list<float64>) -> float64
medium/caesar/encode: (s : string, shift : optional<int>) -> string
medium/caesar/english: list<float64>
medium/caesar/example-uncaesar: () -> console ()
medium/caesar/freqs: (s : string) -> list<float64>
medium/caesar/main: () -> console ()
medium/caesar/percent: (n : int, m : int) -> float64
medium/caesar/rotate: forall<a> (xs : list<a>, n : int) -> list<a>
medium/caesar/test-uncaesar: () -> console ()
medium/caesar/uncaesar: (s : string) -> string

0 comments on commit 7b24c58

Please sign in to comment.