From 1892098bf0952c41a2ef0d514b8ed1577045c9f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20S=CC=8Ckoda?= Date: Fri, 25 Jan 2013 23:35:46 +0100 Subject: [PATCH] MDL-37713 let phpunit bootstrap create test dataroot if necessary --- lib/phpunit/bootstrap.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/phpunit/bootstrap.php b/lib/phpunit/bootstrap.php index f94c2950d6f..2339cf85d97 100644 --- a/lib/phpunit/bootstrap.php +++ b/lib/phpunit/bootstrap.php @@ -93,12 +93,8 @@ $CFG->filepermissions = ($CFG->directorypermissions & 0666); if (!isset($CFG->phpunit_dataroot)) { phpunit_bootstrap_error(PHPUNIT_EXITCODE_CONFIGERROR, 'Missing $CFG->phpunit_dataroot in config.php, can not run tests!'); } -// Ensure we access to phpunit_dataroot realpath always. -$CFG->phpunit_dataroot = realpath($CFG->phpunit_dataroot); -if (isset($CFG->dataroot) and $CFG->phpunit_dataroot === $CFG->dataroot) { - phpunit_bootstrap_error(PHPUNIT_EXITCODE_CONFIGERROR, '$CFG->dataroot and $CFG->phpunit_dataroot must not be identical, can not run tests!'); -} +// Create test dir if does not exists yet. if (!file_exists($CFG->phpunit_dataroot)) { mkdir($CFG->phpunit_dataroot, $CFG->directorypermissions); } @@ -106,6 +102,13 @@ if (!is_dir($CFG->phpunit_dataroot)) { phpunit_bootstrap_error(PHPUNIT_EXITCODE_CONFIGERROR, '$CFG->phpunit_dataroot directory can not be created, can not run tests!'); } +// Ensure we access to phpunit_dataroot realpath always. +$CFG->phpunit_dataroot = realpath($CFG->phpunit_dataroot); + +if (isset($CFG->dataroot) and $CFG->phpunit_dataroot === $CFG->dataroot) { + phpunit_bootstrap_error(PHPUNIT_EXITCODE_CONFIGERROR, '$CFG->dataroot and $CFG->phpunit_dataroot must not be identical, can not run tests!'); +} + if (!is_writable($CFG->phpunit_dataroot)) { // try to fix permissions if possible if (function_exists('posix_getuid')) {