Skip to content

Commit

Permalink
GroupManager: Show which group contains missing file
Browse files Browse the repository at this point in the history
Closes #5938
  • Loading branch information
Naktibalda committed Jan 2, 2021
1 parent bf2d786 commit 0e110ef
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/Codeception/Lib/GroupManager.php
Expand Up @@ -64,7 +64,7 @@ protected function loadConfiguredGroupSettings()
if (is_array($tests)) {
foreach ($tests as $test) {
$file = str_replace(['/', '\\'], [DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR], $test);
$this->testsInGroups[$group][] = $this->normalizeFilePath($file);
$this->testsInGroups[$group][] = $this->normalizeFilePath($file, $group);
}
} elseif (is_file(Configuration::projectDir() . $tests)) {
$handle = @fopen(Configuration::projectDir() . $tests, "r");
Expand All @@ -78,7 +78,7 @@ protected function loadConfiguredGroupSettings()
}

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

/**
* @param string $file
* @param string $group
* @return false|string
* @throws ConfigurationException
*/
private function normalizeFilePath($file)
private function normalizeFilePath($file, $group)
{
$pathParts = explode(':', $file);
if (codecept_is_path_absolute($file)) {
if ($file[0] === '/' && count($pathParts) > 1) {
//take segment before first :
$this->checkIfFileExists($pathParts[0]);
$this->checkIfFileExists($pathParts[0], $group);
return sprintf('%s:%s', realpath($pathParts[0]), $pathParts[1]);
} else if (count($pathParts) > 2) {
//on Windows take segment before second :
$fullPath = $pathParts[0] . ':' . $pathParts[1];
$this->checkIfFileExists($fullPath);
$this->checkIfFileExists($fullPath, $group);
return sprintf('%s:%s', realpath($fullPath), $pathParts[2]);
}

$this->checkIfFileExists($file);
return realpath($file);
} elseif (strpos($file, ':') === false) {
$dirtyPath = Configuration::projectDir() . $file;
$this->checkIfFileExists($dirtyPath);
$this->checkIfFileExists($dirtyPath, $group);
return realpath($dirtyPath);
}

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

/**
* @param string $path
* @param string $group
* @throws ConfigurationException
*/
private function checkIfFileExists($path)
private function checkIfFileExists($path, $group)
{
if (!file_exists($path)) {
throw new ConfigurationException('GroupManager: File or directory ' . $path . ' does not exist');
throw new ConfigurationException('GroupManager: File or directory ' . $path . ' set in ' . $group. ' group does not exist');
}
}

Expand Down

0 comments on commit 0e110ef

Please sign in to comment.