Skip to content

Commit 3816415

Browse files
authored
Merge pull request Codeception#6069 from Codeception/4.1-issue-5938
GroupManager: Show which group contains missing file
2 parents 00e8f50 + 0e110ef commit 3816415

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/Codeception/Lib/GroupManager.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ protected function loadConfiguredGroupSettings()
6464
if (is_array($tests)) {
6565
foreach ($tests as $test) {
6666
$file = str_replace(['/', '\\'], [DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR], $test);
67-
$this->testsInGroups[$group][] = $this->normalizeFilePath($file);
67+
$this->testsInGroups[$group][] = $this->normalizeFilePath($file, $group);
6868
}
6969
} elseif (is_file(Configuration::projectDir() . $tests)) {
7070
$handle = @fopen(Configuration::projectDir() . $tests, "r");
@@ -78,7 +78,7 @@ protected function loadConfiguredGroupSettings()
7878
}
7979

8080
$file = str_replace(['/', '\\'], [DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR], trim($test));
81-
$this->testsInGroups[$group][] = $this->normalizeFilePath($file);
81+
$this->testsInGroups[$group][] = $this->normalizeFilePath($file, $group);
8282
}
8383
fclose($handle);
8484
}
@@ -88,45 +88,47 @@ protected function loadConfiguredGroupSettings()
8888

8989
/**
9090
* @param string $file
91+
* @param string $group
9192
* @return false|string
9293
* @throws ConfigurationException
9394
*/
94-
private function normalizeFilePath($file)
95+
private function normalizeFilePath($file, $group)
9596
{
9697
$pathParts = explode(':', $file);
9798
if (codecept_is_path_absolute($file)) {
9899
if ($file[0] === '/' && count($pathParts) > 1) {
99100
//take segment before first :
100-
$this->checkIfFileExists($pathParts[0]);
101+
$this->checkIfFileExists($pathParts[0], $group);
101102
return sprintf('%s:%s', realpath($pathParts[0]), $pathParts[1]);
102103
} else if (count($pathParts) > 2) {
103104
//on Windows take segment before second :
104105
$fullPath = $pathParts[0] . ':' . $pathParts[1];
105-
$this->checkIfFileExists($fullPath);
106+
$this->checkIfFileExists($fullPath, $group);
106107
return sprintf('%s:%s', realpath($fullPath), $pathParts[2]);
107108
}
108109

109110
$this->checkIfFileExists($file);
110111
return realpath($file);
111112
} elseif (strpos($file, ':') === false) {
112113
$dirtyPath = Configuration::projectDir() . $file;
113-
$this->checkIfFileExists($dirtyPath);
114+
$this->checkIfFileExists($dirtyPath, $group);
114115
return realpath($dirtyPath);
115116
}
116117

117118
$dirtyPath = Configuration::projectDir() . $pathParts[0];
118-
$this->checkIfFileExists($dirtyPath);
119+
$this->checkIfFileExists($dirtyPath, $group);
119120
return sprintf('%s:%s', realpath($dirtyPath), $pathParts[1]);
120121
}
121122

122123
/**
123124
* @param string $path
125+
* @param string $group
124126
* @throws ConfigurationException
125127
*/
126-
private function checkIfFileExists($path)
128+
private function checkIfFileExists($path, $group)
127129
{
128130
if (!file_exists($path)) {
129-
throw new ConfigurationException('GroupManager: File or directory ' . $path . ' does not exist');
131+
throw new ConfigurationException('GroupManager: File or directory ' . $path . ' set in ' . $group. ' group does not exist');
130132
}
131133
}
132134

0 commit comments

Comments
 (0)