http://www.mediawiki.org/wiki/Special:Code/MediaWiki/90021
Revision: 90021
Author: demon
Date: 2011-06-13 23:43:01 +0000 (Mon, 13 Jun 2011)
Log Message:
-----------
Convert a couple of wfDie()s to exceptions
Modified Paths:
--------------
trunk/phase3/tests/parser/parserTest.inc
trunk/phase3/tests/testHelpers.inc
Modified: trunk/phase3/tests/parser/parserTest.inc
===================================================================
--- trunk/phase3/tests/parser/parserTest.inc 2011-06-13 23:28:59 UTC (rev
90020)
+++ trunk/phase3/tests/parser/parserTest.inc 2011-06-13 23:43:01 UTC (rev
90021)
@@ -1138,14 +1138,13 @@
$title = Title::newFromText( $name );
if ( is_null( $title ) ) {
- wfDie( "invalid title ('$name' => '$title') at line
$line\n" );
+ throw new MWException( "invalid title ('$name' =>
'$title') at line $line\n" );
}
$aid = $title->getArticleID( Title::GAID_FOR_UPDATE );
if ( $aid != 0 ) {
- debug_print_backtrace();
- wfDie( "duplicate article '$name' at line $line\n" );
+ throw new MWException( "duplicate article '$name' at
line $line\n" );
}
$art = new Article( $title );
Modified: trunk/phase3/tests/testHelpers.inc
===================================================================
--- trunk/phase3/tests/testHelpers.inc 2011-06-13 23:28:59 UTC (rev 90020)
+++ trunk/phase3/tests/testHelpers.inc 2011-06-13 23:43:01 UTC (rev 90021)
@@ -75,7 +75,7 @@
if ( $this->total > 0 ) {
$this->reportPercentage( $this->success, $this->total );
} else {
- wfDie( "No tests found.\n" );
+ throw new MWException( "No tests found.\n" );
}
}
@@ -458,7 +458,7 @@
$this->fh = fopen( $this->file, "rt" );
if ( !$this->fh ) {
- wfDie( "Couldn't open file '$file'\n" );
+ throw new MWException( "Couldn't open file '$file'\n" );
}
$this->parserTest = $parserTest;
@@ -469,7 +469,7 @@
function rewind() {
if ( fseek( $this->fh, 0 ) ) {
- wfDie( "Couldn't fseek to the start of '$this->file'\n"
);
+ throw new MWException( "Couldn't fseek to the start of
'$this->file'\n" );
}
$this->index = -1;
@@ -514,11 +514,11 @@
if ( $section == 'endarticle' ) {
if ( !isset( $data['text'] ) ) {
- wfDie( "'endarticle' without
'text' at line {$this->lineNum} of $this->file\n" );
+ throw new MWException(
"'endarticle' without 'text' at line {$this->lineNum} of $this->file\n" );
}
if ( !isset( $data['article'] ) ) {
- wfDie( "'endarticle' without
'article' at line {$this->lineNum} of $this->file\n" );
+ throw new MWException(
"'endarticle' without 'article' at line {$this->lineNum} of $this->file\n" );
}
$this->parserTest->addArticle(
ParserTest::chomp( $data['article'] ), $data['text'], $this->lineNum );
@@ -531,7 +531,7 @@
if ( $section == 'endhooks' ) {
if ( !isset( $data['hooks'] ) ) {
- wfDie( "'endhooks' without
'hooks' at line {$this->lineNum} of $this->file\n" );
+ throw new MWException(
"'endhooks' without 'hooks' at line {$this->lineNum} of $this->file\n" );
}
foreach ( explode( "\n", $data['hooks']
) as $line ) {
@@ -552,7 +552,7 @@
if ( $section == 'endfunctionhooks' ) {
if ( !isset( $data['functionhooks'] ) )
{
- wfDie( "'endfunctionhooks'
without 'functionhooks' at line {$this->lineNum} of $this->file\n" );
+ throw new MWException(
"'endfunctionhooks' without 'functionhooks' at line {$this->lineNum} of
$this->file\n" );
}
foreach ( explode( "\n",
$data['functionhooks'] ) as $line ) {
@@ -573,15 +573,15 @@
if ( $section == 'end' ) {
if ( !isset( $data['test'] ) ) {
- wfDie( "'end' without 'test' at
line {$this->lineNum} of $this->file\n" );
+ throw new MWException( "'end'
without 'test' at line {$this->lineNum} of $this->file\n" );
}
if ( !isset( $data['input'] ) ) {
- wfDie( "'end' without 'input'
at line {$this->lineNum} of $this->file\n" );
+ throw new MWException( "'end'
without 'input' at line {$this->lineNum} of $this->file\n" );
}
if ( !isset( $data['result'] ) ) {
- wfDie( "'end' without 'result'
at line {$this->lineNum} of $this->file\n" );
+ throw new MWException( "'end'
without 'result' at line {$this->lineNum} of $this->file\n" );
}
if ( !isset( $data['options'] ) ) {
@@ -611,7 +611,7 @@
}
if ( isset ( $data[$section] ) ) {
- wfDie( "duplicate section '$section' at
line {$this->lineNum} of $this->file\n" );
+ throw new MWException( "duplicate
section '$section' at line {$this->lineNum} of $this->file\n" );
}
$data[$section] = '';
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs