mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
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:
parent
7033316dad
commit
6247d0a82c
2 changed files with 26 additions and 3 deletions
|
@ -150,7 +150,7 @@ if ($diag) {
|
||||||
} else if ($drop) {
|
} else if ($drop) {
|
||||||
// make sure tests do not run in parallel
|
// make sure tests do not run in parallel
|
||||||
phpunit_util::acquire_test_lock();
|
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
|
// note: we must stop here because $CFG is messed up and we can not reinstall, sorry
|
||||||
exit(0);
|
exit(0);
|
||||||
|
|
||||||
|
|
|
@ -762,16 +762,20 @@ class phpunit_util {
|
||||||
* Note: To be used from CLI scripts only.
|
* Note: To be used from CLI scripts only.
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
|
* @param bool $displayprogress if true, this method will echo progress information.
|
||||||
* @return void may terminate execution with exit code
|
* @return void may terminate execution with exit code
|
||||||
*/
|
*/
|
||||||
public static function drop_site() {
|
public static function drop_site($displayprogress = false) {
|
||||||
global $DB, $CFG;
|
global $DB, $CFG;
|
||||||
|
|
||||||
if (!self::is_test_site()) {
|
if (!self::is_test_site()) {
|
||||||
phpunit_bootstrap_error(PHPUNIT_EXITCODE_CONFIGERROR, 'Can not drop non-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();
|
self::reset_dataroot();
|
||||||
phpunit_bootstrap_initdataroot($CFG->dataroot);
|
phpunit_bootstrap_initdataroot($CFG->dataroot);
|
||||||
$keep = array('.', '..', 'lock', 'webrunner.xml');
|
$keep = array('.', '..', 'lock', 'webrunner.xml');
|
||||||
|
@ -795,9 +799,28 @@ class phpunit_util {
|
||||||
unset($tables['config']);
|
unset($tables['config']);
|
||||||
$tables['config'] = 'config';
|
$tables['config'] = 'config';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($displayprogress) {
|
||||||
|
echo "Dropping tables:\n";
|
||||||
|
}
|
||||||
|
$dotsonline = 0;
|
||||||
foreach ($tables as $tablename) {
|
foreach ($tables as $tablename) {
|
||||||
$table = new xmldb_table($tablename);
|
$table = new xmldb_table($tablename);
|
||||||
$DB->get_manager()->drop_table($table);
|
$DB->get_manager()->drop_table($table);
|
||||||
|
|
||||||
|
if ($dotsonline == 60) {
|
||||||
|
if ($displayprogress) {
|
||||||
|
echo "\n";
|
||||||
|
}
|
||||||
|
$dotsonline = 0;
|
||||||
|
}
|
||||||
|
if ($displayprogress) {
|
||||||
|
echo '.';
|
||||||
|
}
|
||||||
|
$dotsonline += 1;
|
||||||
|
}
|
||||||
|
if ($displayprogress) {
|
||||||
|
echo "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue