reorder for readability and comment
This commit is contained in:
parent
0ce38258dc
commit
ce7c917874
@ -5,6 +5,7 @@ use \JHodges\GiteaBot\Client;
|
||||
|
||||
/* creates a new issue for each failed test
|
||||
* if it already exists then report is added as a comment
|
||||
* if exact error exists as body or comment then just link to it instead of posting again
|
||||
* if it passes then the issue is closed
|
||||
*/
|
||||
|
||||
@ -26,6 +27,36 @@ final class PostFailedTests{
|
||||
$this->process($this->xml);
|
||||
}
|
||||
|
||||
private function process($item){
|
||||
if(isset($item->testcase)){
|
||||
foreach($item->testcase as $testcase) {
|
||||
$att=$testcase->attributes();
|
||||
$name=$testcase->attributes()->class[0].'::'.$testcase->attributes()->name[0];
|
||||
$fail=false;
|
||||
foreach($testcase as $k=>$v){
|
||||
$this->fail($name,$att,$k,$v);
|
||||
$fail=true;
|
||||
}
|
||||
if(!$fail){
|
||||
$this->success($name,$att);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(isset($item->testsuite)){
|
||||
foreach($item->testsuite as $testsuite) {
|
||||
$this->process($testsuite);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function success($name,$att){
|
||||
$issue=$this->repo->getIssues(['q' => $name])[0]??null;
|
||||
|
||||
if($issue){
|
||||
$issue->state='closed';
|
||||
$issue->save();
|
||||
}
|
||||
}
|
||||
|
||||
private function fail($name,$att,$error,$message){
|
||||
//stick the error type into the atts array
|
||||
@ -73,7 +104,6 @@ final class PostFailedTests{
|
||||
'body'=>$issueBody
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function doesMessageMatch($body,$message,$att){
|
||||
@ -104,35 +134,4 @@ final class PostFailedTests{
|
||||
return true;
|
||||
}
|
||||
|
||||
private function success($name,$att){
|
||||
$issue=$this->repo->getIssues(['q' => $name])[0]??null;
|
||||
|
||||
if($issue){
|
||||
$issue->state='closed';
|
||||
$issue->save();
|
||||
}
|
||||
}
|
||||
|
||||
private function process($item){
|
||||
if(isset($item->testcase)){
|
||||
foreach($item->testcase as $testcase) {
|
||||
$att=$testcase->attributes();
|
||||
$name=$testcase->attributes()->class[0].'::'.$testcase->attributes()->name[0];
|
||||
$fail=false;
|
||||
foreach($testcase as $k=>$v){
|
||||
$this->fail($name,$att,$k,$v);
|
||||
$fail=true;
|
||||
}
|
||||
if(!$fail){
|
||||
$this->success($name,$att);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(isset($item->testsuite)){
|
||||
foreach($item->testsuite as $testsuite) {
|
||||
$this->process($testsuite);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user