Skip to content

Commit

Permalink
Make test compile and pass on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Jimbo4350 committed Feb 8, 2023
1 parent 00b1b67 commit 6865cb7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
18 changes: 17 additions & 1 deletion cardano-cli/test/Test/Cli/Pipes.hs
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}

module Test.Cli.Pipes
( tests
) where

import Prelude
#if !defined(mingw32_HOST_OS)
#define UNIX
#endif

import Prelude
#ifdef UNIX
import Control.Monad.IO.Class (liftIO)
import qualified Data.ByteString.Char8 as BSC
import qualified Data.ByteString.Lazy as LBS
Expand All @@ -21,7 +26,13 @@ import qualified Hedgehog
import qualified Hedgehog.Extras.Test.Base as H
import Hedgehog.Internal.Property (failWith)

#else

import Hedgehog (Property, discover, property, success)

#endif

#ifdef UNIX
prop_readFromPipe :: Property
prop_readFromPipe =
H.propertyOnce . H.moduleWorkspace "tmp" $ \_ -> do
Expand Down Expand Up @@ -66,6 +77,11 @@ withPipe contents = do
closeFd readEnd
pure readContents

#else
prop_readFromPipe :: Property
prop_readFromPipe = property success
#endif

-- -----------------------------------------------------------------------------

tests :: IO Bool
Expand Down
10 changes: 9 additions & 1 deletion cardano-cli/test/cardano-cli-test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import qualified Test.Cli.Pipes
import qualified Test.Cli.Shelley.Run.Query
import qualified Test.Config.Mainnet

import Hedgehog.Extras.Stock.OS (isWin32)

main :: IO ()
main =
defaultMain
Expand All @@ -23,11 +25,17 @@ main =
, Test.Cli.ITN.tests
, Test.Cli.JSON.tests
, Test.Cli.MultiAssetParsing.tests
, Test.Cli.Pipes.tests
, ignoreOnWindows Test.Cli.Pipes.tests
, Test.Cli.Pioneers.Exercise1.tests
, Test.Cli.Pioneers.Exercise2.tests
, Test.Cli.Pioneers.Exercise3.tests
, Test.Cli.Pioneers.Exercise4.tests
, Test.Cli.Shelley.Run.Query.tests
, Test.Config.Mainnet.tests
]

ignoreOnWindows :: IO Bool -> IO Bool
ignoreOnWindows test =
if isWin32
then return True
else test

0 comments on commit 6865cb7

Please sign in to comment.