Skip to content

Instantly share code, notes, and snippets.

@zoffixznet
Created December 9, 2016 10:02
Show Gist options
  • Save zoffixznet/642020473b713985dd21dc96cdb6cee1 to your computer and use it in GitHub Desktop.
Save zoffixznet/642020473b713985dd21dc96cdb6cee1 to your computer and use it in GitHub Desktop.
#!/bin/bash
# print out the commands we run and bail out on failures
set -x
set -e
# Check out rakudo into ~/coverakudo. You can change it to any dir you want
rm -fr ~/CPANPRC/coverakudo
git clone https://github.com/rakudo/rakudo ~/CPANPRC/coverakudo
# go to that dir
cd ~/CPANPRC/coverakudo
# Configure
perl Configure.pl --gen-moar --gen-nqp --backends=moar
# Disable the optimizer, so routines we want don't get optimized away
perl -pi -e 's/--optimize=\K3/off/' Makefile
# Build Rakudo
make
# Install Rakudo
make install
# Go to MoarVM dir
cd nqp/MoarVM
# Check out the branch with coverage support
git checkout $(git branch -r | grep origin/line_based_coverage | tail -n1)
# Bring in any latest MoarVM changes from master
git pull --rebase https://github.com/MoarVM/MoarVM/
# Configure MoarVM
perl Configure.pl --prefix=../../install/
# Build MoarVM
make
# Install MoarVM
make install
# Go back to rakudo dir
cd ../..
# Just check that we've got coverage now. Should say "WE SUCCEEDED!!"
install/bin/moar --help | grep MVM_COVERAGE_LOG &&
echo 'We SUCCEEDED!!' ||
{ echo 'WE FAILED!!!!'; exit 1; }
# The following steps download `panda` package manager and install
# Inline::Perl5 module that we need for Rakudo stress testing. You may need
# a specially-built Perl 5 for it. You can use `perlbrew` to obtain it.
# See instructions at https://github.com/niner/Inline-Perl5#building
git clone https://github.com/tadzik/panda
export PATH=`pwd`/install/bin:$PATH
cd panda; perl6 bootstrap.pl
cd ..
export PATH=`pwd`/install/share/perl6/site/bin:$PATH
panda install Inline::Perl5
# Delete coverage directory, if it's there already
rm -fr coverage
# Create coverage dir; we'll store our coverage report here
mkdir coverage
# Turn off auto-bail-out, since stresstests may fail and that's OK
set +e
# Run stresstest. The MVM_COVERAGE_LOG var tells MoarVM where to store
# coverage report files; the `%d` in the filename is necessary to store
# the process IDs of running tests!
MVM_COVERAGE_LOG='coverage/cover-%d' TEST_JOBS=8 make stresstest
MVM_COVERAGE_LOG='coverage/cover-%d' TEST_JOBS=8 make stresstest
MVM_COVERAGE_LOG='coverage/cover-%d' TEST_JOBS=8 make stresstest
#########################
## Note: at least on my box, some stresstest flapped and exited early,
## because apparently disabling the optimizer changes the test results.
## For that reason, to get full coverage either run the stresstest
## several times, or run individual failing test files a few times with
## MVM_COVERAGE_LOG='coverage/cover-%d' make t/spec/THE-TEST-FILE.t
## some test files may end with `.rakudo.moar` extension. Change it to `.t`
#########################
# Bail out on fail
set -e
# Go into directory with all the coverage files
cd coverage
# Find entries we want, make sure they're unique, and store them all in
# a file. This step may take awhile to run, especially if you ran the
# entire stresstest several times
cat * | grep 'gen/moar/m-CORE.setting' | sort | uniq > full-cover
rm cover-*
# Go back up
cd ../
# Generate the setting annotations
install/bin/moar --dump CORE.setting.moarvm > setting
# Run the coverage report
./perl6 nqp/MoarVM/tools/parse_coverage_report.p6 \
--annotations=setting coverage/full-cover gen/moar/m-CORE.setting
scp -r coverage/* zoffix@perl6.party:/var/www/perl6.wtf/web/
# It's ready! All of the files are in coverage/ directory and you can
# start viewing them by opening coverage/index.html in your favourite browser
firefox coverage/index.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment