Skip to content

[MakefileConfigurator] Fix indentation of help target#1080

Open
Kocal wants to merge 1 commit intosymfony:2.xfrom
Kocal:fix-makefile-boilerplate
Open

[MakefileConfigurator] Fix indentation of help target#1080
Kocal wants to merge 1 commit intosymfony:2.xfrom
Kocal:fix-makefile-boilerplate

Conversation

@Kocal
Copy link
Copy Markdown
Member

@Kocal Kocal commented Feb 6, 2026

When working on symfony/recipes-contrib#1936, that contains a Makefile, I noticed that the Makefile boilerplate generated in 2.x (1.x not affected) contains 4 spaces instead of a tabulation in the task help.

With the spaces:
image

With the tabulation:
image

Note: I didn't tested the fix, I'm assuming it works 🤞🏻

@GromNaN
Copy link
Copy Markdown
Member

GromNaN commented Apr 2, 2026

The fix looks good! However, it's missing a test — none of the existing tests exercise the boilerplate creation path (they all touch the Makefile before calling configure()).

Here's a test to add to tests/Configurator/MakefileConfiguratorTest.php that would have caught the regression:

public function testConfigureCreatesBoilerplateWithTabIndentation()
{
    $configurator = new MakefileConfigurator(
        $this->getMockBuilder(Composer::class)->getMock(),
        $this->getMockBuilder(IOInterface::class)->getMock(),
        new Options(['root-dir' => FLEX_TEST_DIR])
    );
    $lock = $this->getMockBuilder(Lock::class)->disableOriginalConstructor()->getMock();

    $recipe = $this->getMockBuilder(Recipe::class)->disableOriginalConstructor()->getMock();
    $recipe->expects($this->any())->method('getName')->willReturn('FooBundle');

    $makefile = FLEX_TEST_DIR.'/Makefile';
    @unlink($makefile);

    $configurator->configure($recipe, ['foo: ## Do foo'], $lock);

    $this->assertFileExists($makefile);
    $contents = file_get_contents($makefile);
    $this->assertStringContainsString("ifndef APP_ENV\n    include .env\nendif", $contents);
    $this->assertStringContainsString('.DEFAULT_GOAL := help', $contents);
    $this->assertStringContainsString('.PHONY: help', $contents);
    $this->assertStringContainsString("help:\n\t@awk", $contents, 'The help target must use a tab for indentation, not spaces');
}

@Kocal Kocal force-pushed the fix-makefile-boilerplate branch from c3e7020 to 133a9c3 Compare April 3, 2026 05:09
@Kocal
Copy link
Copy Markdown
Member Author

Kocal commented Apr 3, 2026

Thank you @GromNaN ❤️

@Kocal
Copy link
Copy Markdown
Member Author

Kocal commented Apr 3, 2026

Failing checks will be fixed by #1084

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants