autotest.cmd 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. ::
  2. :: ownCloud
  3. ::
  4. :: @author Thomas Müller
  5. :: @author Tobias Ramforth (translated into Windows batch file)
  6. ::
  7. :: @copyright 2012, 2013 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, postgresql and mssql
  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 ^<?php > .\tests\autoconfig-mssql.php
  49. echo $AUTOCONFIG ^= array ^( >> .\tests\autoconfig-mssql.php
  50. echo 'installed' ^=^> false^, >> .\tests\autoconfig-mssql.php
  51. echo 'dbtype' ^=^> 'mssql'^, >> .\tests\autoconfig-mssql.php
  52. echo 'dbtableprefix' ^=^> 'oc_'^, >> .\tests\autoconfig-mssql.php
  53. echo 'adminlogin' ^=^> 'admin'^, >> .\tests\autoconfig-mssql.php
  54. echo 'adminpass' ^=^> 'admin'^, >> .\tests\autoconfig-mssql.php
  55. echo 'directory' ^=^> '%BASEDIR%%DATADIR%'^, >> .\tests\autoconfig-mssql.php
  56. echo 'dbuser' ^=^> 'oc_autotest'^, >> .\tests\autoconfig-mssql.php
  57. echo 'dbname' ^=^> 'oc_autotest'^, >> .\tests\autoconfig-mssql.php
  58. echo 'dbhost' ^=^> 'localhost\sqlexpress'^, >> .\tests\autoconfig-mssql.php
  59. echo 'dbpass' ^=^> 'owncloud'^, >> .\tests\autoconfig-mssql.php
  60. echo ^)^; >> .\tests\autoconfig-mssql.php
  61. echo localhost:5432:*:oc_autotest:owncloud > %APPDATA%\postgresql\pgpass.conf
  62. ::
  63. :: start test execution
  64. ::
  65. if [%1] == [] (
  66. echo "Running on all database backends"
  67. call:execute_tests "sqlite"
  68. call:execute_tests "mysql"
  69. call:execute_tests "mssql"
  70. ::call:execute_tests "ora"
  71. call:execute_tests "pgsql"
  72. ) else (
  73. call:execute_tests "%1"
  74. )
  75. goto:eof
  76. :execute_tests
  77. echo "Setup environment for %~1 testing ..."
  78. :: back to root folder
  79. cd %BASEDIR%
  80. :: revert changes to tests\data
  81. git checkout tests\data\*
  82. :: reset data directory
  83. rmdir /s /q %DATADIR%
  84. md %DATADIR%
  85. :: remove the old config file
  86. :: del /q /f config\config.php
  87. copy /y tests\preseed-config.php config\config.php
  88. :: drop database
  89. if "%~1" == "mysql" mysql -u oc_autotest -powncloud -e "DROP DATABASE oc_autotest"
  90. if "%~1" == "pgsql" dropdb -h localhost -p 5432 -U oc_autotest -w oc_autotest
  91. :: we assume a sqlexpress installation
  92. if "%~1" == "mssql" sqlcmd -S localhost\sqlexpress -U oc_autotest -P owncloud -Q "IF EXISTS (SELECT name FROM sys.databases WHERE name=N'oc_autotest') DROP DATABASE [oc_autotest]"
  93. :: copy autoconfig
  94. copy /y %BASEDIR%\tests\autoconfig-%~1.php %BASEDIR%\config\autoconfig.php
  95. :: trigger installation
  96. php -f index.php
  97. ::test execution
  98. echo "Testing with %~1 ..."
  99. cd tests
  100. rmdir /s /q coverage-html-%~1
  101. md coverage-html-%~1
  102. php -f enable_all.php
  103. php win32-phpunit.php --bootstrap bootstrap.php --configuration phpunit-autotest.xml --log-junit autotest-results-%~1.xml --coverage-clover autotest-clover-%~1.xml --coverage-html coverage-html-%~1
  104. echo "Done with testing %~1 ..."
  105. cd %BASEDIR%
  106. goto:eof
  107. ::
  108. :: NOTES on mysql:
  109. :: - CREATE USER 'oc_autotest'@'localhost' IDENTIFIED BY 'owncloud';
  110. :: - grant access permissions: grant all on oc_autotest.* to 'oc_autotest'@'localhost';
  111. ::
  112. :: NOTES on pgsql:
  113. :: - su - postgres
  114. :: - createuser -P (enter username and password and enable superuser)
  115. :: - 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):
  116. :: local all all trust
  117. ::
  118. :: NOTES on mssql:
  119. :: we assume the usage of a local installed sqlexpress
  120. :: create a user 'oc_autotest' with password 'owncloud' and assign the server role 'dbcreator'
  121. :: make sure the sqlserver is configured to allow sql authentication
  122. ::