Skip to content

Commit d305b4c

Browse files
committed
MQE-1606: Mftf static check script should return error exit code when check fails
1 parent 0232087 commit d305b4c

File tree

3 files changed

+36
-5
lines changed

3 files changed

+36
-5
lines changed

src/Magento/FunctionalTestingFramework/Console/StaticChecksCommand.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,20 @@ protected function configure()
4747
protected function execute(InputInterface $input, OutputInterface $output)
4848
{
4949
$staticCheckObjects = $this->staticChecksList->getStaticChecks();
50+
51+
$errors = [];
52+
5053
foreach ($staticCheckObjects as $staticCheck) {
5154
$staticOutput = $staticCheck->execute($input);
5255
LoggingUtil::getInstance()->getLogger(get_class($staticCheck))->info($staticOutput);
5356
$output->writeln($staticOutput);
57+
$errors += $staticCheck->getErrors();
58+
}
59+
60+
if (empty($errors)) {
61+
return 0;
62+
} else {
63+
return 1;
5464
}
5565
}
5666
}

src/Magento/FunctionalTestingFramework/StaticCheck/StaticCheckInterface.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,10 @@ interface StaticCheckInterface
1919
* @return string
2020
*/
2121
public function execute(InputInterface $input);
22+
23+
/**
24+
* Return array containing all errors found after running the execute() function.
25+
* @return array
26+
*/
27+
public function getErrors();
2228
}

src/Magento/FunctionalTestingFramework/StaticCheck/TestDependencyCheck.php

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ class TestDependencyCheck implements StaticCheckInterface
6262
*/
6363
private $alreadyExtractedDependencies;
6464

65+
/**
66+
* Array containing all errors found after running the execute() function.
67+
* @var array
68+
*/
69+
private $errors;
70+
6571
/**
6672
* Checks test dependencies, determined by references in tests versus the dependencies listed in the Magento module
6773
*
@@ -98,13 +104,22 @@ public function execute(InputInterface $input)
98104
$actionGroupXmlFiles = $this->buildFileList($allModules, $filePaths[1]);
99105
$dataXmlFiles= $this->buildFileList($allModules, $filePaths[2]);
100106

101-
$testErrors = [];
102-
$testErrors += $this->findErrorsInFileSet($testXmlFiles);
103-
$testErrors += $this->findErrorsInFileSet($actionGroupXmlFiles);
104-
$testErrors += $this->findErrorsInFileSet($dataXmlFiles);
107+
$this->errors = [];
108+
$this->errors += $this->findErrorsInFileSet($testXmlFiles);
109+
$this->errors += $this->findErrorsInFileSet($actionGroupXmlFiles);
110+
$this->errors += $this->findErrorsInFileSet($dataXmlFiles);
105111

106112
//print all errors to file
107-
return $this->printErrorsToFile($testErrors);
113+
return $this->printErrorsToFile($this->getErrors());
114+
}
115+
116+
/**
117+
* Return array containing all errors found after running the execute() function.
118+
* @return array
119+
*/
120+
public function getErrors()
121+
{
122+
return $this->errors;
108123
}
109124

110125
/**

0 commit comments

Comments
 (0)