Advertisement
stronk7

Untitled

Oct 21st, 2021
462
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.94 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Stop on error
  4. set -e
  5.  
  6. # Move to base directory
  7. pushd "$(git rev-parse --show-toplevel)" > /dev/null
  8.  
  9. # Clean any directory only containing phpunit.xml
  10. # sure it was created for another branch and does
  11. # not exist in current one.
  12. candidates=$(find . -name phpunit.xml -not -path "./vendor/*" | xargs dirname | sort -r)
  13. for candidate in ${candidates}; do
  14. numfiles=$(ls -1 ${candidate} | wc -l)
  15. if [[ ${numfiles} -eq 1 ]]; then
  16. echo "Deleting empty ${candidate}"
  17. rm -fr ${candidate}
  18. # if that leads to an empty parent, delete it too
  19. parent=$(dirname ${candidate})
  20. numfiles=$(ls -1 ${parent} | wc -l)
  21. if [[ ${numfiles} -eq 0 ]]; then
  22. echo "Deleting empty ${parent}"
  23. rm -fr ${parent}
  24. fi
  25. fi
  26. done
  27.  
  28. # Similar, only 4.0 and up have admin/tool/componentlibrary and we are leaving there
  29. # some files (docs, hugo...) that make things break when version.php is searched. Clean
  30. # it if missing version.php
  31. if [[ ! -f admin/tool/componentlibrary/version.php ]]; then
  32. rm -fr admin/tool/componentlibrary
  33. fi
  34.  
  35. # Init and enable all the behat tests
  36. # no password is required because (sudo visudo) has, AFTER the admin entries!:
  37. # (or also in a /etc/sudoers.d/stronk7_as_www file, to make it persistent - else it's gone on every upgrade)
  38. # stronk7 ALL=(_www) NOPASSWD: ALL
  39. # (allow to run everything as _www without password to stronk7)
  40. #sudo -u _www /opt/local/bin/php composer.phar update
  41. parallel=
  42. drop=
  43. accessibility=
  44. optimize="--optimize-runs=@javascript"
  45. if [[ -n ${1} ]]; then
  46. # First, look for the (d)rop option
  47. if [[ "${1}" == "d" ]] || [[ "${1}" == "drop" ]]; then
  48. drop=1
  49. fi
  50. if [[ "${1}" == "a" ]] || [[ "${1}" == "accessibility" ]]; then
  51. accessibility="--axe"
  52. else
  53. parallel="--parallel=${1}"
  54. fi
  55. fi
  56. if [[ "${2}" == "a" ]] || [[ "${2}" == "accessibility" ]]; then
  57. accessibility="--axe"
  58. fi
  59. if [[ -n ${3} ]]; then
  60. optimize="--optimize-runs=${3}"
  61. fi
  62. if [[ -n ${drop} ]]; then
  63. sudo -u _www /opt/local/bin/php admin/tool/behat/cli/util.php --drop
  64. else
  65. sudo -u _www /opt/local/bin/php admin/tool/behat/cli/init.php ${parallel} ${optimize} ${accessibility} -a
  66. fi
  67.  
  68. # Move back to original directory
  69. popd > /dev/null
  70.  
  71. # Some information to avoid forgetting it
  72. echo
  73. echo "And, if you're using moodle-browser-config, profiles must be any of:"
  74. echo " -[headless]chrome|firefox|edge|safari => to run with selenium"
  75. echo " -[headless]chromedriver|gecko|edgedriver|safaridriver => to run straight without selenium"
  76. echo
  77. echo "NOTE: When using remote browsers @_file_upload must be excluded because they don't have access to them locally."
  78. echo
  79. echo "Ensure CFG->behat_wwwroot, behat_prefix and behat_dataroot are set. And the site is accesible over http."
  80. echo
  81. echo "If you get, for behat runs:"
  82. echo " Behat requirement not satisfied: http://.... is not available...."
  83. echo " Exit codes for each behat run:"
  84. echo " behatrun1: 251"
  85. echo " behatrun2: 251"
  86. echo " then verify that the directory being served (maybe userdir) has -SymLinksIfOwnerMatch (aka, disabled)"
  87. echo " (if it's enabled... then it may not work if dir owner and link owner are different)"
  88. echo " Link: https://unix.stackexchange.com/questions/20993/symbolic-link-not-allowed-or-link-target-not-accessible-apache-on-centos-6"
  89. echo
  90. echo "Use this (@ dirroot) to launch the selenium server (needed for use of ONE - and only one - browser, no hub)"
  91. echo " java -Dwebdriver.chrome.driver=/Users/stronk7/bin/chromedriver \\"
  92. echo " -Dwebdriver.gecko.driver=/Users/stronk7/bin/geckodriver \\"
  93. echo " -Dwebdriver.edge.driver=/Users/stronk7/bin/msedgedriver \\"
  94. echo " -Djava.net.preferIPv4Stack=true \\"
  95. echo " -jar /Users/stronk7/bin/selenium-server-standalone.jar \\"
  96. echo " -timeout 86400 -port 8668"
  97. echo
  98. echo "If running without selenium, you'll have to start the xxxdriver instead of selenium"
  99. echo
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement