Skip to content

bennofs/hcltest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hcltest Build Status

hcltest is a library for testing command-line applications.

Usage

The library provides integration with tasty. Here's an example of a simple test using the library together with tasty:

{-# LANGUAGE OverloadedStrings #-} -- we enable OverloadedStrings because hcltest uses text
module Main where

import Test.Tasty
import Test.Tasty.HClTest -- this is the library
import System.Exit (ExitCode(ExitSuccess))

main :: IO ()
main = defaultMain $ testGroup "main"
  [ hcltest "true is successful" (testExitCode Nothing Nothing 1000 "true" [] ExitSuccess) 
  , hcltest "cat works" $ testInteractive Nothing Nothing 1000 "cat" [] $ do
      send "Hey!"
      expect Stdout "Hey!"
      return ExitSuccess
  ]

Here, we created a tasty test case with the hcltest function. The first argument of that function specifies the name of the test case. In the second argument, you can then perform hcltest actions, like testExitCode or testInterative. See the haddocks for the details of the arguments to these functions.