-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrunTest.php
executable file
·60 lines (57 loc) · 1.26 KB
/
runTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env php
<?php
//
//coverage -text maker start
//
$coverageOutput = tempnam(".","coverage");
unlink($coverageOutput);
$coverageOutput .= ".txt";
ob_start();
system("./test/bin/phpunit --verbose --coverage-text=$coverageOutput test/Yamaki",$returnCode);
$output = ob_get_clean();
if(0 !== $returnCode){
unlink($coverageOutput);
die($output);
}
if(!is_file($coverageOutput)){
die(__FILE__.":".__LINE__);
}
//
//coverage -text maker end
//
$summary = array();
//
//coverage-text parser start
//
$inSummary = false;
$fd = fopen($coverageOutput,'r');
while(!feof($fd)){
$line = fgets($fd);
if(preg_match("/^Yamaki/",$line)){
$inSummary = false;
}
if($inSummary && preg_match("/[0-9a-zA-Z]/",$line)){
$keyValue = array();
foreach(explode(" ",$line) as $value){
if(preg_match("/[0-9a-zA-Z]/",$value)){
$keyValue[] = $value;
}
}
$summary[$keyValue[0]] = $keyValue[1];
}
if(preg_match("/Summary:/",$line)){
$inSummary = true;
}
}
fclose($fd);
unlink($coverageOutput);
//
//coverage-text parser start
//
foreach($summary as $key => $percent){
if("100.00%" !== $percent){
print_r($summary);
die($key." is not 100.00%!!");
}
}
exit;