File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change 1010 exit (1 );
1111}
1212
13+ $ onlyEchoPercentage = false ;
14+
15+ if (isset ($ argv [3 ]) && $ argv [3 ] === 'only-percentage ' ) {
16+ $ onlyEchoPercentage = true ;
17+ }
18+
1319$ inputFile = $ argv [1 ];
1420$ percentage = min (100 , max (0 , (float )$ argv [2 ]));
1521
3541// See calculation: https://confluence.atlassian.com/pages/viewpage.action?pageId=79986990
3642$ TPC = ($ coveredstatements + $ coveredmethods + $ coveredElements ) / ($ statements + $ methods + $ elements ) * 100 ;
3743
38- if ($ TPC < $ percentage ) {
44+ if ($ TPC < $ percentage && ! $ onlyEchoPercentage ) {
3945 echo 'Total code coverage is ' . sprintf ('%0.2f ' , $ TPC ) . '%, which is below the accepted ' . $ percentage . '% ' . PHP_EOL ;
4046 exit (1 );
4147}
4248
49+ if ($ TPC < $ percentage && $ onlyEchoPercentage ) {
50+ echo sprintf ('%0.2f ' , $ TPC ) . PHP_EOL ;
51+ exit (1 );
52+ }
53+
54+ if ($ onlyEchoPercentage ) {
55+ echo sprintf ('%0.2f ' , $ TPC ) . PHP_EOL ;
56+ exit (0 );
57+ }
58+
4359echo 'Total code coverage is ' . sprintf ('%0.2f ' , $ TPC ) . '% - OK! ' . PHP_EOL ;
You can’t perform that action at this time.
0 commit comments