autotest.cmd 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. ::
  2. :: ownCloud
  3. ::
  4. :: @author Thomas Müller
  5. :: @author Tobias Ramforth (translated into Windows batch file)
  6. ::
  7. :: @copyright 2012 Thomas Müller thomas.mueller@tmit.eu
  8. ::
  9. @echo off
  10. set DATADIR=data-autotest
  11. set BASEDIR=%~dp0
  12. :: create autoconfig for sqlite, mysql and postgresql
  13. echo ^<?php > .\tests\autoconfig-sqlite.php
  14. echo $AUTOCONFIG ^= array ^( >> .\tests\autoconfig-sqlite.php
  15. echo 'installed' ^=^> false^, >> .\tests\autoconfig-sqlite.php
  16. echo 'dbtype' ^=^> 'sqlite'^, >> .\tests\autoconfig-sqlite.php
  17. echo 'dbtableprefix' ^=^> 'oc_'^, >> .\tests\autoconfig-sqlite.php
  18. echo 'adminlogin' ^=^> 'admin'^, >> .\tests\autoconfig-sqlite.php
  19. echo 'adminpass' ^=^> 'admin'^, >> .\tests\autoconfig-sqlite.php
  20. echo 'directory' ^=^> '%BASEDIR%%DATADIR%'^, >> .\tests\autoconfig-sqlite.php
  21. echo ^)^; >> .\tests\autoconfig-sqlite.php
  22. echo ^<?php > .\tests\autoconfig-mysql.php
  23. echo $AUTOCONFIG ^= array ^( >> .\tests\autoconfig-mysql.php
  24. echo 'installed' ^=^> false^, >> .\tests\autoconfig-mysql.php
  25. echo 'dbtype' ^=^> 'mysql'^, >> .\tests\autoconfig-mysql.php
  26. echo 'dbtableprefix' ^=^> 'oc_'^, >> .\tests\autoconfig-mysql.php
  27. echo 'adminlogin' ^=^> 'admin'^, >> .\tests\autoconfig-mysql.php
  28. echo 'adminpass' ^=^> 'admin'^, >> .\tests\autoconfig-mysql.php
  29. echo 'directory' ^=^> '%BASEDIR%%DATADIR%'^, >> .\tests\autoconfig-mysql.php
  30. echo 'dbuser' ^=^> 'oc_autotest'^, >> .\tests\autoconfig-mysql.php
  31. echo 'dbname' ^=^> 'oc_autotest'^, >> .\tests\autoconfig-mysql.php
  32. echo 'dbhost' ^=^> 'localhost'^, >> .\tests\autoconfig-mysql.php
  33. echo 'dbpass' ^=^> 'owncloud'^, >> .\tests\autoconfig-mysql.php
  34. echo ^)^; >> .\tests\autoconfig-mysql.php
  35. echo ^<?php > .\tests\autoconfig-pgsql.php
  36. echo $AUTOCONFIG ^= array ^( >> .\tests\autoconfig-pgsql.php
  37. echo 'installed' ^=^> false^, >> .\tests\autoconfig-pgsql.php
  38. echo 'dbtype' ^=^> 'pgsql'^, >> .\tests\autoconfig-pgsql.php
  39. echo 'dbtableprefix' ^=^> 'oc_'^, >> .\tests\autoconfig-pgsql.php
  40. echo 'adminlogin' ^=^> 'admin'^, >> .\tests\autoconfig-pgsql.php
  41. echo 'adminpass' ^=^> 'admin'^, >> .\tests\autoconfig-pgsql.php
  42. echo 'directory' ^=^> '%BASEDIR%%DATADIR%'^, >> .\tests\autoconfig-pgsql.php
  43. echo 'dbuser' ^=^> 'oc_autotest'^, >> .\tests\autoconfig-pgsql.php
  44. echo 'dbname' ^=^> 'oc_autotest'^, >> .\tests\autoconfig-pgsql.php
  45. echo 'dbhost' ^=^> 'localhost'^, >> .\tests\autoconfig-pgsql.php
  46. echo 'dbpass' ^=^> 'owncloud'^, >> .\tests\autoconfig-pgsql.php
  47. echo ^)^; >> .\tests\autoconfig-pgsql.php
  48. echo localhost:5432:*:oc_autotest:owncloud > %APPDATA%\postgresql\pgpass.conf
  49. ::
  50. :: start test execution
  51. ::
  52. ::call:execute_tests "sqlite"
  53. call:execute_tests "mysql"
  54. ::call:execute_tests "mssql"
  55. ::call:execute_tests "ora"
  56. ::call:execute_tests "pgsql"
  57. goto:eof
  58. :execute_tests
  59. echo "Setup environment for %~1 testing ..."
  60. :: back to root folder
  61. cd %BASEDIR%
  62. :: revert changes to tests\data
  63. git checkout tests\data\*
  64. :: reset data directory
  65. rmdir /s /q %DATADIR%
  66. md %DATADIR%
  67. :: remove the old config file
  68. :: del /q /f config\config.php
  69. copy /y tests\preseed-config.php config\config.php
  70. :: drop database
  71. if "%~1" == "mysql" mysql -u oc_autotest -powncloud -e "DROP DATABASE oc_autotest"
  72. if "%~1" == "pgsql" dropdb -h localhost -p 5432 -U oc_autotest -w oc_autotest
  73. :: copy autoconfig
  74. copy /y %BASEDIR%\tests\autoconfig-%~1.php %BASEDIR%\config\autoconfig.php
  75. :: trigger installation
  76. php -f index.php
  77. ::test execution
  78. echo "Testing with %~1 ..."
  79. cd tests
  80. rmdir /s /q coverage-html-%~1
  81. md coverage-html-%~1
  82. php -f enable_all.php
  83. ::phpunit --log-junit autotest-results-%~1.xml --coverage-clover autotest-clover-%~1.xml --coverage-html coverage-html-%~1
  84. ::phpunit --bootstrap bootstrap.php --configuration phpunit.xml
  85. php win32-phpunit.php --bootstrap bootstrap.php --configuration phpunit.xml --log-junit autotest-results-%~1.xml --coverage-clover autotest-clover-%~1.xml --coverage-html coverage-html-%~1
  86. echo "Done with testing %~1 ..."
  87. cd %BASEDIR%
  88. goto:eof
  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. ::