Fix Trac #10618 (out of scope operator)
[ghc.git] / validate
index 3e1fde6..fbf3c1b 100755 (executable)
--- a/validate
+++ b/validate
@@ -20,7 +20,8 @@ Flags:
                     HTML generated here: testsuite/hpc_output/hpc_index.html
   --normal          Default settings
   --fast            Omit dyn way, omit binary distribution
-  --slow            Build stage2 with -DDEBUG.
+  --slow            Build stage2 with -DDEBUG. Skips tests that call
+                    `compiler_stats_num_field`.
                     2008-07-01: 14% slower than the default.
   --dph:            Also build libraries/dph and run associated tests.
   --help            shows this usage help.
@@ -38,6 +39,7 @@ testsuite_only=0
 hpc=NO
 speed=NORMAL
 use_dph=0
+be_quiet=0
 
 while [ $# -gt 0 ]
 do
@@ -60,9 +62,15 @@ do
     --normal)
         speed=NORMAL
         ;;
+    --no-dph) # for backward compat
+        use_dph=0
+        ;;
     --dph)
         use_dph=1
         ;;
+    --quiet)
+        be_quiet=1
+        ;;
     --help)
         show_help
         exit 0;;
@@ -75,16 +83,49 @@ do
 done
 
 check_packages () {
-    echo "== Start $1 package check"
     if [ "$bindistdir" = "" ]
     then
-        inplace/bin/ghc-pkg check -v
+        ghc_pkg=inplace/bin/ghc-pkg
     else
-        "$bindistdir"/bin/ghc-pkg check -v
+        ghc_pkg="$bindistdir"/bin/ghc-pkg
+    fi
+
+    if [ $be_quiet -eq 1 ]
+    then
+        "$ghc_pkg" check
+    else
+        echo "== Start $1 package check"
+        "$ghc_pkg" check -v
+        echo "== End $1 package check"
+    fi
+}
+
+detect_cpu_count () {
+    if [ "$CPUS" = "" ]; then
+        # Windows standard environment variable
+        CPUS="$NUMBER_OF_PROCESSORS"
+    fi
+
+    if [ "$CPUS" = "" ]; then
+        # Linux
+        CPUS=`getconf _NPROCESSORS_ONLN 2>/dev/null`
+    fi
+
+    if [ "$CPUS" = "" ]; then
+        # FreeBSD
+        CPUS=`getconf NPROCESSORS_ONLN 2>/dev/null`
+    fi
+
+    if [ "$CPUS" = "" ]; then
+        # nothing helped
+        CPUS="1"
     fi
-    echo "== End $1 package check"
+
+    echo "using ${CPUS} CPUs" >&2
 }
 
+detect_cpu_count
+
 if ! [ -d testsuite ]
 then
     echo 'Could not find the testsuite for validation' >&2
@@ -92,20 +133,16 @@ then
 fi
 
 if [ "$THREADS" = "" ]; then
-    if [ "$CPUS" = "" ]; then
-        threads=2
-    else
-        threads=$(($CPUS + 1)) # `expr $CPUS + 1`
-    fi
+    threads=$(($CPUS + 1)) # `expr $CPUS + 1`
 else
     threads="$THREADS"
 fi
 
 if type gmake > /dev/null 2> /dev/null
 then
-    make="gmake"
+    make="gmake -s"
 else
-    make="make"
+    make="make -s"
 fi
 
 if [ $testsuite_only -eq 0 ]; then
@@ -120,9 +157,9 @@ if [ $no_clean -eq 0 ]; then
     fi
 
     if [ $use_dph -eq 1 ]; then
-        /usr/bin/perl -w boot --validate --required-tag=dph
+        perl -w boot --validate --required-tag=dph
     else
-        /usr/bin/perl -w boot --validate
+        perl -w boot --validate
     fi
     ./configure --prefix="$INSTDIR" $config_args
 fi
@@ -132,6 +169,7 @@ thisdir=`utils/ghc-pwd/dist-boot/ghc-pwd`
 echo "Validating=YES"       >  mk/are-validating.mk
 echo "ValidateSpeed=$speed" >> mk/are-validating.mk
 echo "ValidateHpc=$hpc"     >> mk/are-validating.mk
+echo "V=0"                  >> mk/are-validating.mk # Less gunk
 
 if [ $use_dph -eq 1 ]; then
     echo "BUILD_DPH=YES"    >> mk/are-validating.mk
@@ -187,16 +225,22 @@ SLOW)
         BINDIST="BINDIST=YES"
         ;;
 NORMAL)
-        MAKE_TEST_TARGET=test
+        MAKE_TEST_TARGET=fasttest
         BINDIST="BINDIST=YES"
         ;;
 FAST)
-        MAKE_TEST_TARGET=test
+        MAKE_TEST_TARGET=fasttest
         BINDIST="BINDIST=NO"
         ;;
 esac
 
-$make $MAKE_TEST_TARGET stage=2 $BINDIST THREADS=$threads 2>&1 | tee testlog
+if [ $be_quiet -eq 1 ]; then
+    TEST_VERBOSITY="VERBOSE=1 NO_PRINT_SUMMARY=YES"
+else
+    TEST_VERBOSITY="VERBOSE=2"
+fi
+
+$make $MAKE_TEST_TARGET stage=2 $BINDIST $TEST_VERBOSITY THREADS=$threads 2>&1 | tee testlog
 
 check_packages post-testsuite
 
@@ -205,15 +249,16 @@ then
     utils/hpc/hpc markup --hpcdir=. --srcdir=compiler --srcdir=testsuite/hpc_output --destdir=testsuite/hpc_output testsuite/hpc_output/ghc.tix
 fi
 
-echo "-------------------------------------------------------------------"
 if
-    grep '\<0 caused framework failures' testlog >/dev/null 2>/dev/null &&
-    grep '\<0 unexpected passes' testlog >/dev/null 2>/dev/null &&
-    grep '\<0 unexpected failures' testlog >/dev/null 2>/dev/null &&
-    ! grep 'Some files are written by multiple tests' testlog >/dev/null 2>/dev/null ; then
+    grep '\<0 caused framework failures' testsuite_summary.txt >/dev/null 2>/dev/null &&
+    grep '\<0 unexpected passes' testsuite_summary.txt >/dev/null 2>/dev/null &&
+    grep '\<0 unexpected failures' testsuite_summary.txt >/dev/null 2>/dev/null &&
+    grep '\<0 unexpected stat failures' testsuite_summary.txt >/dev/null 2>/dev/null &&
+    ! grep 'Some files are written by multiple tests' testsuite_summary.txt >/dev/null 2>/dev/null ; then
     if [ $testsuite_only -eq 0 ] && [ $no_clean -eq 0 ]
     then
         cat <<EOF
+-------------------------------------------------------------------
 Congratulations!  This tree has passed minimal testing.
 
 NOTE: If you have made changes that may cause failures not tested for by
@@ -235,6 +280,7 @@ EOF
 EOF
     else
         cat <<EOF
+-------------------------------------------------------------------
 I didn't find any problems, but this wasn't a complete validate run,
 so be careful!
 
@@ -244,11 +290,14 @@ the minimal testing procedure, please do further testing as necessary.
 EOF
    fi
 else
-    cat <<EOF
+    if [ $be_quiet -eq 0 ]
+    then
+       cat <<EOF
+-------------------------------------------------------------------
 Oops!  Looks like you have some unexpected test results or framework failures.
 Please fix them before pushing/sending patches.
 -------------------------------------------------------------------
 EOF
+    fi
     exit 1
 fi
-