Skip to content

Commit 4abcf65

Browse files
authored
Merge pull request #9 from magento-pangolin/MQE-2311
MQE-2311: Changed files list for MFTF SVC to only include MFTF files
2 parents b24a992 + 8936896 commit 4abcf65

File tree

4 files changed

+21
-7
lines changed

4 files changed

+21
-7
lines changed

src/Console/Command/CompareSourceCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ protected function execute(InputInterface $input, OutputInterface $cliOutput)
124124
$mftf
125125
);
126126
$fileChangeDetector = new FileChangeDetector($sourceBeforeDir, $sourceAfterDir);
127-
$semanticVersionChecker = new SemanticVersionChecker($reportBuilder, $fileChangeDetector);
127+
$semanticVersionChecker = new SemanticVersionChecker($reportBuilder, $fileChangeDetector, $mftf);
128128
$versionIncrease = $semanticVersionChecker->getVersionIncrease();
129129
$versionIncWord = strtoupper($this->changeLevels[$versionIncrease]);
130130
$versionReport = $semanticVersionChecker->loadVersionReport();

src/FileChangeDetector.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,10 @@ public function __construct($sourceBeforeDir, $sourceAfterDir, $changedFileFilte
4040
/**
4141
* Get the set of files that were added, removed, or changed between before and after source
4242
*
43+
* @param bool $mftf
4344
* @return string[]
4445
*/
45-
public function getChangedFiles()
46+
public function getChangedFiles($mftf = false)
4647
{
4748
$beforeDir = $this->sourceBeforeDir;
4849
$afterDir = $this->sourceAfterDir;
@@ -66,7 +67,14 @@ public function getChangedFiles()
6667
});
6768
}
6869
}
69-
return array_merge($afterFiles, $beforeFiles);
70+
$changedFiles = array_merge($afterFiles, $beforeFiles);
71+
$mftfFiles = array_filter($changedFiles, function ($var) {
72+
return (stripos($var, '/Test/Mftf/') !== false);
73+
});
74+
if ($mftf) {
75+
return $mftfFiles;
76+
}
77+
return array_diff($changedFiles, $mftfFiles);
7078
}
7179

7280
/**

src/Scanner/ModuleNamespaceResolver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function resolveByViewDirFilePath(string $filePath): string
4949
public function resolveByTestMftfPath(string $filePath): string
5050
{
5151
$matches = [];
52-
preg_match('/([\w-]*)\/([\w-]*)\/Test\/Mftf/', $filePath, $matches);
53-
return sprintf('%s_%s', $matches[1], $matches[2]);
52+
preg_match('/([\w-]*)\/Test\/Mftf/', $filePath, $matches);
53+
return sprintf('%s', $matches[1]);
5454
}
5555
}

src/SemanticVersionChecker.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,25 @@ class SemanticVersionChecker
3636
/** @var string[]|null */
3737
private $changedFiles;
3838

39+
/** @var boolean */
40+
private $mftf;
41+
3942
/**
4043
* Initialize dependencies.
4144
*
4245
* @param \Magento\SemanticVersionChecker\ReportBuilder $reportBuilder
4346
* @param FileChangeDetector $fileChangeDetector
47+
* @param boolean $mftf
4448
*/
4549
public function __construct(
4650
ReportBuilder $reportBuilder,
47-
FileChangeDetector $fileChangeDetector
51+
FileChangeDetector $fileChangeDetector,
52+
$mftf = false
4853
) {
4954
$this->reportBuilder = $reportBuilder;
5055
$this->fileChangeDetector = $fileChangeDetector;
5156
$this->changedFiles = null;
57+
$this->mftf = $mftf;
5258
}
5359

5460
/**
@@ -71,7 +77,7 @@ public function loadChangedFiles()
7177
{
7278
// Check null (unloaded) specifically as an empty array of changed files is valid
7379
if ($this->changedFiles === null) {
74-
$this->changedFiles = $this->fileChangeDetector->getChangedFiles();
80+
$this->changedFiles = $this->fileChangeDetector->getChangedFiles($this->mftf);
7581
}
7682
return $this->changedFiles;
7783
}

0 commit comments

Comments
 (0)