Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/actions/spelling/expect.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
boolopts
Cpphs
ekat
exts
deepseq
Felgenhauer
FSolution
gfoldl
gmap
ifdef
IOrep
IOTASKS
KPatterns
Leijen
lhs
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/haskell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ jobs:
- name: Build and test
run: |
set -ex
stack --no-terminal test --coverage --bench --no-run-benchmarks --haddock --no-haddock-deps
stack --no-terminal test --coverage --haddock --no-haddock-deps
stack --no-terminal test --coverage --haddock --no-haddock-deps --flag haskell-template-task-raw:-iotasks
cd raw/embedded
stack --no-terminal test --coverage --bench --no-run-benchmarks --haddock --no-haddock-deps
stack --no-terminal test --coverage --haddock --no-haddock-deps
stack --no-terminal test --coverage --haddock --no-haddock-deps --flag haskell-template-task-embedded:-iotasks
set +ex
env:
BUILD: ${{ matrix.plan.build }}
10 changes: 9 additions & 1 deletion raw/embedded/haskell-template-task-embedded.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ name: haskell-template-task-embedded
version: 0.0.0
build-type: Simple

flag iotasks
description: enables test helpers for IOTasks
manual: True
default: True

library
other-modules:
TestHarness
Expand All @@ -19,11 +24,14 @@ library
ghc-options: -Wall
build-depends:
HUnit
, IOTasks
, QuickCheck
, base
, deepseq
, haskell-src-exts
, random
, syb
default-language: Haskell2010
if flag(iotasks)
cpp-options: -DIOTASKS
build-depends:
IOTasks
14 changes: 12 additions & 2 deletions raw/embedded/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,27 @@
name: haskell-template-task-embedded
ghc-options:
-Wall
flags:
iotasks:
description: enables test helpers for IOTasks
manual: True
default: True
dependencies:
- base
- deepseq
- haskell-src-exts
- HUnit
- IOTasks
- QuickCheck
- random
- syb
library:
source-dirs: src
source-dirs:
- src
other-modules:
- TestHarness
- TestHelper
when:
- condition: flag(iotasks)
dependencies:
- IOTasks
cpp-options: -DIOTASKS
29 changes: 23 additions & 6 deletions raw/embedded/src/TestHelper.hs
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE ScopedTypeVariables #-}
module TestHelper (
isDefined, isDeeplyDefined, mustFail,
qcWithTimeout, qcWithTimeoutAndArgs, qcWithTimeoutAndRuns
, qc, qc', qcWithArgs --DEPRECATED
, tcWithTimeout, tcWithTimeoutAndArgs, tcCustomizedWithTimeoutAndArgs, tcWithInputsOnFailure
isDefined,
isDeeplyDefined,
mustFail,
qcWithTimeout,
qcWithTimeoutAndArgs,
qcWithTimeoutAndRuns,
qc,
qc',
qcWithArgs, --DEPRECATED
#ifdef IOTASKS
tcWithTimeout,
tcWithTimeoutAndArgs,
tcCustomizedWithTimeoutAndArgs,
tcWithInputsOnFailure,
#endif
) where
import Prelude (
Bool (..), Either (Left, Right), Int, IO, String, Maybe (Nothing, Just),
const, error, return, seq, ($), (++), show, (.), id)
Bool (..), Either (Left, Right), Int, IO, String,
const, error, return, seq, ($), (++))

import Control.Exception
(ErrorCall, SomeException, catch, evaluate, try)
Expand All @@ -19,8 +31,9 @@
import Test.QuickCheck.Monadic (monadicIO, run)
import Control.DeepSeq (NFData, deepseq)

#ifdef IOTASKS
import Test.IOTasks (
IOrep,

Check notice on line 36 in raw/embedded/src/TestHelper.hs

View workflow job for this annotation

GitHub Actions / Check Spelling

Line matches candidate pattern `\bI(?=(?:[A-Z][a-z]{2,})+\b)` (candidate-pattern)
Specification,
taskCheckWithOutcome,
feedbackStyle,
Expand All @@ -33,7 +46,9 @@
Outcome (..),
stdArgs,
)
import Prelude (Maybe(..), (.), id, show)
import qualified System.Timeout as System (timeout)
#endif

qcWithArgs :: Testable prop => Int -> Args -> prop -> Assertion
qcWithArgs = qcWithTimeoutAndArgs
Expand Down Expand Up @@ -82,6 +97,7 @@
(seq x $ return True)
((const $ return False) :: ErrorCall -> IO Bool)

#ifdef IOTASKS
-- helper for new IOTasks implementation
tcWithTimeout :: Int -> IOrep () -> Specification -> Assertion
tcWithTimeout to = tcWithTimeoutAndArgs to IOTasks.stdArgs
Expand Down Expand Up @@ -117,3 +133,4 @@
"Gave up on testing. This is usually not caused by a fault within your solution. Please contact your lecturers"
Just o@(IOTasks.Outcome IOTasks.Failure{} _) -> assertFailure $ withFailure o
Nothing -> assertFailure "Failure: Timeout"
#endif
8 changes: 8 additions & 0 deletions raw/haskell-template-task-raw.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ name: haskell-template-task-raw
version: 0.0.0.1
build-type: Simple

flag iotasks
description: enables test helpers for IOTasks
manual: True
default: True

library
exposed-modules:
Haskell.Template.FileContents
Expand All @@ -18,7 +23,10 @@ library
ghc-options: -Wall
build-depends:
base >=4.7 && <5
, cpphs
, filepath
, template-haskell
, th-utilities
default-language: Haskell2010
if flag(iotasks)
cpp-options: -DIOTASKS
9 changes: 9 additions & 0 deletions raw/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,20 @@ name: haskell-template-task-raw
version: 0.0.0.1
ghc-options:
- -Wall
flags:
iotasks:
description: enables test helpers for IOTasks
manual: True
default: True
dependencies:
- base >= 4.7 && < 5
- filepath
- cpphs
- template-haskell
- th-utilities
when:
- condition: flag(iotasks)
cpp-options: -DIOTASKS

library:
source-dirs: src
20 changes: 19 additions & 1 deletion raw/src/Haskell/Template/FileContents.hs
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE TemplateHaskell #-}
{-# OPTIONS -fforce-recomp #-}
module Haskell.Template.FileContents (
testHarnessContents,
testHelperContents,
) where

import Language.Preprocessor.Cpphs (
BoolOptions(..),
CpphsOptions(..),
defaultBoolOptions,
defaultCpphsOptions,
runCpphs
)
import Language.Haskell.TH (runIO, stringE)
import System.FilePath ((</>))
import TH.RelativePaths (pathRelativeToCabalPackage)
Expand All @@ -13,7 +21,17 @@ testHelperContents :: String
testHelperContents =
$(do file <- pathRelativeToCabalPackage
$ "embedded" </> "src" </> "TestHelper.hs"
contents <- runIO $ readFile file
contents <- runIO $ readFile file >>= runCpphs defaultCpphsOptions {
defines = [
#ifdef IOTASKS
("IOTASKS", "")
#else

#endif
],
boolopts = defaultBoolOptions {locations = False}
}
""
stringE contents)

testHarnessContents :: String
Expand Down
Loading