@@ -23,11 +23,6 @@ class GenerateTestFailedCommand extends BaseGenerateCommand
23
23
*/
24
24
const DEFAULT_TEST_GROUP = 'default ' ;
25
25
26
- /**
27
- * @var string
28
- */
29
- private $ testsReRunFile ;
30
-
31
26
/**
32
27
* Configures the current command.
33
28
*
@@ -54,9 +49,6 @@ protected function configure()
54
49
*/
55
50
protected function execute (InputInterface $ input , OutputInterface $ output ): int
56
51
{
57
- $ this ->testsFailedFile = $ this ->getTestsOutputDir () . self ::FAILED_FILE ;
58
- $ this ->testsReRunFile = $ this ->getTestsOutputDir () . "rerun_tests " ;
59
-
60
52
$ force = $ input ->getOption ('force ' );
61
53
$ debug = $ input ->getOption ('debug ' ) ?? MftfApplicationConfig::LEVEL_DEVELOPER ; // for backward compatibility
62
54
$ allowSkipped = $ input ->getOption ('allow-skipped ' );
@@ -71,7 +63,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int
71
63
$ allowSkipped
72
64
);
73
65
74
- $ testConfiguration = $ this ->getFailedTestList ();
66
+ $ testsFailedFile = $ this ->getTestsOutputDir () . self ::FAILED_FILE ;
67
+ $ testsReRunFile = $ this ->getTestsOutputDir () . "rerun_tests " ;
68
+ $ testConfiguration = $ this ->getFailedTestList ($ testsFailedFile , $ testsReRunFile );
75
69
76
70
if ($ testConfiguration === null ) {
77
71
// No failed tests found, no tests generated
@@ -98,16 +92,16 @@ protected function execute(InputInterface $input, OutputInterface $output): int
98
92
*
99
93
* @return string
100
94
*/
101
- private function getFailedTestList ()
95
+ public function getFailedTestList ($ testsFailedFile , $ testsReRunFile )
102
96
{
103
97
$ failedTestDetails = ['tests ' => [], 'suites ' => []];
104
98
105
- if (realpath ($ this ->testsFailedFile )) {
106
- $ testList = $ this ->readFailedTestFile ($ this ->testsFailedFile );
99
+ $ testList = $ this ->readFailedTestFile ($ testsFailedFile );
107
100
101
+ if (!empty ($ testList )) {
108
102
foreach ($ testList as $ test ) {
109
103
if (!empty ($ test )) {
110
- $ this ->writeFailedTestToFile ($ test , $ this -> testsReRunFile );
104
+ $ this ->writeFailedTestToFile ($ test , $ testsReRunFile );
111
105
$ testInfo = explode (DIRECTORY_SEPARATOR , $ test );
112
106
$ testName = explode (": " , $ testInfo [count ($ testInfo ) - 1 ])[1 ];
113
107
$ suiteName = $ testInfo [count ($ testInfo ) - 2 ];
@@ -160,9 +154,12 @@ private function sanitizeSuiteName($suiteName)
160
154
* @param string $filePath
161
155
* @return array|boolean
162
156
*/
163
- private function readFailedTestFile ($ filePath )
157
+ public function readFailedTestFile ($ filePath )
164
158
{
165
- return file ($ filePath , FILE_IGNORE_NEW_LINES );
159
+ if (realpath ($ filePath )) {
160
+ return file ($ filePath , FILE_IGNORE_NEW_LINES );
161
+ }
162
+ return "" ;
166
163
}
167
164
168
165
/**
@@ -172,7 +169,7 @@ private function readFailedTestFile($filePath)
172
169
* @param string $filePath
173
170
* @return void
174
171
*/
175
- private function writeFailedTestToFile ($ test , $ filePath )
172
+ public function writeFailedTestToFile ($ test , $ filePath )
176
173
{
177
174
if (file_exists ($ filePath )) {
178
175
if (strpos (file_get_contents ($ filePath ), $ test ) === false ) {
0 commit comments