@@ -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,22 @@ 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 ['APPVEYOR ' ])
656
+ || isset ($ _SERVER ['BUILD_DEFINITIONVERSION ' ]) // Azure pipelines
657
+ || isset ($ _SERVER ['CIRCLECI ' ])
658
+ || isset ($ _SERVER ['CIRRUS_CI ' ])
659
+ || isset ($ _SERVER ['DRONE ' ])
660
+ || isset ($ _SERVER ['GITHUB_WORKFLOW ' ])
661
+ || isset ($ _SERVER ['GITLAB_CI ' ])
662
+ || isset ($ _SERVER ['JENKINS_URL ' ])
663
+ || isset ($ _SERVER ['SCRUTINIZER ' ])
664
+ || isset ($ _SERVER ['TRAVIS ' ]);
665
+
666
+ $ show_progress = !$ is_ci ;
667
+ }
642
668
}
643
669
644
670
if ($ selected_tests && count ($ test_files ) === 0 ) {
@@ -1331,7 +1357,7 @@ function run_all_tests(array $test_files, array $env, $redir_tested = null): voi
1331
1357
*/
1332
1358
function run_all_tests_parallel (array $ test_files , array $ env , $ redir_tested ): void
1333
1359
{
1334
- global $ workers , $ test_idx , $ test_cnt , $ test_results , $ failed_tests_file , $ result_tests_file , $ PHP_FAILED_TESTS , $ shuffle , $ SHOW_ONLY_GROUPS , $ valgrind ;
1360
+ 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
1361
1336
1362
global $ junit ;
1337
1363
@@ -1578,13 +1604,13 @@ function run_all_tests_parallel(array $test_files, array $env, $redir_tested): v
1578
1604
}
1579
1605
$ test_idx ++;
1580
1606
1581
- if (! $ SHOW_ONLY_GROUPS ) {
1607
+ if ($ show_progress ) {
1582
1608
clear_show_test ();
1583
1609
}
1584
1610
1585
1611
echo $ resultText ;
1586
1612
1587
- if (! $ SHOW_ONLY_GROUPS ) {
1613
+ if ($ show_progress ) {
1588
1614
show_test ($ test_idx , count ($ workerProcs ) . "/ $ workers concurrent test workers running " );
1589
1615
}
1590
1616
@@ -1634,7 +1660,7 @@ function run_all_tests_parallel(array $test_files, array $env, $redir_tested): v
1634
1660
}
1635
1661
}
1636
1662
1637
- if (! $ SHOW_ONLY_GROUPS ) {
1663
+ if ($ show_progress ) {
1638
1664
clear_show_test ();
1639
1665
}
1640
1666
@@ -3223,22 +3249,22 @@ function show_summary(): void
3223
3249
3224
3250
function show_redirect_start (string $ tests , string $ tested , string $ tested_file ): void
3225
3251
{
3226
- global $ SHOW_ONLY_GROUPS ;
3252
+ global $ SHOW_ONLY_GROUPS , $ show_progress ;
3227
3253
3228
3254
if (!$ SHOW_ONLY_GROUPS || in_array ('REDIRECT ' , $ SHOW_ONLY_GROUPS )) {
3229
3255
echo "REDIRECT $ tests ( $ tested [ $ tested_file]) begin \n" ;
3230
- } else {
3256
+ } elseif ( $ show_progress ) {
3231
3257
clear_show_test ();
3232
3258
}
3233
3259
}
3234
3260
3235
3261
function show_redirect_ends (string $ tests , string $ tested , string $ tested_file ): void
3236
3262
{
3237
- global $ SHOW_ONLY_GROUPS ;
3263
+ global $ SHOW_ONLY_GROUPS , $ show_progress ;
3238
3264
3239
3265
if (!$ SHOW_ONLY_GROUPS || in_array ('REDIRECT ' , $ SHOW_ONLY_GROUPS )) {
3240
3266
echo "REDIRECT $ tests ( $ tested [ $ tested_file]) done \n" ;
3241
- } else {
3267
+ } elseif ( $ show_progress ) {
3242
3268
clear_show_test ();
3243
3269
}
3244
3270
}
@@ -3280,7 +3306,7 @@ function show_result(
3280
3306
string $ extra = '' ,
3281
3307
?array $ temp_filenames = null
3282
3308
): void {
3283
- global $ SHOW_ONLY_GROUPS , $ colorize ;
3309
+ global $ SHOW_ONLY_GROUPS , $ colorize, $ show_progress ;
3284
3310
3285
3311
if (!$ SHOW_ONLY_GROUPS || in_array ($ result , $ SHOW_ONLY_GROUPS )) {
3286
3312
if ($ colorize ) {
@@ -3302,10 +3328,9 @@ function show_result(
3302
3328
} else {
3303
3329
echo "$ result $ tested [ $ tested_file] $ extra \n" ;
3304
3330
}
3305
- } elseif (! $ SHOW_ONLY_GROUPS ) {
3331
+ } elseif ($ show_progress ) {
3306
3332
clear_show_test ();
3307
3333
}
3308
-
3309
3334
}
3310
3335
3311
3336
class BorkageException extends Exception
0 commit comments