Skip to content

Commit

Permalink
Fix tests:check-direct-dependency-use command not working with plug…
Browse files Browse the repository at this point in the history
…ins via Github action (matomo-org#22012)
  • Loading branch information
AltamashShaikh authored Mar 11, 2024
1 parent 5f6b344 commit 894d952
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions plugins/TestRunner/Commands/CheckDirectDependencyUse.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ private function grepForUses($prefix, $psrType, $plugin, $isGrepVendorFolder)
$rgOutput = [];

if ($plugin) {
$plugin = '/' . $plugin;
$plugin = '/plugins/' . $plugin;
}

$vendorScan = '--glob=\\!vendor';
Expand All @@ -98,7 +98,7 @@ private function grepForUses($prefix, $psrType, $plugin, $isGrepVendorFolder)
$regex = '\\b' . preg_quote($prefix) . '_';
}

$command = 'rg \'' . $regex . '\' --glob=*.php ' . $vendorScan . ' --json --sort path ' . PIWIK_INCLUDE_PATH . '/plugins' . $plugin;
$command = 'rg \'' . $regex . '\' --glob=*.php ' . $vendorScan . ' --json --sort path ' . PIWIK_INCLUDE_PATH . $plugin;
exec($command, $rgOutput, $returnCode);

if (isset($returnCode) && $returnCode == 127) {
Expand All @@ -119,7 +119,7 @@ private function grepForUses($prefix, $psrType, $plugin, $isGrepVendorFolder)
array_shift($parts);
$pluginName = array_shift($parts);

if (file_exists(PIWIK_INCLUDE_PATH . '/plugins/' . $pluginName . '/.git')) {
if ($pluginName) {
$remainingPath = implode('/', $parts);
$uses[$pluginName][] = $remainingPath;
}
Expand All @@ -138,7 +138,7 @@ private function reportDirectUses($prefix, $directUses, $type)
$output->writeln("<info>Found '$prefix' ($type) usage in:</info>");
foreach ($directUses as $plugin => $files) {
foreach ($files as $file) {
$this->usesFoundList[$plugin][$prefix][] = $plugin . '/' . $file;
$this->usesFoundList[rtrim($plugin, '\\')][rtrim($prefix, '\\')][] = $plugin . '/' . $file;
}
$output->writeln(" - $plugin, " . count($files) . " files");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public function testCommand($pluginName, $expectedResult)
public function getTestDataForDependencyCheck()
{
return [
['TestRunner', []],
['Provider', ['Matomo\Network\\' => ['Provider/Columns/Provider.php']]],
['TestRunner', ['Symfony\Component\Console' => ['TestRunner/tests/System/CheckDirectDependencyUseCommandTest.php']]],
['Provider', ['Matomo\Network' => ['Provider/Columns/Provider.php']]],
];
}
}

0 comments on commit 894d952

Please sign in to comment.