Skip to content

Commit 620c3b4

Browse files
d4mationclaude
andcommitted
ENG-222: Fix .distinclude bug and strengthen tests
The .pup-include filename was incorrect — it should be .pup-distinclude to match the file generated by DistInclude::writePup(). This meant .distinclude was silently ignored during packaging. Tests now use bootstrap.php/other-file.php instead of .puprc (which is always in default ignores) and use find to verify actual zip contents rather than ls -a which only showed directory-level entries. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 37f7c41 commit 620c3b4

6 files changed

Lines changed: 23 additions & 17 deletions

src/Commands/Package.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ public function getDistfilesLines( string $source ): array {
287287
*/
288288
public function getDistincludeLines( string $source ): array {
289289
$include = [];
290-
$include_file = '.pup-include';
290+
$include_file = '.pup-distinclude';
291291

292292
if ( ! file_exists( $source . $include_file ) ) {
293293
return [];

tests/cli/Commands/PackageCest.php

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -162,21 +162,27 @@ public function it_should_package_the_zip_and_ignore_files_from_distignore_and_g
162162
/**
163163
* @test
164164
*/
165-
public function it_should_package_the_zip_and_include_files_in_distinclude( CliTester $I ) {
165+
public function it_should_use_distinclude_as_a_filter_for_candidate_files( CliTester $I ) {
166166
$this->reset_data_and_location();
167167
$this->write_default_puprc();
168168

169169
chdir( $this->tests_root . '/_data/fake-project' );
170170

171-
file_put_contents( '.distinclude', ".puprc\n" );
171+
// .distinclude with bootstrap.php means only bootstrap.php is a candidate.
172+
file_put_contents( '.distinclude', "bootstrap.php\n" );
172173

173174
$I->runShellCommand( "php {$this->pup} package 1.0.0" );
174175

175176
system( 'unzip -d .pup-zip/ fake-project.1.0.0.zip' );
176177

177-
$I->runShellCommand( "ls -a .pup-zip" );
178-
178+
$I->runShellCommand( "find .pup-zip/fake-project -type f | sort" );
179179
$output = $I->grabShellOutput();
180+
181+
// bootstrap.php passes the include filter
182+
$I->assertStringContainsString( 'bootstrap.php', $output );
183+
// other-file.php is excluded because it doesn't match .distinclude
184+
$I->assertStringNotContainsString( 'other-file.php', $output );
185+
180186
$this->assertMatchesStringSnapshot( $output );
181187

182188
$I->runShellCommand( "php {$this->pup} clean" );
@@ -186,23 +192,27 @@ public function it_should_package_the_zip_and_include_files_in_distinclude( CliT
186192
/**
187193
* @test
188194
*/
189-
public function it_should_package_the_zip_and_include_files_in_distinclude_even_if_in_distignore_and_gitattributes( CliTester $I ) {
195+
public function it_should_not_let_distinclude_override_distignore_and_gitattributes( CliTester $I ) {
190196
$this->reset_data_and_location();
191197
$this->write_default_puprc();
192198

193199
chdir( $this->tests_root . '/_data/fake-project' );
194200

195-
file_put_contents( '.distinclude', ".puprc\n" );
196-
file_put_contents( '.distignore', ".puprc\n" );
197-
file_put_contents( '.gitattributes', ".puprc export-ignore\n" );
201+
// .distinclude allows bootstrap.php, but .distignore and .gitattributes exclude it.
202+
file_put_contents( '.distinclude', "bootstrap.php\n" );
203+
file_put_contents( '.distignore', "bootstrap.php\n" );
204+
file_put_contents( '.gitattributes', "bootstrap.php export-ignore\n" );
198205

199206
$I->runShellCommand( "php {$this->pup} package 1.0.0" );
200207

201208
system( 'unzip -d .pup-zip/ fake-project.1.0.0.zip' );
202209

203-
$I->runShellCommand( "ls -a .pup-zip" );
204-
210+
$I->runShellCommand( "find .pup-zip/fake-project | sort" );
205211
$output = $I->grabShellOutput();
212+
213+
// bootstrap.php should NOT be present — ignore rules still apply despite .distinclude
214+
$I->assertStringNotContainsString( 'bootstrap.php', $output );
215+
206216
$this->assertMatchesStringSnapshot( $output );
207217

208218
$I->runShellCommand( "php {$this->pup} clean" );
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.pup-zip/fake-project

tests/cli/Commands/__snapshots__/PackageCest__it_should_package_the_zip_and_include_files_in_distinclude__0.snapshot.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

tests/cli/Commands/__snapshots__/PackageCest__it_should_package_the_zip_and_include_files_in_distinclude_even_if_in_distignore_and_gitattributes__0.snapshot.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.pup-zip/fake-project/bootstrap.php

0 commit comments

Comments
 (0)