Commits

Jasper Van der Jeugt committed 35736a7

Port Makefile/script to generate coverage reports

Comments (0)

Files changed (3)

tests/tests/Makefile

+coverage: build coverage/hpc_index.html
+
+build:
+	cabal configure -fhpc
+	cabal build
+
+coverage/text-tests.tix:
+	-mkdir -p coverage
+	./dist/build/text-tests/text-tests
+	mv text-tests.tix $@
+
+coverage/text-tests-stdio.tix:
+	-mkdir -p coverage
+	./scripts/cover-stdio.sh ./dist/build/text-tests-stdio/text-tests-stdio
+	mv text-tests-stdio.tix $@
+
+coverage/coverage.tix: coverage/text-tests.tix coverage/text-tests-stdio.tix
+	hpc combine --output=$@ \
+        --exclude=Main \
+        coverage/text-tests.tix \
+        coverage/text-tests-stdio.tix
+
+coverage/hpc_index.html: coverage/coverage.tix
+	hpc markup --destdir=coverage coverage/coverage.tix
+
+clean:
+	rm -rf dist coverage .hpc
+
+.PHONY: build coverage

tests/tests/scripts/cover-stdio.sh

+#!/bin/bash
+
+if [[ $# < 1 ]]; then
+    echo "Usage: $0 <exe>"
+    exit 1
+fi
+
+exe=$1
+
+rm -f $exe.tix
+
+f=$(mktemp stdio-f.XXXXXX)
+g=$(mktemp stdio-g.XXXXXX)
+
+for t in T TL; do
+    echo $t.readFile > $f
+    $exe $t.readFile $f > $g
+    if ! diff -u $f $g; then
+	errs=$((errs+1))
+	echo FAIL: $t.readFile 1>&2
+    fi
+
+    $exe $t.writeFile $f $t.writeFile
+    echo -n $t.writeFile > $g
+    if ! diff -u $f $g; then
+	errs=$((errs+1))
+	echo FAIL: $t.writeFile 1>&2
+    fi
+
+    echo -n quux > $f
+    $exe $t.appendFile $f $t.appendFile
+    echo -n quux$t.appendFile > $g
+    if ! diff -u $f $g; then
+	errs=$((errs+1))
+	echo FAIL: $t.appendFile 1>&2
+    fi
+
+    echo $t.interact | $exe $t.interact > $f
+    echo $t.interact > $g
+    if ! diff -u $f $g; then
+	errs=$((errs+1))
+	echo FAIL: $t.interact 1>&2
+    fi
+
+    echo $t.getContents | $exe $t.getContents > $f
+    echo $t.getContents > $g
+    if ! diff -u $f $g; then
+	errs=$((errs+1))
+	echo FAIL: $t.getContents 1>&2
+    fi
+
+    echo $t.getLine | $exe $t.getLine > $f
+    echo $t.getLine > $g
+    if ! diff -u $f $g; then
+	errs=$((errs+1))
+	echo FAIL: $t.getLine 1>&2
+    fi
+done
+
+rm -f $f $g
+
+exit $errs

tests/tests/text-tests.cabal

 category:      Text
 build-type:    Simple
 
-cabal-version: >=1.2
+cabal-version: >=1.8
 
 flag hpc
   description: Enable HPC to generate coverage reports
   default:     False
 
 executable text-tests
-  hs-source-dirs: src ../..
+  hs-source-dirs: src
   main-is:        Data/Text/Tests.hs
 
   ghc-options:
     -threaded
     -O0
 
-  -- Optional HPC support
   if flag(hpc)
     ghc-options:
       -fhpc
     -DHAVE_DEEPSEQ
 
   build-depends:
+    text-tests,
     base                       >= 4   && < 5,
     bytestring                 >= 0.9 && < 0.10,
     deepseq                    >= 1.1 && < 1.2,
     test-framework-hunit       >= 0.2 && < 0.3
 
 executable text-tests-stdio
-  hs-source-dirs: src ../..
+  hs-source-dirs: src
   main-is:        Data/Text/Tests/IO.hs
 
   ghc-options:
       -fhpc
 
   build-depends:
+    text-tests,
     base >= 4 && < 5
+
+library
+  hs-source-dirs: ../..
+  exposed-modules:
+    Data.Text
+    Data.Text.Array
+    Data.Text.Encoding
+    Data.Text.Encoding.Error
+    Data.Text.Foreign
+    Data.Text.IO
+    Data.Text.Internal
+    Data.Text.Lazy
+    Data.Text.Lazy.Builder
+    Data.Text.Lazy.Builder.Int
+    Data.Text.Lazy.Builder.RealFloat
+    Data.Text.Lazy.Encoding
+    Data.Text.Lazy.IO
+    Data.Text.Lazy.Internal
+    Data.Text.Lazy.Read
+    Data.Text.Read
+    Data.Text.Encoding.Fusion
+    Data.Text.Encoding.Fusion.Common
+    Data.Text.Encoding.Utf16
+    Data.Text.Encoding.Utf32
+    Data.Text.Encoding.Utf8
+    Data.Text.Fusion
+    Data.Text.Fusion.CaseMapping
+    Data.Text.Fusion.Common
+    Data.Text.Fusion.Internal
+    Data.Text.Fusion.Size
+    Data.Text.IO.Internal
+    Data.Text.Lazy.Builder.Functions
+    Data.Text.Lazy.Builder.RealFloat.Functions
+    Data.Text.Lazy.Encoding.Fusion
+    Data.Text.Lazy.Fusion
+    Data.Text.Lazy.Search
+    Data.Text.Search
+    Data.Text.Unsafe
+    Data.Text.UnsafeChar
+    Data.Text.UnsafeShift
+    Data.Text.Util
+
+  if flag(hpc)
+    ghc-options:
+      -fhpc
+
+  cpp-options:
+    -DHAVE_DEEPSEQ
+    -DASSERTS
+    -DINTEGER_GMP
+
+  build-depends:
+    array,
+    base        >= 4   && < 5,
+    bytestring  >= 0.9 && < 1.0,
+    deepseq     >= 1.1 && < 1.2,
+    integer-gmp >= 0.2 && < 0.3,
+    ghc-prim    >= 0.2 && < 0.3