Run bindisttest when validating
[ghc-hetmet.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 [ "$CPUS" = "" ]; then
49     threads=2
50 else
51     threads=$(($CPUS + 1)) # `expr $CPUS + 1`
52 fi
53
54 if [ $testsuite_only -eq 0 ]; then
55
56 if [ $no_clean -eq 0 ]; then
57     make maintainer-clean NO_CLEAN_GMP=YES
58
59     INSTDIR=`pwd`/inst
60     if [ "$OSTYPE" = "cygwin" ]
61     then
62         INSTDIR=`cygpath -m "$INSTDIR"`
63     fi
64     case $OSTYPE in
65         cygwin|msys) config_args=--build=i386-unknown-mingw32
66             if [ -f c:/mingw/bin/gcc.exe ]
67             then
68                 config_args="$config_args --with-gcc=c:/mingw/bin/gcc"
69             fi
70             if [ -f c:/mingw/bin/ld.exe ]
71             then
72                 config_args="$config_args --with-ld=c:/mingw/bin/ld"
73             fi
74             ;;
75     esac
76
77     sh boot
78     ./configure --prefix="$INSTDIR" $config_args
79 fi
80
81 thisdir=`utils/ghc-pwd/ghc-pwd`
82
83 echo "Validating=YES" > mk/are-validating.mk
84
85 make -j$threads ValidateHpc=$hpc ValidateSlow=$slow
86 fi # testsuite-only
87
88 if [ "$hpc" = YES ]
89 then
90     # XXX With threads we'd need to give a different tix file to each thread
91     #     and then sum them up at the end
92     threads=1
93     HPCTIXFILE=$thisdir/testsuite/hpc_output/ghc.tix
94     export HPCTIXFILE
95     rm -f $HPCTIXFILE
96 fi
97
98 make binary-dist-prep
99 make -C bindisttest TEST_PREP=YES
100
101 make -C testsuite/tests/ghc-regress fast stage=2 CLEANUP=1 THREADS=$threads 2>&1 | tee testlog
102
103 if [ "$hpc" = YES ]
104 then
105     utils/hpc/hpc markup --hpcdir=. --srcdir=compiler --srcdir=testsuite/hpc_output --destdir=testsuite/hpc_output testsuite/hpc_output/ghc.tix
106 fi
107
108 echo "-------------------------------------------------------------------"
109 if
110     grep '\<0 caused framework failures' testlog >/dev/null 2>/dev/null &&
111     grep '\<0 unexpected passes' testlog >/dev/null 2>/dev/null &&
112     grep '\<0 unexpected failures' testlog >/dev/null 2>/dev/null ; then
113     if [ $testsuite_only -eq 0 ] && [ $no_clean -eq 0 ]
114     then
115         cat <<EOF
116 Congratulations!  This tree has passed minimal testing.
117
118 NOTE: If you have made changes that may cause failures not tested for by
119 the minimal testing procedure, please do further testing as necessary.
120
121 When you are satisfied that you haven't broken anything, go ahead and
122 push/send your patches.
123 EOF
124         if grep -q "^[^#]" mk/validate.mk
125         then
126             cat <<EOF
127
128 WARNING: You seem to have things set in mk/validate.mk. Please check
129 that it is OK before pushing.
130 EOF
131         fi
132         cat <<EOF
133 -------------------------------------------------------------------
134 EOF
135     else
136         cat <<EOF
137 I didn't find any problems, but this wasn't a complete validate run,
138 so be careful!
139
140 NOTE: If you have made changes that may cause failures not tested for by
141 the minimal testing procedure, please do further testing as necessary.
142 -------------------------------------------------------------------
143 EOF
144    fi
145 else
146     cat <<EOF
147 Oops!  Looks like you have some unexpected test results or framework failures.
148 Please fix them before pushing/sending patches.
149 -------------------------------------------------------------------
150 EOF
151     exit 1
152 fi
153