MediaWiki r19401 - Code Review

Jump to: navigation, search
Repository:MediaWiki
Revision:r19400‎ | r19401 (on ViewVC)‎ | r19402 >
Date:21:24, 17 January 2007
Author:hashar
Status:old
Tags:
Comment:
* Fix hardcoded background color in parserTests.php
* AnsiTermColorer::reset() now calls color(0)
* parserTests.php : remove 'light' option for --color switch
Modified paths:

Diff [purge]

Index: trunk/phase3/maintenance/parserTests.inc
===================================================================
--- trunk/phase3/maintenance/parserTests.inc	(revision 19400)
+++ trunk/phase3/maintenance/parserTests.inc	(revision 19401)
@@ -48,12 +48,6 @@
 	var $color;
 
 	/**
-	 * boolean $lightcolor whereas output should use light colors
-	 * @private
-	 */
-	var $lightcolor;
-
-	/**
 	 * boolean $showOutput Show test output
 	 */
 	var $showOutput;
@@ -68,7 +62,6 @@
 		global $options;
 
 		# Only colorize output if stdout is a terminal.
-		$this->lightcolor = false;
 		$this->color = !wfIsWindows() && posix_isatty(1);
 
 		if( isset( $options['color'] ) ) {
@@ -76,9 +69,6 @@
 			case 'no':
 				$this->color = false;
 				break;
-			case 'light':
-				$this->lightcolor = true;
-				# Fall through
 			case 'yes':
 			default:
 				$this->color = true;
@@ -86,7 +76,7 @@
 			}
 		}
 		$this->term = $this->color
-			? new AnsiTermColorer( $this->lightcolor )
+			? new AnsiTermColorer()
 			: new DummyTermColorer();
 
 		$this->showDiffs = !isset( $options['quick'] );
@@ -682,7 +672,7 @@
 				# test, in case it succeeded. Show it now:
 				$this->showTesting( $desc );
 			}
-			print $this->term->color( '1;31' ) . 'FAILED!' . $this->term->reset() . "\n";
+			print $this->term->color( '31' ) . 'FAILED!' . $this->term->reset() . "\n";
 			if ( $this->showOutput ) {
 				print "--- Expected ---\n$result\n--- Actual ---\n$html\n";
 			}
@@ -873,8 +863,7 @@
 }
 
 class AnsiTermColorer {
-	function __construct( $light ) {
-		$this->light = $light;
+	function __construct() {
 	}
 
 	/**
@@ -885,7 +874,8 @@
 	 * @private
 	 */
 	function color( $color ) {
-		$light = $this->light ? "1;" : "";
+		global $wgCommandLineDarkBg;
+		$light = $wgCommandLineDarkBg ? "1;" : "0;";
 		return "\x1b[{$light}{$color}m";
 	}
 
@@ -896,7 +886,7 @@
 	 * @private
 	 */
 	function reset() {
-		return "\x1b[0m";
+		return $this->color( 0 );
 	}
 }
 
Index: trunk/phase3/maintenance/parserTests.php
===================================================================
--- trunk/phase3/maintenance/parserTests.php	(revision 19400)
+++ trunk/phase3/maintenance/parserTests.php	(revision 19401)
@@ -29,7 +29,7 @@
     echo <<<ENDS
 MediaWiki $wgVersion parser test suite
 Usage: php parserTests.php [--quick] [--quiet] [--show-output]
-                           [--color[=(yes|no|light)]]
+                           [--color[=(yes|no)]]
                            [--regex=<expression>] [--file=<testfile>]
                            [--record]
                            [--help]
@@ -38,7 +38,7 @@
   --quiet          Suppress notification of passed tests (shows only failed tests)
   --show-output    Show expected and actual output
   --color          Override terminal detection and force color output on or off
-                   'light' option is similar to 'yes' but with color for dark backgrounds
+                   use wgCommandLineDarkBg = true; if your term is dark 
   --regex          Only run tests whose descriptions which match given regex
   --file           Run test cases from a custom file instead of parserTests.txt
   --record         Record tests in database
Index: trunk/phase3/maintenance/Makefile
===================================================================
--- trunk/phase3/maintenance/Makefile	(revision 19400)
+++ trunk/phase3/maintenance/Makefile	(revision 19401)
@@ -7,9 +7,6 @@
 test:
 	php parserTests.php
 
-test-light:
-	php parserTests.php --color=light
-
 doc:
 	php mwdocgen.php -all
 	echo 'Doc generation done. Look at ./docs/html/'
Index: trunk/phase3/includes/DefaultSettings.php
===================================================================
--- trunk/phase3/includes/DefaultSettings.php	(revision 19400)
+++ trunk/phase3/includes/DefaultSettings.php	(revision 19401)
@@ -1518,6 +1518,8 @@
 	$wgCommandLineMode = false;
 }
 
+/** For colorized maintenance script output, is your terminal background dark ? */
+$wgCommandLineDarkBg = false;
 
 #
 # Recent changes settings
Index: trunk/phase3/RELEASE-NOTES
===================================================================
--- trunk/phase3/RELEASE-NOTES	(revision 19400)
+++ trunk/phase3/RELEASE-NOTES	(revision 19401)
@@ -20,6 +20,12 @@
 
 == Configuration changes ==
 
+=== $wgCommandLineDarkBg ==
+
+A new switch used by maintenance scripts (parserTests.php). It lets you specify
+if your terminal use a dark background, the colorized output will be made
+lighter making things easier to read.
+
 == Major new features ==
 
 == Changes since 1.9 ==
@@ -106,6 +112,9 @@
 * (bug 8641) Fix order of updates to ipblocks table
 * (bug 8678) Fix detection of self-links for numeric titles in Parser
 * (bug 6171) Magically close tags in tables when not using Tidy.
+* Fix hardcoded background color in parserTests.php
+* parserTests.php : removed the 'light' option for --color argument, replacing
+  it with a new global switch : $wgCommandLineDarkBg
 
 == Languages updated ==
 
Personal tools
Namespaces
Variants
Views
Actions
Site
Support
Download
Development
Communication
Toolbox