MDL-34889 phpunit: progress output in util.php --drop.

It is slow for me, and it is nice to know that something is going on.
This commit is contained in:
Tim Hunt 2012-08-14 15:25:03 +01:00
parent 7033316dad
commit 6247d0a82c
2 changed files with 26 additions and 3 deletions

View file

@ -150,7 +150,7 @@ if ($diag) {
} else if ($drop) {
// make sure tests do not run in parallel
phpunit_util::acquire_test_lock();
phpunit_util::drop_site();
phpunit_util::drop_site(true);
// note: we must stop here because $CFG is messed up and we can not reinstall, sorry
exit(0);

View file

@ -762,16 +762,20 @@ class phpunit_util {
* Note: To be used from CLI scripts only.
*
* @static
* @param bool $displayprogress if true, this method will echo progress information.
* @return void may terminate execution with exit code
*/
public static function drop_site() {
public static function drop_site($displayprogress = false) {
global $DB, $CFG;
if (!self::is_test_site()) {
phpunit_bootstrap_error(PHPUNIT_EXITCODE_CONFIGERROR, 'Can not drop non-test site!!');
}
// purge dataroot
// Purge dataroot
if ($displayprogress) {
echo "Purging dataroot:\n";
}
self::reset_dataroot();
phpunit_bootstrap_initdataroot($CFG->dataroot);
$keep = array('.', '..', 'lock', 'webrunner.xml');
@ -795,9 +799,28 @@ class phpunit_util {
unset($tables['config']);
$tables['config'] = 'config';
}
if ($displayprogress) {
echo "Dropping tables:\n";
}
$dotsonline = 0;
foreach ($tables as $tablename) {
$table = new xmldb_table($tablename);
$DB->get_manager()->drop_table($table);
if ($dotsonline == 60) {
if ($displayprogress) {
echo "\n";
}
$dotsonline = 0;
}
if ($displayprogress) {
echo '.';
}
$dotsonline += 1;
}
if ($displayprogress) {
echo "\n";
}
}