9 Validate GHC source tree against testsuite; see
10 https://gitlab.haskell.org/ghc/ghc/wikis/testing-patches for more
14 --no-clean don't make clean first, just carry on from
15 a previous interrupted validation run
16 --testsuite-only don't build the compiler, just run the test suite
17 --build-only don't test the compiler, just build it
18 --hpc build stage2 with -fhpc, and see how much of the
19 compiler the test suite covers.
20 2008-07-01: 63% slower than the default.
21 HTML generated here: testsuite/hpc_output/hpc_index.html
22 --fast Omit binary distribution. Omit certain tests.
23 --slow Build stage2 with -DDEBUG. Run tests for all WAYS,
24 but skip those that call compiler_stats_num_field.
25 2008-07-01: 14% slower than the default.
26 --quiet More pretty build log.
27 See Note [Default build system verbosity].
28 --hadrian Build the compiler and run the tests through hadrian.
29 --help shows this usage help.
31 validate runs 'make -j\$THREADS', where by default THREADS is the number of
32 cpus your computer has +1. You can set the environment variable THREADS to
33 override this. For a sequential build you would for example use
37 You can set the 'config_args' environment variable to pass flags to
40 You can also use environment variables to pass extra options to the
41 testsuite. For example:
43 TEST='read001 read002' ./validate --testsuite-only --fast
54 # Validate uses gzip compression for the binary distribution to avoid the rather
55 # heavy cost of xz, which is the typical default. The options are defined in
81 --normal) # for backward compat
89 hadrian_build_root=_validatebuild
95 echo "$0: unrecognized argument '$1'" >&2
96 echo "Try '$0 --help' for more information." >&2
103 if [ "$bindistdir" = "" ]
105 if [ "$use_hadrian" = "YES" ]
107 ghc_pkg=$hadrian_build_root/stage1/bin/ghc-pkg
109 ghc_pkg=inplace/bin/ghc-pkg
112 ghc_pkg="$bindistdir"/bin/ghc-pkg
115 if [ $be_quiet -eq 1 ]
119 echo "== Start $1 package check"
121 echo "== End $1 package check"
125 CPUS=`mk/detect-cpu-count.sh`
127 if ! [ -d testsuite ]
129 echo 'Could not find the testsuite for validation' >&2
133 if [ "$THREADS" = "" ]; then
134 threads=$(($CPUS + 1)) # `expr $CPUS + 1`
139 echo "using THREADS=${threads}" >&2
141 if [ "$use_hadrian" = "NO" ]
144 if type gmake > /dev/null 2> /dev/null
150 if [ $be_quiet -eq 1 ]; then
151 # See Note [Default build system verbosity].
154 $make -C utils/checkUniques
156 # Just build hadrian.
157 hadrian/build.sh --help > /dev/null
159 hadrian_cmd=$(cabal new-exec -- which hadrian)
161 # TODO: define a hadrian Flavour that mimics
162 # mk/flavours/validate.mk and use it here
163 # Until then, we're using the default flavour.
164 hadrian="$hadrian_cmd -j$threads --build-root=$hadrian_build_root"
165 if [ $be_quiet -eq 0 ]; then
166 hadrian="$hadrian -V"
168 echo "Hadrian command: $hadrian"
171 if [ $testsuite_only -eq 0 ]; then
175 if [ $no_clean -eq 0 ]; then
176 if [ "$use_hadrian" = "NO" ]
178 $make maintainer-clean
180 $hadrian clean && rm -rf $hadrian_build_root
183 INSTDIR="$thisdir/inst"
185 python3 ./boot --validate
186 ./configure --prefix="$INSTDIR" $config_args
189 if [ "$use_hadrian" = "NO" ]
191 echo "Validating=YES" > mk/are-validating.mk
192 echo "ValidateSpeed=$speed" >> mk/are-validating.mk
193 echo "ValidateHpc=$hpc" >> mk/are-validating.mk
195 # Note [Default build system verbosity].
197 # From https://gitlab.haskell.org/ghc/ghc/wikis/design/build-system:
199 # "The build system should clearly report what it's doing (and sometimes
200 # why), without being too verbose. It should emit actual command lines as
201 # much as possible, so that they can be inspected and cut & pasted."
203 # That should be the default. Only suppress commands, by setting V=0 and using
204 # `make -s`, when user explicitly asks for it with `./validate --quiet`.
205 if [ $be_quiet -eq 1 ]; then
206 # See Note [Default build system verbosity].
207 echo "V=0" >> mk/are-validating.mk # Less gunk
211 # For a "debug make", add "--debug=b --debug=m"
213 # TODO: define a hadrian Flavour that mimics
214 # mk/flavours/validate.mk and use it here
218 check_packages post-build
220 bindistdir="bindisttest/install dir"
221 ghc="$bindistdir/bin/ghc"
223 # -----------------------------------------------------------------------------
224 # Build and test a binary distribution (not --fast)
226 if [ $speed != "FAST" ]; then
227 if [ "$use_hadrian" = "NO" ]
229 $make binary-dist-prep TAR_COMP=$tar_comp
230 $make test_bindist TEST_PREP=YES TAR_COMP=$tar_comp
232 $hadrian binary-dist --docs=no-sphinx
233 cfgdir=$(find $hadrian_build_root/bindist/ -name 'configure' | head -1)
234 dir=$(dirname $cfgdir)
236 ./configure --prefix="$thisdir/$bindistdir" && make install
238 "$ghc" -e 'Data.Text.IO.putStrLn (Data.Text.pack "bindist test: OK")'
241 check_packages post-install
243 if [ "$use_hadrian" = "NO" ]
245 $make validate_build_xhtml BINDIST_PREFIX="$thisdir/$bindistdir"
248 dynamicGhc=$("../../$ghc" --info | grep "GHC Dynamic" | cut -d',' -f3 | cut -d'"' -f2)
249 if [ "$dynamicGhc" = "NO" ]
251 libFlags="--enable-shared --disable-library-vanilla"
253 libFlags="--disable-shared --enable-library-vanilla"
255 libFlags="$libFlags --disable-library-prof"
257 "../../$ghc" --make Setup
259 --with-ghc="$thisdir/$ghc" \
260 --with-haddock="$thisdir/$bindistdir/bin/haddock" \
262 --global --builddir=dist-bindist \
263 --prefix="$thisdir/$bindistdir"
264 ./Setup build --builddir=dist-bindist
265 ./Setup haddock -v0 --ghc-options=-optP-P --builddir=dist-bindist
266 ./Setup install --builddir=dist-bindist
267 ./Setup clean --builddir=dist-bindist
268 rm -f Setup Setup.exe Setup.hi Setup.o
272 check_packages post-xhtml
277 # -----------------------------------------------------------------------------
280 if [ "$build_only" -eq 1 ]; then
282 -------------------------------------------------------------------
283 Congratulations! This tree has compiled successfully.
285 You can now test your new compiler using ./validate --testsuite-only.
292 # XXX With threads we'd need to give a different tix file to each thread
293 # and then sum them up at the end
295 HPCTIXFILE=$thisdir/testsuite/hpc_output/ghc.tix
302 MAKE_TEST_TARGET=slowtest
303 BINDIST="BINDIST=YES"
304 HADRIAN_TEST_SPEED=slow
307 MAKE_TEST_TARGET=test
308 BINDIST="BINDIST=YES"
309 HADRIAN_TEST_SPEED=normal
312 MAKE_TEST_TARGET=fasttest
314 HADRIAN_TEST_SPEED=fast
318 if [ $be_quiet -eq 1 ] && [ -z $VERBOSE ]; then
319 TEST_VERBOSITY="VERBOSE=1"
322 # We need to be quite picky on Windows about which Python interpreter we use
323 # (#12554, #12661). Allow the user to override it.
324 if [ "z$PYTHON" != "z" ]; then
325 PYTHON_ARG="PYTHON=$PYTHON"
328 rm -f testsuite_summary.txt testsuite_summary_stage1.txt
330 if [ "$use_hadrian" = "NO" ]
332 # Use LOCAL=0, see Note [Running tests in /tmp].
333 $make -C testsuite/tests $BINDIST $PYTHON_ARG \
334 $MAKE_TEST_TARGET stage=2 LOCAL=0 $TEST_VERBOSITY THREADS=$threads \
335 NO_PRINT_SUMMARY=YES SUMMARY_FILE=../../testsuite_summary.txt \
336 JUNIT_FILE=../../testsuite.xml \
339 # Run a few tests using the stage1 compiler.
340 # See Note [Why is there no stage1 setup function?].
341 # Don't use BINDIST=YES, as stage1 is not available in a bindist.
342 $make -C testsuite/tests/stage1 $PYTHON_ARG \
343 $MAKE_TEST_TARGET stage=1 LOCAL=0 $TEST_VERBOSITY THREADS=$threads \
344 NO_PRINT_SUMMARY=YES SUMMARY_FILE=../../../testsuite_summary_stage1.txt \
345 JUNIT_FILE=../../../testsuite_stage1.xml \
346 2>&1 | tee testlog-stage1
348 testghc="$thisdir/$ghc"
349 arg="test --test-speed=$HADRIAN_TEST_SPEED \
350 --test-compiler=\"$testghc\" \
351 --summary=$thisdir/testsuite_summary.txt \
352 --summary-junit=$thisdir/testsuite.xml"
353 sh -c "$hadrian $arg"
354 # TODO: Run testsuite/tests/stage1 using the stage 1 compiler when
359 echo '==== STAGE 1 TESTS ==== '
360 cat testsuite_summary_stage1.txt
362 echo '==== STAGE 2 TESTS ==== '
363 cat testsuite_summary.txt
365 check_packages post-testsuite
369 utils/hpc/hpc markup --hpcdir=. --srcdir=compiler --srcdir=testsuite/hpc_output --destdir=testsuite/hpc_output testsuite/hpc_output/ghc.tix
373 grep '\<0 caused framework failures' testsuite_summary.txt >/dev/null 2>/dev/null &&
374 grep '\<0 unexpected passes' testsuite_summary.txt >/dev/null 2>/dev/null &&
375 grep '\<0 unexpected failures' testsuite_summary.txt >/dev/null 2>/dev/null &&
376 grep '\<0 unexpected stat failures' testsuite_summary.txt >/dev/null 2>/dev/null &&
378 grep '\<0 caused framework failures' testsuite_summary_stage1.txt >/dev/null 2>/dev/null &&
379 grep '\<0 unexpected passes' testsuite_summary_stage1.txt >/dev/null 2>/dev/null &&
380 grep '\<0 unexpected failures' testsuite_summary_stage1.txt >/dev/null 2>/dev/null &&
381 grep '\<0 unexpected stat failures' testsuite_summary_stage1.txt >/dev/null 2>/dev/null ; then
383 if [ $testsuite_only -eq 0 ] && [ $no_clean -eq 0 ]
386 -------------------------------------------------------------------
387 Congratulations! This tree has passed minimal testing.
389 NOTE: If you have made changes that may cause failures not tested for by
390 the minimal testing procedure, please do further testing as necessary.
392 When you are satisfied that you haven't broken anything, go ahead and
393 push/send your patches.
395 if [ -f mk/validate.mk ] && grep -q "^[^#]" mk/validate.mk
399 WARNING: You seem to have things set in mk/validate.mk. Please check
400 that it is OK before pushing.
404 -------------------------------------------------------------------
408 -------------------------------------------------------------------
409 I didn't find any problems, but this wasn't a complete validate run,
412 NOTE: If you have made changes that may cause failures not tested for by
413 the minimal testing procedure, please do further testing as necessary.
414 -------------------------------------------------------------------
418 if [ $be_quiet -eq 0 ]
421 -------------------------------------------------------------------
422 Oops! Looks like you have some unexpected test results or framework failures.
423 Please fix them before pushing/sending patches.
424 -------------------------------------------------------------------