Add a comment about how to do validate while capturing a debug log,
[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 #                     2008-07-01: 63% slower than the default.
11 #                     HTML generated here: testsuite/hpc_output/hpc_index.html
12 #   --fast:           Default. Opposite to --slow.
13 #   --slow:           Build stage2 with -DDEBUG.
14 #                     2008-07-01: 14% slower than the default.
15
16 set -e
17
18 no_clean=0
19 testsuite_only=0
20 hpc=NO
21 slow=NO
22
23 while [ $# -gt 0 ]
24 do
25     case "$1" in
26     --no-clean)
27         no_clean=1
28         ;;
29     --testsuite-only)
30         testsuite_only=1
31         ;;
32     --hpc)
33         hpc=YES
34         ;;
35     --slow)
36         slow=YES
37         ;;
38     --fast)
39         slow=NO
40         ;;
41     *)
42         echo "Bad argument: $1" >&2
43         exit 1;;
44     esac
45     shift
46 done
47
48 if [ "$THREADS" = "" ]; then
49     if [ "$CPUS" = "" ]; then
50         threads=2
51     else
52         threads=$(($CPUS + 1)) # `expr $CPUS + 1`
53     fi
54 else
55     threads="$THREADS"
56 fi
57
58 if type gmake > /dev/null 2> /dev/null
59 then
60     make="gmake"
61 else
62     make="make"
63 fi
64
65 if [ $testsuite_only -eq 0 ]; then
66
67 if [ $no_clean -eq 0 ]; then
68     $make maintainer-clean NO_CLEAN_GMP=YES
69
70     INSTDIR=`pwd`/inst
71     if [ "$OSTYPE" = "cygwin" ]
72     then
73         INSTDIR=`cygpath -m "$INSTDIR"`
74     fi
75
76     /usr/bin/perl -w boot --validate --required-tag=dph
77     ./configure --prefix="$INSTDIR" $config_args
78 fi
79
80 thisdir=`utils/ghc-pwd/dist-boot/ghc-pwd`
81
82 echo "Validating=YES" > mk/are-validating.mk
83
84 $make -j$threads ValidateHpc=$hpc ValidateSlow=$slow
85 # For a "debug make", add "--debug=b --debug=m"
86
87 $make binary-dist-prep
88 $make test_bindist TEST_PREP=YES
89
90 #
91 # Install the mtl package into the bindist, because it is used by some
92 # tests.  It isn't essential that we do this (the failing tests will
93 # be treated as expected failures), but we get a bit more test
94 # coverage, and also verify that we can install a package into the
95 # bindist with Cabal.
96 #
97 bindistdir="bindisttest/install dir"
98 cd libraries/mtl
99 "$thisdir/$bindistdir/bin/runhaskell" Setup.hs configure --with-ghc="$thisdir/$bindistdir/bin/ghc" --global --builddir=dist-bindist --prefix="$thisdir/$bindistdir"
100 "$thisdir/$bindistdir/bin/runhaskell" Setup.hs build  --builddir=dist-bindist
101 "$thisdir/$bindistdir/bin/runhaskell" Setup.hs install  --builddir=dist-bindist
102 "$thisdir/$bindistdir/bin/runhaskell" Setup.hs clean  --builddir=dist-bindist
103 cd $thisdir
104
105 fi # testsuite-only
106
107 if [ "$hpc" = YES ]
108 then
109     # XXX With threads we'd need to give a different tix file to each thread
110     #     and then sum them up at the end
111     threads=1
112     HPCTIXFILE=$thisdir/testsuite/hpc_output/ghc.tix
113     export HPCTIXFILE
114     rm -f $HPCTIXFILE
115 fi
116
117 if [ "$slow" = YES ]
118 then
119 MAKE_TEST_TARGET=fulltest
120 else
121 MAKE_TEST_TARGET=test
122 fi
123
124 $make $MAKE_TEST_TARGET stage=2 BINDIST=YES THREADS=$threads 2>&1 | tee testlog
125
126 if [ "$hpc" = YES ]
127 then
128     utils/hpc/hpc markup --hpcdir=. --srcdir=compiler --srcdir=testsuite/hpc_output --destdir=testsuite/hpc_output testsuite/hpc_output/ghc.tix
129 fi
130
131 echo "-------------------------------------------------------------------"
132 if
133     grep '\<0 caused framework failures' testlog >/dev/null 2>/dev/null &&
134     grep '\<0 unexpected passes' testlog >/dev/null 2>/dev/null &&
135     grep '\<0 unexpected failures' testlog >/dev/null 2>/dev/null ; then
136     if [ $testsuite_only -eq 0 ] && [ $no_clean -eq 0 ]
137     then
138         cat <<EOF
139 Congratulations!  This tree has passed minimal testing.
140
141 NOTE: If you have made changes that may cause failures not tested for by
142 the minimal testing procedure, please do further testing as necessary.
143
144 When you are satisfied that you haven't broken anything, go ahead and
145 push/send your patches.
146 EOF
147         if grep -q "^[^#]" mk/validate.mk
148         then
149             cat <<EOF
150
151 WARNING: You seem to have things set in mk/validate.mk. Please check
152 that it is OK before pushing.
153 EOF
154         fi
155         cat <<EOF
156 -------------------------------------------------------------------
157 EOF
158     else
159         cat <<EOF
160 I didn't find any problems, but this wasn't a complete validate run,
161 so be careful!
162
163 NOTE: If you have made changes that may cause failures not tested for by
164 the minimal testing procedure, please do further testing as necessary.
165 -------------------------------------------------------------------
166 EOF
167    fi
168 else
169     cat <<EOF
170 Oops!  Looks like you have some unexpected test results or framework failures.
171 Please fix them before pushing/sending patches.
172 -------------------------------------------------------------------
173 EOF
174     exit 1
175 fi
176