#!/bin/sh set -e show_help () { cat <&2 echo "Try '$0 --help' for more information." >&2 exit 1;; esac shift done check_packages () { if [ "$bindistdir" = "" ] then ghc_pkg=inplace/bin/ghc-pkg else 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 } detect_cpu_count if ! [ -d testsuite ] then echo 'Could not find the testsuite for validation' >&2 exit 1 fi if [ "$THREADS" = "" ]; then threads=$(($CPUS + 1)) # `expr $CPUS + 1` else threads="$THREADS" fi echo "using THREADS=${threads}" >&2 if type gmake > /dev/null 2> /dev/null then make="gmake" else make="make" fi if [ $be_quiet -eq 1 ]; then # See Note [Default build system verbosity]. make="$make -s" fi if [ $testsuite_only -eq 0 ]; then if [ $no_clean -eq 0 ]; then $make maintainer-clean NO_CLEAN_GMP=YES INSTDIR=`pwd`/inst if [ $use_dph -eq 1 ]; then perl -w boot --validate --required-tag=dph else perl -w boot --validate fi ./configure --prefix="$INSTDIR" $config_args fi thisdir=`utils/ghc-pwd/dist-boot/ghc-pwd` make_settings="Validating=YES ValidateSpeed=$speed ValidateHpc=$hpc" # Note [Default build system verbosity]. # # From https://ghc.haskell.org/trac/ghc/wiki/Design/BuildSystem: # # "The build system should clearly report what it's doing (and sometimes # why), without being too verbose. It should emit actual command lines as # much as possible, so that they can be inspected and cut & pasted." # # That should be the default. Only suppress commands, by setting V=0 and using # `make -s`, when user explicitly asks for it with `./validate --quiet`. if [ $be_quiet -eq 1 ]; then # See Note [Default build system verbosity]. make_settings="$make_settings V=0" fi if [ $use_dph -eq 1 ]; then make_settings="$make_settings BUILD_DPH=YES" fi $make -j$threads $make_settings # For a "debug make", add "--debug=b --debug=m" check_packages post-build # ----------------------------------------------------------------------------- # Build and test a binary distribution (not --fast) if [ $speed != "FAST" ]; then $make binary-dist-prep $make_settings $make test_bindist TEST_PREP=YES $make_settings # # Install the xhtml package into the bindist. # This verifies that we can install a package into the # bindist with Cabal. # bindistdir="bindisttest/install dir" check_packages post-install $make validate_build_xhtml BINDIST_PREFIX="$thisdir/$bindistdir" $make_settings check_packages post-xhtml fi fi # testsuite-only # ----------------------------------------------------------------------------- # Run the testsuite if [ "$hpc" = YES ] then # XXX With threads we'd need to give a different tix file to each thread # and then sum them up at the end threads=1 HPCTIXFILE=$thisdir/testsuite/hpc_output/ghc.tix export HPCTIXFILE rm -f $HPCTIXFILE fi case "$speed" in SLOW) MAKE_TEST_TARGET=slowtest BINDIST="BINDIST=YES" ;; NORMAL) MAKE_TEST_TARGET=test BINDIST="BINDIST=YES" ;; FAST) MAKE_TEST_TARGET=fasttest BINDIST="BINDIST=NO" ;; esac if [ $be_quiet -eq 1 ] && [ -z $VERBOSE ]; then TEST_VERBOSITY="VERBOSE=1 NO_PRINT_SUMMARY=YES" fi $make $MAKE_TEST_TARGET stage=2 $BINDIST $TEST_VERBOSITY THREADS=$threads 2>&1 | tee testlog check_packages post-testsuite if [ "$hpc" = YES ] then utils/hpc/hpc markup --hpcdir=. --srcdir=compiler --srcdir=testsuite/hpc_output --destdir=testsuite/hpc_output testsuite/hpc_output/ghc.tix fi if 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 <