}
}
+/**
+ * Generate a relative path name to the given file.
+ * May explode on non-matching case-insensitive paths,
+ * funky symlinks, etc.
+ *
+ * @param string $path Absolute destination path including target filename
+ * @param string $from Absolute source path, directory only
+ * @return string
+ */
+function wfRelativePath( $path, $from ) {
+ $pieces = explode( DIRECTORY_SEPARATOR, dirname( $path ) );
+ $against = explode( DIRECTORY_SEPARATOR, $from );
+
+ // Trim off common prefix
+ while( count( $pieces ) && count( $against )
+ && $pieces[0] == $against[0] ) {
+ array_shift( $pieces );
+ array_shift( $against );
+ }
+
+ // relative dots to bump us to the parent
+ while( count( $against ) ) {
+ array_unshift( $pieces, '..' );
+ array_shift( $against );
+ }
+
+ array_push( $pieces, wfBaseName( $path ) );
+
+ return implode( DIRECTORY_SEPARATOR, $pieces );
+}
+
/**
* Make a URL index, appropriate for the el_index field of externallinks.
*/
$this->log( "$oldpath -> $newpath" );
if( rename( $oldpath, $newpath ) ) {
- $relpath = $this->relativize( $newpath, dirname( $oldpath ) );
+ $relpath = wfRelativePath( $newpath, dirname( $oldpath ) );
if( !symlink( $relpath, $oldpath ) ) {
$this->log( "... symlink failed!" );
}
}
}
- /**
- * Generate a relative path name to the given file.
- * Assumes Unix-style paths, separators, and semantics.
- *
- * @param string $path Absolute destination path including target filename
- * @param string $from Absolute source path, directory only
- * @return string
- * @access private
- * @static
- */
- function relativize( $path, $from ) {
- $pieces = explode( '/', dirname( $path ) );
- $against = explode( '/', $from );
-
- // Trim off common prefix
- while( count( $pieces ) && count( $against )
- && $pieces[0] == $against[0] ) {
- array_shift( $pieces );
- array_shift( $against );
- }
-
- // relative dots to bump us to the parent
- while( count( $against ) ) {
- array_unshift( $pieces, '..' );
- array_shift( $against );
- }
-
- array_push( $pieces, wfBaseName( $path ) );
-
- return implode( '/', $pieces );
- }
-
function upgradeOldImage() {
$tabledef = <<<END
CREATE TABLE $1 (
: new DummyTermColorer();
$this->showDiffs = !isset( $options['quick'] );
- $this->quiet = isset( $options['quiet'] );
+ $this->showProgress = !isset( $options['quiet'] );
+ $this->showFailure = !(
+ isset( $options['quiet'] )
+ && isset( $options['record'] ) ); // redundant output
+
$this->showOutput = isset( $options['show-output'] );
if( !$infile ) {
wfDie( "Couldn't open $filename\n" );
} else {
+ global $IP;
+ $relative = wfRelativePath( $filename, $IP );
print $this->term->color( 1 ) .
- "Reading tests from \"$filename\"..." .
+ "Reading tests from \"$relative\"..." .
$this->term->reset() .
"\n";
}
* @return bool
*/
function runTest( $desc, $input, $result, $opts ) {
- if( !$this->quiet ) {
+ if( $this->showProgress ) {
$this->showTesting( $desc );
}
* @private
*/
function showSuccess( $desc ) {
- if( !$this->quiet ) {
+ if( $this->showProgress ) {
print $this->term->color( '1;32' ) . 'PASSED' . $this->term->reset() . "\n";
}
return true;
* @private
*/
function showFailure( $desc, $result, $html ) {
- if( $this->quiet ) {
- # In quiet mode we didn't show the 'Testing' message before the
- # test, in case it succeeded. Show it now:
- $this->showTesting( $desc );
- }
- print $this->term->color( '1;31' ) . 'FAILED!' . $this->term->reset() . "\n";
- if ( $this->showOutput ) {
- print "--- Expected ---\n$result\n--- Actual ---\n$html\n";
- }
- if( $this->showDiffs ) {
- print $this->quickDiff( $result, $html );
- if( !$this->wellFormed( $html ) ) {
- print "XML error: $this->mXmlError\n";
+ if( $this->showFailure ) {
+ if( !$this->showProgress ) {
+ # In quiet mode we didn't show the 'Testing' message before the
+ # test, in case it succeeded. Show it now:
+ $this->showTesting( $desc );
+ }
+ print $this->term->color( '1;31' ) . 'FAILED!' . $this->term->reset() . "\n";
+ if ( $this->showOutput ) {
+ print "--- Expected ---\n$result\n--- Actual ---\n$html\n";
+ }
+ if( $this->showDiffs ) {
+ print $this->quickDiff( $result, $html );
+ if( !$this->wellFormed( $html ) ) {
+ print "XML error: $this->mXmlError\n";
+ }
}
}
return false;
array( 'previously passing test(s) now FAILING! :(', 1, 0 ),
array( 'previously FAILING test(s) removed O_o', 0, null ),
array( 'new FAILING test(s) :(', null, 0 ),
+ array( 'still FAILING test(s) :(', 0, 0 ),
);
foreach( $table as $criteria ) {
list( $label, $before, $after ) = $criteria;