Tell the testsuite how many threads we want it to use 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
9 set -e
10
11 no_clean=0
12 testsuite_only=0
13
14 while [ $# -gt 0 ]
15 do
16     case "$1" in
17     --no-clean)
18         no_clean=1
19         ;;
20     --testsuite-only)
21         testsuite_only=1
22         ;;
23     *)
24         echo "Bad argument: $1" >&2
25         exit 1;;
26     esac
27     shift
28 done
29
30 if [ $testsuite_only -eq 0 ]; then
31
32 if [ $no_clean -eq 0 ] && [ -f mk/config.mk ]; then
33     make distclean
34 fi
35
36 case $OSTYPE in
37     cygwin|msys) config_args=--build=i386-unknown-mingw32
38         if [ -f c:/mingw/bin/gcc.exe ]
39         then
40             config_args="$config_args --with-gcc=c:/mingw/bin/gcc"
41         fi
42         ;;
43 esac
44
45 if [ "$CPUS" = "" ]; then
46     threads=2
47 else
48     threads=`expr $CPUS + 1`
49 fi
50
51 sh boot
52 ./configure "--prefix=`pwd`/inst" $config_args
53
54 make Validating=YES -j$threads
55 fi # testsuite-only
56
57 make Validating=YES -C testsuite/tests/ghc-regress fast stage=2 CLEANUP=1 THREADS=$threads 2>&1 | tee testlog
58
59 echo "-------------------------------------------------------------------"
60 if
61     grep '\<0 caused framework failures' testlog >/dev/null 2>/dev/null &&
62     grep '\<0 unexpected passes' testlog >/dev/null 2>/dev/null &&
63     grep '\<0 unexpected failures' testlog >/dev/null 2>/dev/null ; then
64     if [ $testsuite_only -eq 0 ] && [ $no_clean -eq 0 ]
65     then
66         cat <<EOF
67 Congratulations!  This tree has passed minimal testing.
68
69 NOTE: If you have made changes that may cause failures not tested for by
70 the minimal testing procedure, please do further testing as necessary.
71
72 When you are satisfied that you haven't broken anything, go ahead and
73 push/send your patches.
74 EOF
75     else
76         cat <<EOF
77 I didn't find any problems, but this wasn't a complete validate run,
78 so be careful!
79
80 NOTE: If you have made changes that may cause failures not tested for by
81 the minimal testing procedure, please do further testing as necessary.
82 EOF
83    fi
84 else
85     cat <<EOF
86 Oops!  Looks like you have some unexpected test results or framework failures.
87 Please fix them before pushing/sending patches.
88 EOF
89 fi
90 echo "-------------------------------------------------------------------"
91