[ Index ] |
|
Code source de eZ Publish 3.9.0 |
1 #!/usr/bin/env php 2 <?php 3 // 4 // Created on: <18-Mar-2003 17:06:45 amos> 5 // 6 // SOFTWARE NAME: eZ publish 7 // SOFTWARE RELEASE: 3.9.0 8 // BUILD VERSION: 17785 9 // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS 10 // SOFTWARE LICENSE: GNU General Public License v2.0 11 // NOTICE: > 12 // This program is free software; you can redistribute it and/or 13 // modify it under the terms of version 2.0 of the GNU General 14 // Public License as published by the Free Software Foundation. 15 // 16 // This program is distributed in the hope that it will be useful, 17 // but WITHOUT ANY WARRANTY; without even the implied warranty of 18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 // GNU General Public License for more details. 20 // 21 // You should have received a copy of version 2.0 of the GNU General 22 // Public License along with this program; if not, write to the Free 23 // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 24 // MA 02110-1301, USA. 25 // 26 // 27 28 include_once ( "lib/ezutils/classes/ezextension.php" ); 29 include_once ( "lib/ezutils/classes/ezmodule.php" ); 30 include_once ( 'lib/ezutils/classes/ezcli.php' ); 31 include_once ( 'lib/ezutils/classes/ezini.php' ); 32 include_once ( 'kernel/classes/ezscript.php' ); 33 include_once ( 'lib/compat.php' ); 34 35 $ini =& eZINI::instance(); 36 $ini->appendOverrideDir( 'tests/settings', true ); 37 38 $cli =& eZCLI::instance(); 39 $script =& eZScript::instance( array( 'description' => ( "eZ publish Unit Tester\n" . 40 "Runs selected unit tests.\n" . 41 "\n" . 42 "The syntax of SUITE can be one of:\n" . 43 "SUITENAME - Run all tests in suite SUITENAME\n" . 44 "SUITENAME:TESTNAME - Run only test TESTNAME in suite SUITENAME" ), 45 'use-session' => false, 46 'use-modules' => true, 47 'use-extensions' => true ) ); 48 49 $script->startup(); 50 $options = $script->getOptions( "", 51 "[suite*]", 52 array( 'compile-directory' => "Where to place compiled files,\ndefault is template/compiled in current cache directory" ) ); 53 54 /* Use the 'test' site access if none is set, 55 this ensures that only ini settings which are good for the 56 test is used (e.g override.ini) */ 57 if ( !$script->usedSiteAccess() ) 58 { 59 $script->setUseSiteAccess( 'test' ); 60 } 61 62 $suiteList = array(); 63 foreach ( $options['arguments'] as $suiteName ) 64 { 65 $suiteTestName = false; 66 $suiteTestEntryName = false; 67 if ( preg_match( "/^([a-zA-Z0-9_]+):([a-zA-Z0-9_]+):([a-zA-Z0-9_]+)/", $suiteName, $matches ) ) 68 { 69 $suiteName = $matches[1]; 70 $suiteTestName = $matches[2]; 71 $suiteTestEntryName = strtolower( $suiteTestName . '::' . $matches[3] ); 72 } 73 else if ( preg_match( "/^([a-zA-Z0-9_]+):([a-zA-Z0-9_]+)/", $suiteName, $matches ) ) 74 { 75 $suiteName = $matches[1]; 76 $suiteTestName = $matches[2]; 77 } 78 79 if ( !in_array( $suiteName, $suiteList ) ) 80 $suiteList[] = $suiteName; 81 82 if ( $suiteTestName ) 83 { 84 if ( !isset( $suiteTestMap[$suiteName] ) ) 85 $suiteTestMap[$suiteName] = array(); 86 if ( $suiteTestEntryName ) 87 { 88 if ( !isset( $suiteTestMap[$suiteName][$suiteTestName] ) or 89 !is_array( $suiteTestMap[$suiteName][$suiteTestName] ) ) 90 $suiteTestMap[$suiteName][$suiteTestName] = array(); 91 $suiteTestMap[$suiteName][$suiteTestName][] = $suiteTestEntryName; 92 } 93 else 94 { 95 $suiteTestMap[$suiteName][$suiteTestName] = true; 96 } 97 } 98 } 99 100 $script->initialize(); 101 102 if ( count( $suiteList ) == 0 ) 103 { 104 $script->showHelp(); 105 $script->shutdown( 1 ); 106 } 107 108 include_once ( 'tests/classes/eztestcase.php' ); 109 include_once ( 'tests/classes/eztestsuite.php' ); 110 include_once ( 'tests/classes/eztestclirunner.php' ); 111 112 $success = true; 113 114 foreach ( $suiteList as $suiteName ) 115 { 116 $suitePath = 'tests/' . $suiteName; 117 $suiteDefinitionPath = $suitePath . '/testsuite.php'; 118 if ( file_exists( $suiteDefinitionPath ) ) 119 { 120 unset( $SuiteDefinition ); 121 include( $suiteDefinitionPath ); 122 if ( isset( $SuiteDefinition ) ) 123 { 124 $suite = new eZTestSuite( $SuiteDefinition['name'] ); 125 $testsToRun = array(); 126 foreach ( $SuiteDefinition['tests'] as $testDefinition ) 127 { 128 $testUnitName = $testDefinition['name']; 129 if ( isset( $suiteTestMap[$suiteName] ) ) 130 { 131 if ( !isset( $suiteTestMap[$suiteName][$testUnitName] ) ) 132 continue; 133 $testsToRun = array_merge( $testsToRun, $suiteTestMap[$suiteName][$testUnitName] ); 134 } 135 $testUnitFile = $testDefinition['file']; 136 $testUnitPath = $suitePath . '/' . $testUnitFile; 137 if ( file_exists( $testUnitPath ) ) 138 { 139 include_once( $testUnitPath ); 140 $testUnitClass = $testDefinition['class']; 141 if ( class_exists( $testUnitClass ) ) 142 { 143 $testUnit = new $testUnitClass( $testUnitName ); 144 $suite->addUnit( $testUnit ); 145 } 146 else 147 { 148 $cli->warning( "Could not find test unit class '" . $cli->stylize( 'emphasize', $testUnitClass ) . "' for test suite " . 149 $cli->stylize( 'emphasize', $suiteName ) ); 150 } 151 } 152 else 153 { 154 $cli->warning( "Could not find a test unit file '" . $cli->stylize( 'emphasize', $testUnitFile ) . "' for test suite " . 155 $cli->stylize( 'emphasize', $suiteName ) ); 156 } 157 } 158 $cli->output( "Test results from suite " . $cli->stylize( 'emphasize', $suiteName ) ); 159 $runner = new eZTestCLIRunner(); 160 if ( count( $testsToRun ) == 0 ) 161 $testsToRun = true; 162 $runner->run( $suite, true, $testsToRun ); 163 164 if ( !$runner->isSuccessful() ) 165 $success = false; 166 } 167 else 168 { 169 $cli->warning( "Could not find a suite definition for test suite " . 170 $cli->stylize( 'emphasize', $suiteName ) . "\n" . 171 $cli->stylize( 'emphasize', "\$SuiteDefinition" ) . " is missing" ); 172 } 173 } 174 else 175 { 176 $cli->warning( "Could not find a suite definition for test suite " . $cli->stylize( 'emphasize', $suiteName ) . "\nTried $suiteDefinitionPath" ); 177 } 178 } 179 180 $exitStatus = 0; 181 if ( !$success ) 182 { 183 $cli->output(); 184 $cli->output( $cli->stylize( 'failure', "Some tests failed" ) ); 185 $exitStatus = 1; 186 } 187 188 $script->shutdown(); 189 190 exit( $exitStatus ); 191 192 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Feb 24 10:30:04 2007 | par Balluche grâce à PHPXref 0.7 |