@@ -36,6 +36,11 @@ class RunTestFailedCommand extends BaseGenerateCommand
36
36
DIRECTORY_SEPARATOR .
37
37
"testManifest.txt " ;
38
38
39
+ /**
40
+ * @var array
41
+ */
42
+ private $ failedList = [];
43
+
39
44
/**
40
45
* Configures the current command.
41
46
*
@@ -83,8 +88,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
83
88
84
89
$ testManifestList = $ this ->readTestManifestFile ();
85
90
86
- foreach ($ testManifestList as $ testCommand )
87
- {
91
+ foreach ($ testManifestList as $ testCommand ) {
88
92
$ codeceptionCommand = realpath (PROJECT_ROOT . '/vendor/bin/codecept ' ) . ' run functional ' ;
89
93
$ codeceptionCommand .= $ testCommand ;
90
94
@@ -97,6 +101,13 @@ function ($type, $buffer) use ($output) {
97
101
$ output ->write ($ buffer );
98
102
}
99
103
);
104
+ $ this ->failedList = array_merge (
105
+ $ this ->failedList ,
106
+ $ this ->readFailedTestFile (self ::TESTS_FAILED_FILE )
107
+ );
108
+ }
109
+ foreach ($ this ->failedList as $ test ) {
110
+ $ this ->writeFailedTestToFile ($ test , self ::TESTS_FAILED_FILE );
100
111
}
101
112
}
102
113
@@ -107,21 +118,13 @@ function ($type, $buffer) use ($output) {
107
118
*/
108
119
private function getFailedTestList ()
109
120
{
110
- $ failedTestPath = TESTS_BP .
111
- DIRECTORY_SEPARATOR .
112
- "tests " .
113
- DIRECTORY_SEPARATOR .
114
- "_output " .
115
- DIRECTORY_SEPARATOR .
116
- "failed " ;
117
-
118
121
$ failedTestDetails = ['tests ' => [], 'suites ' => []];
119
122
120
- if (realpath ($ failedTestPath )) {
121
- $ testList = $ this ->readFailedTestFile ($ failedTestPath );
123
+ if (realpath (self :: TESTS_FAILED_FILE )) {
124
+ $ testList = $ this ->readFailedTestFile (self :: TESTS_FAILED_FILE );
122
125
123
126
foreach ($ testList as $ test ) {
124
- $ this ->writeFailedTestToFile ($ test );
127
+ $ this ->writeFailedTestToFile ($ test, self :: TESTS_RERUN_FILE );
125
128
$ testInfo = explode (DIRECTORY_SEPARATOR , $ test );
126
129
$ testName = explode (": " , $ testInfo [count ($ testInfo ) - 1 ])[1 ];
127
130
$ suiteName = $ testInfo [count ($ testInfo ) - 2 ];
@@ -150,9 +153,8 @@ private function getFailedTestList()
150
153
}
151
154
152
155
/**
153
- * Returns an array of tests read from the failed test file in _output
156
+ * Returns an array of run commands read from the manifest file created post generation
154
157
*
155
- * @param string $filePath
156
158
* @return array|boolean
157
159
*/
158
160
private function readTestManifestFile ()
@@ -177,14 +179,14 @@ private function readFailedTestFile($filePath)
177
179
* @param string $test
178
180
* @return void
179
181
*/
180
- private function writeFailedTestToFile ($ test )
182
+ private function writeFailedTestToFile ($ test, $ filePath )
181
183
{
182
- if (realpath (self :: TESTS_RERUN_FILE )) {
183
- if (strpos (file_get_contents (self :: TESTS_RERUN_FILE ), $ test ) == false ) {
184
- file_put_contents (self :: TESTS_RERUN_FILE , $ test . "\n" , FILE_APPEND );
184
+ if (realpath ($ filePath )) {
185
+ if (strpos (file_get_contents ($ filePath ), $ test ) = == false ) {
186
+ file_put_contents ($ filePath , "\n" . $ test , FILE_APPEND );
185
187
}
186
188
} else {
187
- file_put_contents (self :: TESTS_RERUN_FILE , $ test . "\n" );
189
+ file_put_contents ($ filePath , $ test . "\n" );
188
190
}
189
191
}
190
192
}
0 commit comments