Skip to content

Commit 9771e64

Browse files
committed
MQE-982: Verification Test around Suite Generation
- Added SingleRun Manifest Verification - Sanitized createGroupDir for multiple entry points
1 parent 35dd1fe commit 9771e64

File tree

3 files changed

+66
-5
lines changed

3 files changed

+66
-5
lines changed

dev/_suite/functionalSuite.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,15 @@
1818
<test name="ExcludeTest2"/>
1919
</exclude>
2020
</suite>
21+
<suite name="functionalSuite2">
22+
<include>
23+
<group name="include"/>
24+
<test name="IncludeTest"/>
25+
<module name="TestModule" file="SampleSuite2Test.xml"/>
26+
</include>
27+
<exclude>
28+
<group name="exclude"/>
29+
<test name="ExcludeTest2"/>
30+
</exclude>
31+
</suite>
2132
</suites>

dev/tests/verification/Tests/SuiteGenerationTest.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,54 @@ public function testSuiteGenerationHooks()
204204

205205
}
206206

207+
/**
208+
* Test generation of parallel suite groups
209+
*/
210+
public function testSuiteGenerationSingleRun()
211+
{
212+
//using functionalSuite2 to avoid directory caching
213+
$groupName = 'functionalSuite2';
214+
215+
$expectedContents = [
216+
'additionalTestCest.php',
217+
'additionalIncludeTest2Cest.php',
218+
'IncludeTest2Cest.php',
219+
'IncludeTestCest.php'
220+
];
221+
222+
//createParallelManifest
223+
/** @var ParallelTestManifest $parallelManifest */
224+
$singleRunManifest = TestManifestFactory::makeManifest("singleRun", ["functionalSuite2" => []]);
225+
226+
// Generate the Suite
227+
SuiteGenerator::getInstance()->generateAllSuites($singleRunManifest);
228+
$singleRunManifest->generate();
229+
230+
// Validate console message and add group name for later deletion
231+
$this->expectOutputRegex('/Suite .* generated to .*/');
232+
self::$TEST_GROUPS[] = $groupName;
233+
234+
// Validate Yaml file updated
235+
$yml = Yaml::parse(file_get_contents(self::CONFIG_YML_FILE));
236+
$this->assertArrayHasKey($groupName, $yml['groups']);
237+
238+
$suiteResultBaseDir = self::GENERATE_RESULT_DIR .
239+
DIRECTORY_SEPARATOR .
240+
$groupName .
241+
DIRECTORY_SEPARATOR;
242+
243+
// Validate tests have been generated
244+
$dirContents = array_diff(scandir($suiteResultBaseDir), ['..', '.']);
245+
246+
foreach ($expectedContents as $expectedFile) {
247+
$this->assertTrue(in_array($expectedFile, $dirContents));
248+
}
249+
250+
$expectedManifest = "dev/tests/verification/_generated/default/" . PHP_EOL . "-g functionalSuite2" . PHP_EOL;
251+
252+
$this->assertEquals($expectedManifest, file_get_contents(self::getManifestFilePath()));
253+
}
254+
207255
/**
208256
* revert any changes made to config.yml
209257
* remove _generated directory

src/Magento/FunctionalTestingFramework/Util/Filesystem/DirSetupUtil.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,19 @@ class DirSetupUtil
2626
*/
2727
public static function createGroupDir($fullPath)
2828
{
29+
//prevent redundant calls to these directories
30+
$sanitizedPath = rtrim($fullPath, DIRECTORY_SEPARATOR);
2931
// make sure we haven't already cleaned up this directory at any point before deletion
30-
if (in_array($fullPath, self::$DIR_CONTEXT)) {
32+
if (in_array($sanitizedPath, self::$DIR_CONTEXT)) {
3133
return;
3234
}
3335

34-
if (file_exists($fullPath)) {
35-
self::rmDirRecursive($fullPath);
36+
if (file_exists($sanitizedPath)) {
37+
self::rmDirRecursive($sanitizedPath);
3638
}
3739

38-
mkdir($fullPath, 0777, true);
39-
self::$DIR_CONTEXT[] = $fullPath;
40+
mkdir($sanitizedPath, 0777, true);
41+
self::$DIR_CONTEXT[] = $sanitizedPath;
4042
}
4143

4244
/**

0 commit comments

Comments
 (0)