Skip to content

Commit 7543050

Browse files
committed
MQE-1260: Create RERUN_COUNT field in Jenkins MFTF Parameters section same as MTF parameters section
- Protecting on missing testname and filepath
1 parent 82ed2ba commit 7543050

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

src/Magento/FunctionalTestingFramework/Console/RunTestFailedCommand.php

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -126,18 +126,20 @@ private function getFailedTestList()
126126
$testList = $this->readFailedTestFile(self::TESTS_FAILED_FILE);
127127

128128
foreach ($testList as $test) {
129-
$this->writeFailedTestToFile($test, self::TESTS_RERUN_FILE);
130-
$testInfo = explode(DIRECTORY_SEPARATOR, $test);
131-
$testName = explode(":", $testInfo[count($testInfo) - 1])[1];
132-
$suiteName = $testInfo[count($testInfo) - 2];
133-
134-
if ($suiteName == self::DEFAULT_TEST_GROUP) {
135-
array_push($failedTestDetails['tests'], $testName);
136-
} else {
137-
$failedTestDetails['suites'] = array_merge_recursive(
138-
$failedTestDetails['suites'],
139-
[$suiteName => [$testName]]
140-
);
129+
if (!empty($test)) {
130+
$this->writeFailedTestToFile($test, self::TESTS_RERUN_FILE);
131+
$testInfo = explode(DIRECTORY_SEPARATOR, $test);
132+
$testName = explode(":", $testInfo[count($testInfo) - 1])[1];
133+
$suiteName = $testInfo[count($testInfo) - 2];
134+
135+
if ($suiteName == self::DEFAULT_TEST_GROUP) {
136+
array_push($failedTestDetails['tests'], $testName);
137+
} else {
138+
$failedTestDetails['suites'] = array_merge_recursive(
139+
$failedTestDetails['suites'],
140+
[$suiteName => [$testName]]
141+
);
142+
}
141143
}
142144
}
143145
}
@@ -183,7 +185,7 @@ private function readFailedTestFile($filePath)
183185
*/
184186
private function writeFailedTestToFile($test, $filePath)
185187
{
186-
if (realpath($filePath)) {
188+
if (file_exists($filePath)) {
187189
if (strpos(file_get_contents($filePath), $test) === false) {
188190
file_put_contents($filePath, "\n" . $test, FILE_APPEND);
189191
}

0 commit comments

Comments
 (0)