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 10
10
exit (1 );
11
11
}
12
12
13
+ $ onlyEchoPercentage = false ;
14
+
15
+ if (isset ($ argv [3 ]) && $ argv [3 ] === 'only-percentage ' ) {
16
+ $ onlyEchoPercentage = true ;
17
+ }
18
+
13
19
$ inputFile = $ argv [1 ];
14
20
$ percentage = min (100 , max (0 , (float )$ argv [2 ]));
15
21
35
41
// See calculation: https://confluence.atlassian.com/pages/viewpage.action?pageId=79986990
36
42
$ TPC = ($ coveredstatements + $ coveredmethods + $ coveredElements ) / ($ statements + $ methods + $ elements ) * 100 ;
37
43
38
- if ($ TPC < $ percentage ) {
44
+ if ($ TPC < $ percentage && ! $ onlyEchoPercentage ) {
39
45
echo 'Total code coverage is ' . sprintf ('%0.2f ' , $ TPC ) . '%, which is below the accepted ' . $ percentage . '% ' . PHP_EOL ;
40
46
exit (1 );
41
47
}
42
48
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
+
43
59
echo 'Total code coverage is ' . sprintf ('%0.2f ' , $ TPC ) . '% - OK! ' . PHP_EOL ;
You can’t perform that action at this time.
0 commit comments