From 219d1a4e7246601adb77e634e6366276875afa81 Mon Sep 17 00:00:00 2001 From: Petr Skoda Date: Sat, 7 Apr 2012 14:00:44 +0200 Subject: [PATCH] MDL-32323 improve self-diagnostic messages --- lib/phpunit/bootstraplib.php | 3 +++ lib/phpunit/lib.php | 11 ++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/phpunit/bootstraplib.php b/lib/phpunit/bootstraplib.php index cd9bcce6c98..93bc164db38 100644 --- a/lib/phpunit/bootstraplib.php +++ b/lib/phpunit/bootstraplib.php @@ -33,6 +33,9 @@ */ function phpunit_bootstrap_error($errorcode, $text = '') { switch ($errorcode) { + case 0: + // this is not an error, just print information and exit + break; case 1: $text = 'Error: '.$text; break; diff --git a/lib/phpunit/lib.php b/lib/phpunit/lib.php index 521958ce639..8d38a75fd60 100644 --- a/lib/phpunit/lib.php +++ b/lib/phpunit/lib.php @@ -564,7 +564,7 @@ class phpunit_util { global $DB, $CFG; if (!self::is_test_site()) { - cli_error('Can not drop non-test sites!!', 131); + phpunit_bootstrap_error(131, 'Can not drop non-test site!!'); } // purge dataroot @@ -609,11 +609,16 @@ class phpunit_util { global $DB, $CFG; if (!self::is_test_site()) { - cli_error('Can not install non-test sites!!', 131); + phpunit_bootstrap_error(131, 'Can not install on non-test site!!'); } if ($DB->get_tables()) { - cli_error('Database tables already installed, drop the site first.', 133); + list($errorcode, $message) = phpunit_util::testing_ready_problem(); + if ($errorcode) { + phpunit_bootstrap_error(133, 'Database tables already installed, drop the site first.'); + } else { + phpunit_bootstrap_error(0, 'Test database is already initialised'); + } } $options = array();