From 73210da3d01d7ed7616b28a940cd6ce01885d8c1 Mon Sep 17 00:00:00 2001 From: Rod Vince Date: Wed, 7 Oct 2026 19:26:27 -0600 Subject: [PATCH] fix: what Composer installs carries no tests, nor a machine's name with them The version of this package that Composer installs today still carries its tests, and in them a machine's name of the place they were written in. Both are already put right on main: the tests are marked out of the archive, and the tests name a made-up operator. But those two commits are a chore and a test, and neither cuts a release, so nothing published has changed. This is the commit that publishes it. It adds the one thing that was missing: a test that holds the line of .gitattributes, and that builds the archive of the commit and finds no test in it. Without that line the tests travel again, and nothing in the package said so. The release this cuts is the first whose archive carries neither. --- tests/TheArchiveCarriesNoTestsTest.php | 56 ++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 tests/TheArchiveCarriesNoTestsTest.php diff --git a/tests/TheArchiveCarriesNoTestsTest.php b/tests/TheArchiveCarriesNoTestsTest.php new file mode 100644 index 0000000..f459822 --- /dev/null +++ b/tests/TheArchiveCarriesNoTestsTest.php @@ -0,0 +1,56 @@ + + * + * @license Apache-2.0 + * + * @link https://github.com/getmilpa/command + */ + +declare(strict_types=1); + +namespace Milpa\Command\Tests; + +use PHPUnit\Framework\TestCase; + +/** + * WHAT A HOUSE INSTALLS OF THIS PACKAGE CARRIES NO TESTS. + * + * Composer installs the archive of a tag, and git leaves out of an archive whatever `.gitattributes` marks + * `export-ignore`. Until that line existed, a house that required this package received its tests too — as + * many files as the code it runs, never run there, and with them whatever a test had been written with. One + * line keeps them out, and nothing in the package held that line. + * + * @guards the tests being marked out of the archive, and the archive git builds carrying none + * + * @refuses nothing — it holds a line of `.gitattributes` + */ +final class TheArchiveCarriesNoTestsTest extends TestCase +{ + public function testTheTestsAreMarkedOutOfTheArchive(): void + { + $marked = array_map('trim', file(\dirname(__DIR__) . '/.gitattributes', \FILE_IGNORE_NEW_LINES | \FILE_SKIP_EMPTY_LINES) ?: []); + + self::assertContains('/tests export-ignore', $marked, 'the tests travel to every house that installs this package'); + } + + /** By execution: the archive git builds of this very commit, listed. */ + public function testTheArchiveGitBuildsOfThisCommitCarriesNone(): void + { + $root = \dirname(__DIR__); + if (!file_exists($root . '/.git')) { + self::markTestSkipped('not a git checkout: there is no archive to build here'); + } + + exec('git -C ' . escapeshellarg($root) . ' archive HEAD 2>/dev/null | tar -t 2>/dev/null', $entries, $exit); + if ($exit !== 0 || $entries === []) { + self::markTestSkipped('git could not build the archive of HEAD here'); + } + + self::assertSame([], array_values(array_filter($entries, static fn (string $entry): bool => str_starts_with($entry, 'tests/')))); + self::assertNotSame([], array_filter($entries, static fn (string $entry): bool => str_starts_with($entry, 'src/')), 'the control: the archive was read, and it carries the code'); + } +}