Skip to content

Commit

Permalink
tests: Guard against Flex presence (#162)
Browse files Browse the repository at this point in the history
If the Flex plugin is installed on the machine, running tests locally
will cause additional noise.
  • Loading branch information
theofidry authored Nov 5, 2024
1 parent bbe4925 commit b54a150
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 12 deletions.
3 changes: 2 additions & 1 deletion e2e/scenario0/vendor-bin/ns1/composer.json
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
{}
{
}
3 changes: 2 additions & 1 deletion e2e/scenario0/vendor-bin/ns2/composer.json
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
{}
{
}
3 changes: 2 additions & 1 deletion e2e/scenario1/vendor-bin/ns1/composer.json
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
{}
{
}
3 changes: 2 additions & 1 deletion e2e/scenario1/vendor-bin/ns2/composer.json
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
{}
{
}
3 changes: 2 additions & 1 deletion e2e/scenario11/vendor-bin/ns1/composer.json
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
{}
{
}
3 changes: 2 additions & 1 deletion e2e/scenario3/vendor-bin/ns1/composer.json
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
{}
{
}
3 changes: 2 additions & 1 deletion e2e/scenario8/vendor-bin/ns1/composer.json
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
{}
{
}
23 changes: 18 additions & 5 deletions tests/EndToEndTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ public function test_it_passes_the_e2e_test(string $scenarioPath): void

$actualPath = $scenarioPath.'/actual.txt';

if (file_exists($actualPath)) {
$originalContent = file_get_contents($scenarioPath.'/actual.txt');
} else {
$originalContent = 'File was not created.';
}
$originalContent = file_exists($actualPath)
? self::removeFlexMessages(
file_get_contents($scenarioPath . '/actual.txt')
)
: 'File was not created.';

$errorMessage = <<<TXT
Standard output:
Expand Down Expand Up @@ -187,4 +187,17 @@ private static function normalizeTrailingWhitespacesAndLineReturns(string $value
array_map('rtrim', explode(PHP_EOL, $value))
);
}

private static function removeFlexMessages(string $value): string
{
return preg_replace(
'/.+Symfony\\\\Flex.+\n/',
'',
str_replace(
"Symfony recipes are disabled: \"symfony/flex\" not found in the root composer.json\n\n",
'',
$value
)
);
}
}

0 comments on commit b54a150

Please sign in to comment.