Simple test that feedback is waiting

This commit is contained in:
Tom Sydney Kerckhove 2023-01-14 20:53:46 +01:00
parent f7648e94b7
commit 384811ae20
4 changed files with 23 additions and 5 deletions

View File

@ -6,7 +6,9 @@ mkDerivation {
version = "0.0.0.0";
src = ./.;
libraryHaskellDepends = [ base feedback path path-io ];
testHaskellDepends = [ base feedback sydtest typed-process ];
testHaskellDepends = [
base feedback path path-io sydtest typed-process
];
testToolDepends = [ sydtest-discover ];
doHaddock = false;
homepage = "https://github.com/NorfairKing/feedback#readme";

View File

@ -50,6 +50,8 @@ test-suite feedback-test
base >=4.7 && <5
, feedback
, feedback-test-harness
, path
, path-io
, sydtest
, typed-process
default-language: Haskell2010

View File

@ -30,5 +30,7 @@ tests:
dependencies:
- feedback
- feedback-test-harness
- path
- path-io
- sydtest
- typed-process

View File

@ -1,11 +1,23 @@
{-# LANGUAGE NumericUnderscores #-}
module FeedbackSpec (spec) where
import Control.Concurrent
import Path
import System.Process.Typed
import Test.Syd
import Test.Syd.Path
spec :: Spec
spec = sequential $ do
it "can show help text" $ do
let cp = setStdout nullStream $ proc "feedback" ["--help"]
spec = sequential . tempDirSpec "feedback" $ do
it "can show help text" $ \tdir -> do
let cp = setStdout nullStream $ setWorkingDir (fromAbsDir tdir) $ proc "feedback" ["--help"]
runProcess_ cp :: IO ()
pure ()
it "can start a loop and wait for input" $ \tdir -> do
let cp = setStdout nullStream $ setWorkingDir (fromAbsDir tdir) $ proc "feedback" ["echo", "hi"]
withProcessTerm cp $ \ph -> do
threadDelay 100_000 -- Wait 100 ms
-- If the program is still running after 100ms, we assume that it is waiting.
mExitCode <- getExitCode ph
mExitCode `shouldBe` Nothing