@@ -31,6 +31,9 @@ RUNNING_TESTS=y
31source $SCRIPT_DIR/build-lib.sh
31source $SCRIPT_DIR/build-lib.sh
33set_common_vars
33set_common_vars
35# XXX add a bisect option
38# XXX add a bisect option
36while test -n "$1"
39while test -n "$1"
@@ -40,11 +43,14 @@ do
40 # options with arguments
43 # options with arguments
41 --targets) shift; TARGETS=$1; shift ;;
44 --targets) shift; TARGETS=$1; shift ;;
42 --cabal-build-options) shift; CABAL_BUILD_OPTIONS=$1; shift ;;
45 --cabal-build-options) shift; CABAL_BUILD_OPTIONS=$1; shift ;;
46+ --hpc-report-options) shift; HPC_REPORT_OPTIONS=$1; shift ;;
43 --rtsopts) shift; RTS_OPTIONS=$1; shift ;;
47 --rtsopts) shift; RTS_OPTIONS=$1; shift ;;
45 --slow) SLOW=1; shift ;;
49 --slow) SLOW=1; shift ;;
46 --quick) QUICK_MODE=1; shift ;;
50 --quick) QUICK_MODE=1; shift ;;
47 --dev-build) RUNNING_DEVBUILD=1; shift ;;
51 --dev-build) RUNNING_DEVBUILD=1; shift ;;
52+ --coverage) COVERAGE=1; shift ;;
53+ --no-measure) MEASURE=0; shift ;;
48 --) shift; break ;;
54 --) shift; break ;;
49 -*|--*) echo "Unknown flags: $*"; echo; print_help ;;
55 -*|--*) echo "Unknown flags: $*"; echo; print_help ;;
50 *) break ;;
56 *) break ;;
@@ -77,7 +83,12 @@ echo "Using targets [$TARGETS]"
78test_exe_rts_opts () {
84test_exe_rts_opts () {
79 case "$1" in
85 case "$1" in
86+ *) if test "$COVERAGE" -eq "1"
88+ echo -n "-K8M -M1024M"
80− *) echo -n "-K8M -M64M" ;;
90+ echo -n "-K8M -M64M"
@@ -93,11 +104,51 @@ target_exe_extra_args () {
107+if test "$COVERAGE" -eq "1"
109+ # With the --enable-coverage option the tests as well as the library get
110+ # compiled with -fhpc, and we get coverage for tests as well. But we want to
111+ # exclude that, so a project file is needed.
112+ CABAL_BUILD_OPTIONS+=" --project-file cabal.project.coverage"
113+ mkdir -p $BUILD_DIR/coverage
96BUILD_TEST="$CABAL_EXECUTABLE v2-build $CABAL_BUILD_OPTIONS --enable-tests"
115BUILD_TEST="$CABAL_EXECUTABLE v2-build $CABAL_BUILD_OPTIONS --enable-tests"
117+if test "$MEASURE" -eq "1"
97run_build "$BUILD_TEST" streamly-tests test "$TARGETS"
119run_build "$BUILD_TEST" streamly-tests test "$TARGETS"
99#-----------------------------------------------------------------------------
122#-----------------------------------------------------------------------------
100# Run targets
123# Run targets
101#-----------------------------------------------------------------------------
124#-----------------------------------------------------------------------------
126+if test "$MEASURE" -eq "1"
103−run_targets streamly-tests "$TARGETS" target_exe_extra_args
128+run_targets streamly-tests t "$TARGETS" target_exe_extra_args
131+#-----------------------------------------------------------------------------
132+# Run coverage reports
133+#-----------------------------------------------------------------------------
135+if test "$COVERAGE" -eq "1"
140+ TIXFILES+="$BUILD_DIR/coverage/${i}.tix "
144+ Linux) SYSTEM=x86_64-linux ;;
145+ *) echo "Unsupported system"; exit 1 ;;
148+ ALLTIX=$BUILD_DIR/coverage/all.tix
149+ hpc sum --output=$ALLTIX $TIXFILES
150+ run_verbose hpc markup $ALLTIX --hpcdir \
151+ $BUILD_DIR/build/$SYSTEM/ghc-${GHC_VERSION}/streamly-0.7.2/hpc/vanilla/mix/streamly-0.7.2/
152+ run_verbose hpc report $ALLTIX $HPC_REPORT_OPTIONS --hpcdir \
153+ $BUILD_DIR/build/$SYSTEM/ghc-${GHC_VERSION}/streamly-0.7.2/hpc/vanilla/mix/streamly-0.7.2/