Make a "validate --hpc"; shows how much of the compiler the testsuite tests
[ghc.git] / validate
1 #!/bin/sh
2
3 # Flags:
4 #   --no-clean:       don't make clean first, just carry on from
5 #                     a previous interrupted validation run
6 #   --testsuite-only: don't build the compiler, just run
7 #                     the test suite
8 #   --hpc:            build stage2 with -fhpc, and see how much of the
9 #                     compiler the test suite covers
10
11 set -e
12
13 no_clean=0
14 testsuite_only=0
15 hpc=0
16
17 while [ $# -gt 0 ]
18 do
19     case "$1" in
20     --no-clean)
21         no_clean=1
22         ;;
23     --testsuite-only)
24         testsuite_only=1
25         ;;
26     --hpc)
27         hpc=1
28         ;;
29     *)
30         echo "Bad argument: $1" >&2
31         exit 1;;
32     esac
33     shift
34 done
35
36 if [ $testsuite_only -eq 0 ]; then
37
38 if [ $no_clean -eq 0 ] && [ -f mk/config.mk ]; then
39     make distclean
40 fi
41
42 case $OSTYPE in
43     cygwin|msys) config_args=--build=i386-unknown-mingw32
44         if [ -f c:/mingw/bin/gcc.exe ]
45         then
46             config_args="$config_args --with-gcc=c:/mingw/bin/gcc"
47         fi
48         ;;
49 esac
50
51 if [ "$CPUS" = "" ]; then
52     threads=2
53 else
54     threads=`expr $CPUS + 1`
55 fi
56
57 sh boot
58 ./configure "--prefix=`pwd`/inst" $config_args
59
60 thisdir=`utils/pwd/pwd forwardslash`
61
62 if [ "$hpc" = 1 ]
63 then
64     hpcflags="ValidateHpcFlags=-fhpc -hpcdir $thisdir/testsuite/hpc_output/"
65 fi
66
67 make Validating=YES -j$threads ${hpcflags+"$hpcflags"}
68 fi # testsuite-only
69
70 if [ "$hpc" = 1 ]
71 then
72     # XXX With threads we'd need to give a different tix file to each thread
73     #     and then sum them up at the end
74     threads=1
75     HPCTIXFILE=$thisdir/testsuite/hpc_output/ghc.tix
76     export HPCTIXFILE
77     rm -f $HPCTIXFILE
78 fi
79
80 make Validating=YES -C testsuite/tests/ghc-regress fast stage=2 CLEANUP=1 THREADS=$threads 2>&1 | tee testlog
81
82 if [ "$hpc" = 1 ]
83 then
84     utils/hpc/hpc markup --hpcdir=. --srcdir=compiler --srcdir=testsuite/hpc_output --destdir=testsuite/hpc_output testsuite/hpc_output/ghc.tix
85 fi
86
87 echo "-------------------------------------------------------------------"
88 if
89     grep '\<0 caused framework failures' testlog >/dev/null 2>/dev/null &&
90     grep '\<0 unexpected passes' testlog >/dev/null 2>/dev/null &&
91     grep '\<0 unexpected failures' testlog >/dev/null 2>/dev/null ; then
92     if [ $testsuite_only -eq 0 ] && [ $no_clean -eq 0 ]
93     then
94         cat <<EOF
95 Congratulations!  This tree has passed minimal testing.
96
97 NOTE: If you have made changes that may cause failures not tested for by
98 the minimal testing procedure, please do further testing as necessary.
99
100 When you are satisfied that you haven't broken anything, go ahead and
101 push/send your patches.
102 EOF
103     else
104         cat <<EOF
105 I didn't find any problems, but this wasn't a complete validate run,
106 so be careful!
107
108 NOTE: If you have made changes that may cause failures not tested for by
109 the minimal testing procedure, please do further testing as necessary.
110 EOF
111    fi
112 else
113     cat <<EOF
114 Oops!  Looks like you have some unexpected test results or framework failures.
115 Please fix them before pushing/sending patches.
116 EOF
117 fi
118 echo "-------------------------------------------------------------------"
119