Add new shelltestrunner based test-suite

This commit is contained in:
Daniel Gröber 2017-03-01 08:26:17 +01:00
parent 53df9d228f
commit 04baf3e31f
15 changed files with 166 additions and 0 deletions

View File

@ -3,6 +3,7 @@
import Distribution.Simple import Distribution.Simple
import Distribution.Simple.Setup import Distribution.Simple.Setup
import Distribution.Simple.Install import Distribution.Simple.Install
import Distribution.Simple.Program
import Distribution.Simple.Register import Distribution.Simple.Register
import Distribution.Simple.InstallDirs as ID import Distribution.Simple.InstallDirs as ID
import Distribution.Simple.LocalBuildInfo import Distribution.Simple.LocalBuildInfo
@ -25,6 +26,7 @@ main :: IO ()
main = defaultMainWithHooks $ simpleUserHooks { main = defaultMainWithHooks $ simpleUserHooks {
confHook = \(gpd, hbi) cf -> confHook = \(gpd, hbi) cf ->
xBuildDependsLike <$> (confHook simpleUserHooks) (gpd, hbi) cf xBuildDependsLike <$> (confHook simpleUserHooks) (gpd, hbi) cf
, hookedPrograms = [ simpleProgram "shelltest" ]
} }
xBuildDependsLike :: LocalBuildInfo -> LocalBuildInfo xBuildDependsLike :: LocalBuildInfo -> LocalBuildInfo

View File

@ -299,6 +299,20 @@ Test-Suite spec
Build-Depends: hspec < 2.4 && >= 2.0.0 Build-Depends: hspec < 2.4 && >= 2.0.0
X-Build-Depends-Like: CLibName X-Build-Depends-Like: CLibName
Test-Suite shelltest
Default-Language: Haskell2010
Main-Is: ShellTest.hs
Hs-Source-Dirs: shelltest
Type: exitcode-stdio-1.0
Build-Tools: shelltest
Build-Depends: base
, process < 1.5
-- , shelltestrunner >= 1.3.5
if !flag(shelltest)
Buildable: False
Benchmark criterion Benchmark criterion
Type: exitcode-stdio-1.0 Type: exitcode-stdio-1.0
Default-Language: Haskell2010 Default-Language: Haskell2010
@ -325,6 +339,13 @@ Benchmark criterion
, ghc-mod , ghc-mod
Flag shelltest
Description: Enable/disable shelltest test-suite
Default: False
Manual: True
Source-Repository head Source-Repository head
Type: git Type: git
Location: https://github.com/DanielG/ghc-mod.git Location: https://github.com/DanielG/ghc-mod.git

23
shelltest/ShellTest.hs Normal file
View File

@ -0,0 +1,23 @@
#!/usr/bin/env runhaskell
-- ghc-mod: Making Haskell development *more* fun
-- Copyright (C) 2017 Daniel Gröber <dxld ÄT darkboxed DOT org>
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU Affero General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU Affero General Public License for more details.
--
-- You should have received a copy of the GNU Affero General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
module Main where
import System.Exit
import System.Process
main = exitWith =<< rawSystem "shelltest" [ "--execdir", "shelltest/" ]

11
shelltest/browse.test Normal file
View File

@ -0,0 +1,11 @@
cabal exec -- ghc-mod browse Data.Map
>>> /differenceWithKey/
>>>= 0
cabal exec -- ghc-mod browse -d Data.Either
>>> /^either :: \(a -> c\) -> \(b -> c\) -> Either a b -> c$/
>>>= 0
cabal exec -- ghc-mod browse -d Data.Either
>>> /^Left :: a -> Either a b$/
>>>= 0

View File

@ -0,0 +1,11 @@
module MyModule where
data MyType = MyConstructor1
| MyConstructor2
some_num = 0
some_char = ' '
some_string = "bar"
($?>>/) :: Int -> Int -> Int
a $?>>/ b = a + b

View File

@ -0,0 +1,62 @@
cabal exec -- ghc-mod browse MyModule | sort
>>>
MyConstructor1
MyConstructor2
MyType
some_char
some_num
some_string
>>>= 0
cabal exec -- ghc-mod browse -q MyModule | sort
>>>
MyModule.MyConstructor1
MyModule.MyConstructor2
MyModule.MyType
MyModule.some_char
MyModule.some_num
MyModule.some_string
>>>= 0
cabal exec -- ghc-mod browse -d MyModule | sort
>>>
MyConstructor1 :: MyType
MyConstructor2 :: MyType
MyType :: data MyType
some_char :: Char
some_num :: Integer
some_string :: [Char]
>>>= 0
cabal exec -- ghc-mod browse -o MyModule | sort
>>>
($?>>/)
MyConstructor1
MyConstructor2
MyType
some_char
some_num
some_string
>>>= 0
cabal exec -- ghc-mod browse -p MyModule | sort
>>>
MyConstructor1 -- from:MyType
MyConstructor2 -- from:MyType
MyType
some_char
some_num
some_string
>>>= 0
cabal exec -- ghc-mod browse -odpq MyModule | sort
>>>
MyModule.($?>>/) :: Int -> Int -> Int
MyModule.MyConstructor1 :: MyType -- from:MyType
MyModule.MyConstructor2 :: MyType -- from:MyType
MyModule.MyType :: data MyType
MyModule.some_char :: Char
MyModule.some_num :: Integer
MyModule.some_string :: [Char]
>>>= 0

View File

@ -0,0 +1 @@
../MyModule.hs

View File

@ -0,0 +1,9 @@
name: browse-cabal
version: 0
build-type: Simple
cabal-version: >=1.2
library
hs-source-dirs: .
build-depends: base
exposed-modules: MyModule

View File

@ -0,0 +1 @@
../browse-project.testtpl

View File

@ -0,0 +1 @@
../MyModule.hs

View File

@ -0,0 +1,4 @@
# # TODO: make this work
# cabal exec -- ghc-mod browse MyModule
# >>>
# >>>= !0

View File

@ -0,0 +1 @@
../MyModule.hs

View File

@ -0,0 +1,4 @@
# # TODO: make this work
# cabal exec -- ghc-mod browse MyModule
# >>>
# >>>= !0

View File

@ -0,0 +1,8 @@
#!/bin/sh
set -e
rm cabal.sandbox.config
rm -r .cabal-sandbox
cabal sandbox init

7
shelltest/version.test Normal file
View File

@ -0,0 +1,7 @@
cabal exec -- ghc-mod version
>>> /^ghc-mod version [0-9.]+ compiled by GHC [0-9.]+/
>>>= 0
cabal exec -- ghc-mod --version
>>> /^ghc-mod version [0-9.]+ compiled by GHC [0-9.]+/
>>>= 0