1
1
var q = require ( 'q' ) ,
2
2
helper = require ( './util' ) ,
3
- ConfigParser = require ( './configParser' ) ;
3
+ ConfigParser = require ( './configParser' ) ,
4
+ log = require ( './logger' ) ;
4
5
5
6
var logPrefix = '[plugins]' ;
6
7
@@ -11,7 +12,7 @@ var logPrefix = '[plugins]';
11
12
*/
12
13
var log_ = function ( ) {
13
14
var args = [ logPrefix ] . concat ( [ ] . slice . call ( arguments ) ) ;
14
- console . log . apply ( console , args ) ;
15
+ log . puts . apply ( log , args ) ;
15
16
} ;
16
17
17
18
/**
@@ -42,16 +43,36 @@ var Plugins = function(config) {
42
43
} ) ;
43
44
} ;
44
45
45
- var green = '\x1b[32m' ;
46
- var red = '\x1b[31m' ;
47
- var normalColor = '\x1b[39m' ;
46
+ var noop = function ( ) { } ;
48
47
49
- var printResult = function ( message , pass ) {
50
- console . log ( pass ? green : red ,
51
- '\t' , pass ? 'Pass: ' : 'Fail: ' , message , normalColor ) ;
52
- } ;
48
+ Plugins . printPluginResults = function ( specResults ) {
49
+ var green = '\x1b[32m' ;
50
+ var red = '\x1b[31m' ;
51
+ var normalColor = '\x1b[39m' ;
53
52
54
- var noop = function ( ) { } ;
53
+ var printResult = function ( message , pass ) {
54
+ log . puts ( pass ? green : red ,
55
+ '\t' , pass ? 'Pass: ' : 'Fail: ' , message , normalColor ) ;
56
+ } ;
57
+
58
+ for ( var j = 0 ; j < specResults . length ; j ++ ) {
59
+ var specResult = specResults [ j ] ;
60
+ var passed = specResult . assertions . map ( function ( x ) {
61
+ return x . passed ;
62
+ } ) . reduce ( function ( x , y ) {
63
+ return x && y ;
64
+ } , true ) ;
65
+
66
+ printResult ( specResult . description , passed ) ;
67
+ if ( ! passed ) {
68
+ for ( var k = 0 ; k < specResult . assertions . length ; k ++ ) {
69
+ if ( ! specResult . assertions [ k ] . passed ) {
70
+ log . puts ( '\t\t' + specResult . assertions [ k ] . errorMsg ) ;
71
+ }
72
+ }
73
+ }
74
+ }
75
+ }
55
76
56
77
function pluginFunFactory ( funName ) {
57
78
return function ( ) {
@@ -81,25 +102,8 @@ function pluginFunFactory(funName) {
81
102
82
103
// Output test results
83
104
if ( pluginResult . specResults ) {
84
- console . log ( 'Plugin: ' + names [ i ] + ' (' + funName + ')' ) ;
85
- for ( var j = 0 ; j < pluginResult . specResults . length ; j ++ ) {
86
- var specResult = pluginResult . specResults [ j ] ;
87
- var passed = specResult . assertions . map ( function ( x ) {
88
- return x . passed ;
89
- } ) . reduce ( function ( x , y ) {
90
- return x && y ;
91
- } , true ) ;
92
-
93
-
94
- printResult ( specResult . description , passed ) ;
95
- if ( ! passed ) {
96
- for ( var k = 0 ; k < specResult . assertions . length ; k ++ ) {
97
- if ( ! specResult . assertions [ k ] . passed ) {
98
- console . log ( '\t\t' + specResult . assertions [ k ] . errorMsg ) ;
99
- }
100
- }
101
- }
102
- }
105
+ log . puts ( 'Plugin: ' + names [ i ] + ' (' + funName + ')' ) ;
106
+ Plugins . printPluginResults ( pluginResult . specResults ) ;
103
107
}
104
108
105
109
// Join objects
0 commit comments