r104553 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r104552‎ | r104553 | r104554 >
Date:12:17, 29 November 2011
Author:hashar
Status:ok (Comments)
Tags:
Comment:
Move terminal colorers classes in their own file

They were originally written for parserTests output and were in
tests/testHelpers.inc since them. Those classes can be used by most
our maintenance scripts anyway, so here is their new home.

Also make tests/testHelpers.inc a bit shorter which is always welcome.
Modified paths:
  • /trunk/phase3/includes/AutoLoader.php (modified) (history)
  • /trunk/phase3/maintenance/term (added) (history)
  • /trunk/phase3/maintenance/term/MWTerm.php (added) (history)
  • /trunk/phase3/tests/testHelpers.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/term/MWTerm.php
@@ -0,0 +1,50 @@
 2+<?php
 3+
 4+/**
 5+ * @ingroup Testing
 6+ *
 7+ * Set of classes to help with test output and such. Right now pretty specific
 8+ * to the parser tests but could be more useful one day :)
 9+ *
 10+ * @todo Fixme: Make this more generic
 11+ */
 12+
 13+class AnsiTermColorer {
 14+ function __construct() {
 15+ }
 16+
 17+ /**
 18+ * Return ANSI terminal escape code for changing text attribs/color
 19+ *
 20+ * @param $color String: semicolon-separated list of attribute/color codes
 21+ * @return String
 22+ */
 23+ public function color( $color ) {
 24+ global $wgCommandLineDarkBg;
 25+
 26+ $light = $wgCommandLineDarkBg ? "1;" : "0;";
 27+
 28+ return "\x1b[{$light}{$color}m";
 29+ }
 30+
 31+ /**
 32+ * Return ANSI terminal escape code for restoring default text attributes
 33+ *
 34+ * @return String
 35+ */
 36+ public function reset() {
 37+ return $this->color( 0 );
 38+ }
 39+}
 40+
 41+/* A colour-less terminal */
 42+class DummyTermColorer {
 43+ public function color( $color ) {
 44+ return '';
 45+ }
 46+
 47+ public function reset() {
 48+ return '';
 49+ }
 50+}
 51+
Property changes on: trunk/phase3/maintenance/term/MWTerm.php
___________________________________________________________________
Added: svn:mergeinfo
152 Merged /branches/phpunit-restructure/maintenance/tests/testHelpers.inc:r72257-72560
Added: svn:eol-style
253 + native
Index: trunk/phase3/tests/testHelpers.inc
@@ -1,53 +1,5 @@
22 <?php
33
4 -/**
5 - * @ingroup Testing
6 - *
7 - * Set of classes to help with test output and such. Right now pretty specific
8 - * to the parser tests but could be more useful one day :)
9 - *
10 - * @todo Fixme: Make this more generic
11 - */
12 -
13 -class AnsiTermColorer {
14 - function __construct() {
15 - }
16 -
17 - /**
18 - * Return ANSI terminal escape code for changing text attribs/color
19 - *
20 - * @param $color String: semicolon-separated list of attribute/color codes
21 - * @return String
22 - */
23 - public function color( $color ) {
24 - global $wgCommandLineDarkBg;
25 -
26 - $light = $wgCommandLineDarkBg ? "1;" : "0;";
27 -
28 - return "\x1b[{$light}{$color}m";
29 - }
30 -
31 - /**
32 - * Return ANSI terminal escape code for restoring default text attributes
33 - *
34 - * @return String
35 - */
36 - public function reset() {
37 - return $this->color( 0 );
38 - }
39 -}
40 -
41 -/* A colour-less terminal */
42 -class DummyTermColorer {
43 - public function color( $color ) {
44 - return '';
45 - }
46 -
47 - public function reset() {
48 - return '';
49 - }
50 -}
51 -
524 class TestRecorder {
535 var $parent;
546 var $term;
Index: trunk/phase3/includes/AutoLoader.php
@@ -885,11 +885,13 @@
886886 'textStatsOutput' => 'maintenance/language/StatOutputs.php',
887887 'wikiStatsOutput' => 'maintenance/language/StatOutputs.php',
888888
 889+ # maintenance/term
 890+ 'AnsiTermColorer' => 'maintenance/term/MWTerm.php',
 891+ 'DummyTermColorer' => 'maintenance/term/MWTerm.php',
 892+
889893 # tests
890 - 'AnsiTermColorer' => 'tests/testHelpers.inc',
891894 'DbTestPreviewer' => 'tests/testHelpers.inc',
892895 'DbTestRecorder' => 'tests/testHelpers.inc',
893 - 'DummyTermColorer' => 'tests/testHelpers.inc',
894896 'TestFileIterator' => 'tests/testHelpers.inc',
895897 'TestRecorder' => 'tests/testHelpers.inc',
896898

Comments

#Comment by Nikerabbit (talk | contribs)   07:22, 2 December 2011

Term can mean just about anything without context. We have seen what happens when people make random shortenings: PHP has tempnam and tmpfile :)

Status & tagging log