@@ -7,7 +7,7 @@ $PHPUNIT_VERSION = 4.8;
7
7
$ PHPUNIT_DIR = __DIR__ .'/.phpunit ' ;
8
8
9
9
if (!file_exists ("$ PHPUNIT_DIR /phpunit- $ PHPUNIT_VERSION /phpunit " )) {
10
- # Build a standalone phpunit without symfony/yaml
10
+ // Build a standalone phpunit without symfony/yaml
11
11
12
12
$ oldPwd = getcwd ();
13
13
mkdir ($ PHPUNIT_DIR );
@@ -31,7 +31,7 @@ $cmd = array_map('escapeshellarg', $argv);
31
31
$ exit = 0 ;
32
32
33
33
if (isset ($ argv [1 ]) && 'symfony ' === $ argv [1 ]) {
34
- # Find Symfony components in plain php for Windows portability
34
+ // Find Symfony components in plain php for Windows portability
35
35
36
36
$ finder = new RecursiveDirectoryIterator ('src/Symfony ' , FilesystemIterator::KEY_AS_FILENAME | FilesystemIterator::UNIX_PATHS );
37
37
$ finder = new RecursiveIteratorIterator ($ finder );
@@ -45,7 +45,7 @@ if (isset($argv[1]) && 'symfony' === $argv[1]) {
45
45
if ('phpunit.xml.dist ' === $ file ) {
46
46
$ component = dirname ($ fileInfo ->getPathname ());
47
47
48
- # Run phpunit tests in parallel
48
+ // Run phpunit tests in parallel
49
49
50
50
$ c = escapeshellarg ($ component );
51
51
@@ -58,20 +58,34 @@ if (isset($argv[1]) && 'symfony' === $argv[1]) {
58
58
}
59
59
}
60
60
61
+ // Fixes for colors support on appveyor
62
+ // See http://help.appveyor.com/discussions/suggestions/197-support-ansi-color-codes
63
+ $ colorFixes = array (
64
+ array ("S \033[0m \033[0m \033[36m \033[1mS " , "E \033[0m \033[0m \033[31m \033[1mE " , "I \033[0m \033[0m \033[33m \033[1mI " , "F \033[0m \033[0m \033[41m \033[37mF " ),
65
+ array ("SS " , "EE " , "II " , "FF " ),
66
+ );
67
+ $ colorFixes [0 ] = array_merge ($ colorFixes [0 ], $ colorFixes [0 ]);
68
+ $ colorFixes [1 ] = array_merge ($ colorFixes [1 ], $ colorFixes [1 ]);
69
+
61
70
foreach ($ procs as $ component => $ proc ) {
62
71
$ procStatus = proc_close ($ proc );
63
72
64
73
foreach (array ('out ' , 'err ' ) as $ file ) {
65
74
$ file = "$ component/phpunit.std $ file " ;
66
- $ h = fopen ($ file , 'rb ' );
67
- while (false !== $ line = fgets ($ h )) {
68
- echo preg_replace_callback (
69
- '/\033\[[0-9]++(?:;[0-9]++)++m/ ' ,
70
- function ($ m ) {return str_replace ('; ' , "m \033[ " , $ m [0 ]);},
71
- $ line
72
- );
75
+
76
+ if ('\\' === DIRECTORY_SEPARATOR ) {
77
+ $ h = fopen ($ file , 'rb ' );
78
+ while (false !== $ line = fgets ($ h )) {
79
+ echo str_replace ($ colorFixes [0 ], $ colorFixes [1 ], preg_replace (
80
+ '/(\033\[[0-9]++);([0-9]++m)(?:(.)(\033\[0m))?/ ' ,
81
+ "$1m \033[$2$3$4$4 " ,
82
+ $ line
83
+ ));
84
+ }
85
+ fclose ($ h );
86
+ } else {
87
+ readfile ($ file );
73
88
}
74
- fclose ($ h );
75
89
unlink ($ file );
76
90
}
77
91
@@ -84,32 +98,28 @@ if (isset($argv[1]) && 'symfony' === $argv[1]) {
84
98
}
85
99
86
100
} elseif (!isset ($ argv [1 ]) || 'install ' !== $ argv [1 ]) {
87
- # Run regular phpunit in a subprocess
101
+ // Run regular phpunit in a subprocess
88
102
89
103
$ cmd [0 ] = "php $ PHPUNIT_DIR /phpunit- $ PHPUNIT_VERSION /phpunit --colors=always " ;
90
104
91
105
$ errFile = tempnam (sys_get_temp_dir (), 'phpunit.stderr. ' );
92
106
if ($ proc = proc_open (implode (' ' , $ cmd ).' 2> ' .escapeshellarg ($ errFile ), array (1 => array ('pipe ' , 'w ' )), $ pipes )) {
93
- while (false !== $ line = fgets ($ pipes [1 ])) {
94
- echo $ line ;
95
- }
107
+ stream_copy_to_stream ($ pipes [1 ], STDOUT );
96
108
fclose ($ pipes [1 ]);
97
109
$ exit = proc_close ($ proc );
98
110
99
- $ h = fopen ($ errFile , 'rb ' );
100
- while (false !== $ line = fgets ($ h )) {
101
- echo $ line ;
102
- }
103
- fclose ($ h );
111
+ readfile ($ errFile );
104
112
unlink ($ errFile );
105
113
}
106
114
107
- if (file_exists ($ component = array_pop ($ argv ))) {
108
- if ($ exit ) {
109
- echo "\033[41mKO \033[0m $ component \n\n" ;
110
- } else {
111
- echo "\033[32mOK \033[0m $ component \n\n" ;
112
- }
115
+ if (!file_exists ($ component = array_pop ($ argv ))) {
116
+ $ component = basename (getcwd ());
117
+ }
118
+
119
+ if ($ exit ) {
120
+ echo "\033[41mKO \033[0m $ component \n\n" ;
121
+ } else {
122
+ echo "\033[32mOK \033[0m $ component \n\n" ;
113
123
}
114
124
}
115
125
0 commit comments