Add integration test

This commit is contained in:
waddlaw 2020-01-18 12:45:40 +09:00
parent dd4f8dbfd0
commit e5412b8cfd
4 changed files with 57 additions and 0 deletions

View File

@ -44,6 +44,28 @@ library
ghc-options: -O2 -Wall
default-language: Haskell2010
test-suite test
main-is: Spec.hs
hs-source-dirs: test
type: exitcode-stdio-1.0
build-depends:
base >=4.12 && <4.13,
bytestring >= 0.10.8 && <0.11,
hspec >= 2.7 && <2.8,
typed-process >= 0.2.6 && <0.2.9
build-tool-depends:
hspec-discover:hspec-discover >= 2.7 && <2.8
other-modules: StackTrace.PluginSpec
if flag(dev)
ghc-options: -Wall -Werror
else
ghc-options: -O2 -Wall
default-language: Haskell2010
executable example
main-is: Main.hs
hs-source-dirs: example

1
test/Spec.hs Normal file
View File

@ -0,0 +1 @@
{-# OPTIONS_GHC -F -pgmF hspec-discover #-}

View File

@ -0,0 +1,21 @@
{-# LANGUAGE OverloadedStrings #-}
module StackTrace.PluginSpec (spec) where
import Data.ByteString.Lazy (ByteString)
import qualified Data.ByteString.Lazy as BL
import Test.Hspec
import System.Process.Typed
spec :: Spec
spec = do
output <- runIO exe
expected <- runIO $ BL.readFile "test/resource/ghc86.output"
it "integration test" $ output `shouldBe` expected
exe :: IO ByteString
exe = do
runProcess_ $ shell "cabal install exe:example --installdir=./dist"
err <- readProcessStderr_ $ shell "./dist/example || true"
runProcess_ $ shell "rm -rf ./dist"
return err

View File

@ -0,0 +1,13 @@
example: fError
CallStack (from HasCallStack):
error, called at example/Main.hs:41:10 in main:Main
fError, called at example/Main.hs:37:11 in main:Main
f8, called at example/Main.hs:33:16 in main:Main
f7, called at example/Main.hs:29:11 in main:Main
f6, called at example/Main.hs:25:15 in main:Main
f5, called at example/Main.hs:21:8 in main:Main
f4, called at example/Main.hs:17:6 in main:Main
f3, called at example/Main.hs:13:6 in main:Main
f2, called at example/Main.hs:10:6 in main:Main
f1, called at example/Main.hs:7:14 in main:Main
main, called at example/Main.hs:7:1 in main:Main