on master help sign in
Port Makefile/script to generate coverage reports
commit1f4236376a69887632a99013b81cc036408775c8 authorJasper Van der Jeugt <jaspervdj@gmail.com> dateWed 22 Jun 2011, 14:30 (15 years ago) parent30c8db3
3 files changed+154−4
tests/tests/Makefile+29 tests/tests/scripts/cover-stdio.sh+62 tests/tests/text-tests.cabal+63−4
tests/tests/Makefilenew file+29
@@ -0,0 +1,29 @@
1+coverage: build coverage/hpc_index.html
2+
3+build:
4+ cabal configure -fhpc
5+ cabal build
6+
7+coverage/text-tests.tix:
8+ -mkdir -p coverage
9+ ./dist/build/text-tests/text-tests
10+ mv text-tests.tix $@
11+
12+coverage/text-tests-stdio.tix:
13+ -mkdir -p coverage
14+ ./scripts/cover-stdio.sh ./dist/build/text-tests-stdio/text-tests-stdio
15+ mv text-tests-stdio.tix $@
16+
17+coverage/coverage.tix: coverage/text-tests.tix coverage/text-tests-stdio.tix
18+ hpc combine --output=$@ \
19+ --exclude=Main \
20+ coverage/text-tests.tix \
21+ coverage/text-tests-stdio.tix
22+
23+coverage/hpc_index.html: coverage/coverage.tix
24+ hpc markup --destdir=coverage coverage/coverage.tix
25+
26+clean:
27+ rm -rf dist coverage .hpc
28+
29+.PHONY: build coverage
tests/tests/scripts/cover-stdio.shnew file+62
@@ -0,0 +1,62 @@
1+#!/bin/bash
2+
3+if [[ $# < 1 ]]; then
4+ echo "Usage: $0 <exe>"
5+ exit 1
6+fi
7+
8+exe=$1
9+
10+rm -f $exe.tix
11+
12+f=$(mktemp stdio-f.XXXXXX)
13+g=$(mktemp stdio-g.XXXXXX)
14+
15+for t in T TL; do
16+ echo $t.readFile > $f
17+ $exe $t.readFile $f > $g
18+ if ! diff -u $f $g; then
19+ errs=$((errs+1))
20+ echo FAIL: $t.readFile 1>&2
21+ fi
22+
23+ $exe $t.writeFile $f $t.writeFile
24+ echo -n $t.writeFile > $g
25+ if ! diff -u $f $g; then
26+ errs=$((errs+1))
27+ echo FAIL: $t.writeFile 1>&2
28+ fi
29+
30+ echo -n quux > $f
31+ $exe $t.appendFile $f $t.appendFile
32+ echo -n quux$t.appendFile > $g
33+ if ! diff -u $f $g; then
34+ errs=$((errs+1))
35+ echo FAIL: $t.appendFile 1>&2
36+ fi
37+
38+ echo $t.interact | $exe $t.interact > $f
39+ echo $t.interact > $g
40+ if ! diff -u $f $g; then
41+ errs=$((errs+1))
42+ echo FAIL: $t.interact 1>&2
43+ fi
44+
45+ echo $t.getContents | $exe $t.getContents > $f
46+ echo $t.getContents > $g
47+ if ! diff -u $f $g; then
48+ errs=$((errs+1))
49+ echo FAIL: $t.getContents 1>&2
50+ fi
51+
52+ echo $t.getLine | $exe $t.getLine > $f
53+ echo $t.getLine > $g
54+ if ! diff -u $f $g; then
55+ errs=$((errs+1))
56+ echo FAIL: $t.getLine 1>&2
57+ fi
58+done
59+
60+rm -f $f $g
61+
62+exit $errs
tests/tests/text-tests.cabal+63−4
@@ -13,14 +13,14 @@ maintainer: Bryan O'Sullivan <bos@serpentine.com>
1313category: Text
1414build-type: Simple
1515
16−cabal-version: >=1.2
16+cabal-version: >=1.8
1717
1818flag hpc
1919 description: Enable HPC to generate coverage reports
2020 default: False
2121
2222executable text-tests
23− hs-source-dirs: src ../..
23+ hs-source-dirs: src
2424 main-is: Data/Text/Tests.hs
2525
2626 ghc-options:
@@ -28,7 +28,6 @@ executable text-tests
2828 -threaded
2929 -O0
3030
31− -- Optional HPC support
3231 if flag(hpc)
3332 ghc-options:
3433 -fhpc
@@ -38,6 +37,7 @@ executable text-tests
3837 -DHAVE_DEEPSEQ
3938
4039 build-depends:
40+ text-tests,
4141 base >= 4 && < 5,
4242 bytestring >= 0.9 && < 0.10,
4343 deepseq >= 1.1 && < 1.2,
@@ -50,7 +50,7 @@ executable text-tests
5050 test-framework-hunit >= 0.2 && < 0.3
5151
5252executable text-tests-stdio
53− hs-source-dirs: src ../..
53+ hs-source-dirs: src
5454 main-is: Data/Text/Tests/IO.hs
5555
5656 ghc-options:
@@ -63,4 +63,63 @@ executable text-tests-stdio
6363 -fhpc
6464
6565 build-depends:
66+ text-tests,
6667 base >= 4 && < 5
68+
69+library
70+ hs-source-dirs: ../..
71+ exposed-modules:
72+ Data.Text
73+ Data.Text.Array
74+ Data.Text.Encoding
75+ Data.Text.Encoding.Error
76+ Data.Text.Foreign
77+ Data.Text.IO
78+ Data.Text.Internal
79+ Data.Text.Lazy
80+ Data.Text.Lazy.Builder
81+ Data.Text.Lazy.Builder.Int
82+ Data.Text.Lazy.Builder.RealFloat
83+ Data.Text.Lazy.Encoding
84+ Data.Text.Lazy.IO
85+ Data.Text.Lazy.Internal
86+ Data.Text.Lazy.Read
87+ Data.Text.Read
88+ Data.Text.Encoding.Fusion
89+ Data.Text.Encoding.Fusion.Common
90+ Data.Text.Encoding.Utf16
91+ Data.Text.Encoding.Utf32
92+ Data.Text.Encoding.Utf8
93+ Data.Text.Fusion
94+ Data.Text.Fusion.CaseMapping
95+ Data.Text.Fusion.Common
96+ Data.Text.Fusion.Internal
97+ Data.Text.Fusion.Size
98+ Data.Text.IO.Internal
99+ Data.Text.Lazy.Builder.Functions
100+ Data.Text.Lazy.Builder.RealFloat.Functions
101+ Data.Text.Lazy.Encoding.Fusion
102+ Data.Text.Lazy.Fusion
103+ Data.Text.Lazy.Search
104+ Data.Text.Search
105+ Data.Text.Unsafe
106+ Data.Text.UnsafeChar
107+ Data.Text.UnsafeShift
108+ Data.Text.Util
109+
110+ if flag(hpc)
111+ ghc-options:
112+ -fhpc
113+
114+ cpp-options:
115+ -DHAVE_DEEPSEQ
116+ -DASSERTS
117+ -DINTEGER_GMP
118+
119+ build-depends:
120+ array,
121+ base >= 4 && < 5,
122+ bytestring >= 0.9 && < 1.0,
123+ deepseq >= 1.1 && < 1.2,
124+ integer-gmp >= 0.2 && < 0.3,
125+ ghc-prim >= 0.2 && < 0.3