@@ -127,6 +127,9 @@ function show_usage(): void
127
127
--color
128
128
--no-color Do/Don't colorize the result type in the test result.
129
129
130
+ --progress
131
+ --no-progress Do/Don't show the current progress.
132
+
130
133
--repeat [n]
131
134
Run the tests multiple times in the same process and check the
132
135
output of the last execution (CLI SAPI only).
@@ -159,7 +162,7 @@ function main(): void
159
162
$ temp_source , $ temp_target , $ test_cnt , $ test_dirs ,
160
163
$ test_files , $ test_idx , $ test_list , $ test_results , $ testfile ,
161
164
$ user_tests , $ valgrind , $ sum_results , $ shuffle , $ file_cache , $ num_repeats ,
162
- $ bless ;
165
+ $ bless, $ show_progress ;
163
166
// Parallel testing
164
167
global $ workers , $ workerID ;
165
168
global $ context_line_count ;
@@ -360,6 +363,7 @@ function main(): void
360
363
$ workers = null ;
361
364
$ context_line_count = 3 ;
362
365
$ num_repeats = 1 ;
366
+ $ show_progress = null ;
363
367
364
368
$ cfgtypes = ['show ' , 'keep ' ];
365
369
$ cfgfiles = ['skip ' , 'php ' , 'clean ' , 'out ' , 'diff ' , 'exp ' , 'mem ' ];
@@ -600,6 +604,12 @@ function main(): void
600
604
$ repeat = true ;
601
605
}
602
606
break ;
607
+ case '--progress ' :
608
+ $ show_progress = true ;
609
+ break ;
610
+ case '--no-progress ' :
611
+ $ show_progress = false ;
612
+ break ;
603
613
case '--version ' :
604
614
echo '$Id$ ' . "\n" ;
605
615
exit (1 );
@@ -639,6 +649,20 @@ function main(): void
639
649
die ('Cannot find test file " ' . $ argv [$ i ] . '". ' . PHP_EOL );
640
650
}
641
651
}
652
+
653
+ if ($ show_progress === null ) {
654
+ // Taken from https://github.com/vimeo/psalm/blob/1ef3851580acef380d083d9b4044bd8c6204b780/src/Psalm/Internal/CliUtils.php#L656
655
+ $ is_ci = isset ($ _SERVER ['TRAVIS ' ])
656
+ || isset ($ _SERVER ['CIRCLECI ' ])
657
+ || isset ($ _SERVER ['APPVEYOR ' ])
658
+ || isset ($ _SERVER ['JENKINS_URL ' ])
659
+ || isset ($ _SERVER ['SCRUTINIZER ' ])
660
+ || isset ($ _SERVER ['GITLAB_CI ' ])
661
+ || isset ($ _SERVER ['GITHUB_WORKFLOW ' ])
662
+ || isset ($ _SERVER ['DRONE ' ]);
663
+
664
+ $ show_progress = !$ is_ci ;
665
+ }
642
666
}
643
667
644
668
if ($ selected_tests && count ($ test_files ) === 0 ) {
@@ -1331,7 +1355,7 @@ function run_all_tests(array $test_files, array $env, $redir_tested = null): voi
1331
1355
*/
1332
1356
function run_all_tests_parallel (array $ test_files , array $ env , $ redir_tested ): void
1333
1357
{
1334
- global $ workers , $ test_idx , $ test_cnt , $ test_results , $ failed_tests_file , $ result_tests_file , $ PHP_FAILED_TESTS , $ shuffle , $ SHOW_ONLY_GROUPS , $ valgrind ;
1358
+ global $ workers , $ test_idx , $ test_cnt , $ test_results , $ failed_tests_file , $ result_tests_file , $ PHP_FAILED_TESTS , $ shuffle , $ SHOW_ONLY_GROUPS , $ valgrind, $ show_progress ;
1335
1359
1336
1360
global $ junit ;
1337
1361
@@ -1578,13 +1602,13 @@ function run_all_tests_parallel(array $test_files, array $env, $redir_tested): v
1578
1602
}
1579
1603
$ test_idx ++;
1580
1604
1581
- if (! $ SHOW_ONLY_GROUPS ) {
1605
+ if ($ show_progress ) {
1582
1606
clear_show_test ();
1583
1607
}
1584
1608
1585
1609
echo $ resultText ;
1586
1610
1587
- if (! $ SHOW_ONLY_GROUPS ) {
1611
+ if ($ show_progress ) {
1588
1612
show_test ($ test_idx , count ($ workerProcs ) . "/ $ workers concurrent test workers running " );
1589
1613
}
1590
1614
@@ -1634,7 +1658,7 @@ function run_all_tests_parallel(array $test_files, array $env, $redir_tested): v
1634
1658
}
1635
1659
}
1636
1660
1637
- if (! $ SHOW_ONLY_GROUPS ) {
1661
+ if ($ show_progress ) {
1638
1662
clear_show_test ();
1639
1663
}
1640
1664
@@ -3223,22 +3247,22 @@ function show_summary(): void
3223
3247
3224
3248
function show_redirect_start (string $ tests , string $ tested , string $ tested_file ): void
3225
3249
{
3226
- global $ SHOW_ONLY_GROUPS ;
3250
+ global $ SHOW_ONLY_GROUPS , $ show_progress ;
3227
3251
3228
3252
if (!$ SHOW_ONLY_GROUPS || in_array ('REDIRECT ' , $ SHOW_ONLY_GROUPS )) {
3229
3253
echo "REDIRECT $ tests ( $ tested [ $ tested_file]) begin \n" ;
3230
- } else {
3254
+ } elseif ( $ show_progress ) {
3231
3255
clear_show_test ();
3232
3256
}
3233
3257
}
3234
3258
3235
3259
function show_redirect_ends (string $ tests , string $ tested , string $ tested_file ): void
3236
3260
{
3237
- global $ SHOW_ONLY_GROUPS ;
3261
+ global $ SHOW_ONLY_GROUPS , $ show_progress ;
3238
3262
3239
3263
if (!$ SHOW_ONLY_GROUPS || in_array ('REDIRECT ' , $ SHOW_ONLY_GROUPS )) {
3240
3264
echo "REDIRECT $ tests ( $ tested [ $ tested_file]) done \n" ;
3241
- } else {
3265
+ } elseif ( $ show_progress ) {
3242
3266
clear_show_test ();
3243
3267
}
3244
3268
}
@@ -3280,7 +3304,7 @@ function show_result(
3280
3304
string $ extra = '' ,
3281
3305
?array $ temp_filenames = null
3282
3306
): void {
3283
- global $ SHOW_ONLY_GROUPS , $ colorize ;
3307
+ global $ SHOW_ONLY_GROUPS , $ colorize, $ show_progress ;
3284
3308
3285
3309
if (!$ SHOW_ONLY_GROUPS || in_array ($ result , $ SHOW_ONLY_GROUPS )) {
3286
3310
if ($ colorize ) {
@@ -3302,10 +3326,9 @@ function show_result(
3302
3326
} else {
3303
3327
echo "$ result $ tested [ $ tested_file] $ extra \n" ;
3304
3328
}
3305
- } elseif (! $ SHOW_ONLY_GROUPS ) {
3329
+ } elseif ($ show_progress ) {
3306
3330
clear_show_test ();
3307
3331
}
3308
-
3309
3332
}
3310
3333
3311
3334
class BorkageException extends Exception
0 commit comments