Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Stop on error
- set -e
- # Move to base directory
- pushd "$(git rev-parse --show-toplevel)" > /dev/null
- # Clean any directory only containing phpunit.xml
- # sure it was created for another branch and does
- # not exist in current one.
- candidates=$(find . -name phpunit.xml -not -path "./vendor/*" | xargs dirname | sort -r)
- for candidate in ${candidates}; do
- numfiles=$(ls -1 ${candidate} | wc -l)
- if [[ ${numfiles} -eq 1 ]]; then
- echo "Deleting empty ${candidate}"
- rm -fr ${candidate}
- # if that leads to an empty parent, delete it too
- parent=$(dirname ${candidate})
- numfiles=$(ls -1 ${parent} | wc -l)
- if [[ ${numfiles} -eq 0 ]]; then
- echo "Deleting empty ${parent}"
- rm -fr ${parent}
- fi
- fi
- done
- # Similar, only 4.0 and up have admin/tool/componentlibrary and we are leaving there
- # some files (docs, hugo...) that make things break when version.php is searched. Clean
- # it if missing version.php
- if [[ ! -f admin/tool/componentlibrary/version.php ]]; then
- rm -fr admin/tool/componentlibrary
- fi
- # Init and enable all the behat tests
- # no password is required because (sudo visudo) has, AFTER the admin entries!:
- # (or also in a /etc/sudoers.d/stronk7_as_www file, to make it persistent - else it's gone on every upgrade)
- # stronk7 ALL=(_www) NOPASSWD: ALL
- # (allow to run everything as _www without password to stronk7)
- #sudo -u _www /opt/local/bin/php composer.phar update
- parallel=
- drop=
- accessibility=
- optimize="--optimize-runs=@javascript"
- if [[ -n ${1} ]]; then
- # First, look for the (d)rop option
- if [[ "${1}" == "d" ]] || [[ "${1}" == "drop" ]]; then
- drop=1
- fi
- if [[ "${1}" == "a" ]] || [[ "${1}" == "accessibility" ]]; then
- accessibility="--axe"
- else
- parallel="--parallel=${1}"
- fi
- fi
- if [[ "${2}" == "a" ]] || [[ "${2}" == "accessibility" ]]; then
- accessibility="--axe"
- fi
- if [[ -n ${3} ]]; then
- optimize="--optimize-runs=${3}"
- fi
- if [[ -n ${drop} ]]; then
- sudo -u _www /opt/local/bin/php admin/tool/behat/cli/util.php --drop
- else
- sudo -u _www /opt/local/bin/php admin/tool/behat/cli/init.php ${parallel} ${optimize} ${accessibility} -a
- fi
- # Move back to original directory
- popd > /dev/null
- # Some information to avoid forgetting it
- echo
- echo "And, if you're using moodle-browser-config, profiles must be any of:"
- echo " -[headless]chrome|firefox|edge|safari => to run with selenium"
- echo " -[headless]chromedriver|gecko|edgedriver|safaridriver => to run straight without selenium"
- echo
- echo "NOTE: When using remote browsers @_file_upload must be excluded because they don't have access to them locally."
- echo
- echo "Ensure CFG->behat_wwwroot, behat_prefix and behat_dataroot are set. And the site is accesible over http."
- echo
- echo "If you get, for behat runs:"
- echo " Behat requirement not satisfied: http://.... is not available...."
- echo " Exit codes for each behat run:"
- echo " behatrun1: 251"
- echo " behatrun2: 251"
- echo " then verify that the directory being served (maybe userdir) has -SymLinksIfOwnerMatch (aka, disabled)"
- echo " (if it's enabled... then it may not work if dir owner and link owner are different)"
- echo " Link: https://unix.stackexchange.com/questions/20993/symbolic-link-not-allowed-or-link-target-not-accessible-apache-on-centos-6"
- echo
- echo "Use this (@ dirroot) to launch the selenium server (needed for use of ONE - and only one - browser, no hub)"
- echo " java -Dwebdriver.chrome.driver=/Users/stronk7/bin/chromedriver \\"
- echo " -Dwebdriver.gecko.driver=/Users/stronk7/bin/geckodriver \\"
- echo " -Dwebdriver.edge.driver=/Users/stronk7/bin/msedgedriver \\"
- echo " -Djava.net.preferIPv4Stack=true \\"
- echo " -jar /Users/stronk7/bin/selenium-server-standalone.jar \\"
- echo " -timeout 86400 -port 8668"
- echo
- echo "If running without selenium, you'll have to start the xxxdriver instead of selenium"
- echo
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement