autotest.sh 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. #!/bin/bash
  2. #
  3. # ownCloud
  4. #
  5. # @author Thomas Müller
  6. # @copyright 2012 Thomas Müller thomas.mueller@tmit.eu
  7. #
  8. DATADIR=data-autotest
  9. BASEDIR=$PWD
  10. # create autoconfig for sqlite, mysql and postgresql
  11. cat > ./tests/autoconfig-sqlite.php <<DELIM
  12. <?php
  13. \$AUTOCONFIG = array (
  14. 'installed' => false,
  15. 'dbtype' => 'sqlite',
  16. 'dbtableprefix' => 'oc_',
  17. 'adminlogin' => 'admin',
  18. 'adminpass' => 'admin',
  19. 'directory' => '$BASEDIR/$DATADIR',
  20. );
  21. DELIM
  22. cat > ./tests/autoconfig-mysql.php <<DELIM
  23. <?php
  24. \$AUTOCONFIG = array (
  25. 'installed' => false,
  26. 'dbtype' => 'mysql',
  27. 'dbtableprefix' => 'oc_',
  28. 'adminlogin' => 'admin',
  29. 'adminpass' => 'admin',
  30. 'directory' => '$BASEDIR/$DATADIR',
  31. 'dbuser' => 'oc_autotest',
  32. 'dbname' => 'oc_autotest',
  33. 'dbhost' => 'localhost',
  34. 'dbpass' => 'owncloud',
  35. );
  36. DELIM
  37. cat > ./tests/autoconfig-pgsql.php <<DELIM
  38. <?php
  39. \$AUTOCONFIG = array (
  40. 'installed' => false,
  41. 'dbtype' => 'pgsql',
  42. 'dbtableprefix' => 'oc_',
  43. 'adminlogin' => 'admin',
  44. 'adminpass' => 'admin',
  45. 'directory' => '$BASEDIR/$DATADIR',
  46. 'dbuser' => 'oc_autotest',
  47. 'dbname' => 'oc_autotest',
  48. 'dbhost' => 'localhost',
  49. 'dbpass' => 'owncloud',
  50. );
  51. DELIM
  52. function execute_tests {
  53. echo "Setup environment for $1 testing ..."
  54. # back to root folder
  55. cd $BASEDIR
  56. # revert changes to tests/data
  57. git checkout tests/data/*
  58. # reset data directory
  59. rm -rf $DATADIR
  60. mkdir $DATADIR
  61. # remove the old config file
  62. #rm -rf config/config.php
  63. cp tests/preseed-config.php config/config.php
  64. # drop database
  65. if [ "$1" == "mysql" ] ; then
  66. mysql -u oc_autotest -powncloud -e "DROP DATABASE oc_autotest"
  67. fi
  68. if [ "$1" == "pgsql" ] ; then
  69. dropdb -U oc_autotest oc_autotest
  70. fi
  71. # copy autoconfig
  72. cp $BASEDIR/tests/autoconfig-$1.php $BASEDIR/config/autoconfig.php
  73. # trigger installation
  74. php -f index.php
  75. #test execution
  76. echo "Testing with $1 ..."
  77. cd tests
  78. rm -rf coverage-html-$1
  79. mkdir coverage-html-$1
  80. php -f enable_all.php
  81. phpunit --configuration phpunit-autotest.xml --log-junit autotest-results-$1.xml --coverage-clover autotest-clover-$1.xml --coverage-html coverage-html-$1
  82. }
  83. #
  84. # start test execution
  85. #
  86. execute_tests "sqlite"
  87. execute_tests 'mysql'
  88. execute_tests 'pgsql'
  89. #
  90. # NOTES on mysql:
  91. # - CREATE USER 'oc_autotest'@'localhost' IDENTIFIED BY 'owncloud';
  92. # - grant access permissions: grant all on oc_autotest.* to 'oc_autotest'@'localhost';
  93. #
  94. # NOTES on pgsql:
  95. # - su - postgres
  96. # - createuser -P (enter username and password and enable superuser)
  97. # - to enable dropdb I decided to add following line to pg_hba.conf (this is not the safest way but I don't care for the testing machine):
  98. # local all all trust
  99. #