Skip to content

test: report PHP line coverage of the integration tests - #276

Merged
pjcdawkins merged 3 commits into
mainfrom
php-integration-coverage
Oct 27, 2026
Merged

pjcdawkins merged 3 commits into
mainfrom
php-integration-coverage

Conversation

@pjcdawkins

Copy link
Copy Markdown
Contributor

The integration tests' coverage report counts Go statements, but most of the CLI's behavior is in the legacy PHP code. This adds PHP line coverage of the integration tests, to show which legacy behavior is untested before it is ported to Go.

  • make test-integration-php-coverage builds a CLI with legacy.PHPPath set at build time to legacy/scripts/coverage/php. That wrapper runs the legacy source (TEST_CLI_PHAR_PATH=legacy/bin/platform) on the system PHP with PCOV, and each process writes its coverage to PHP_COVERAGE_DIR. Release builds are unchanged.
  • legacy/scripts/coverage/report.php merges the data, prints a Markdown summary by directory, and writes an HTML report to dist/php-coverage/html.
  • A new CI job, integration-test-php-coverage, writes the summary to the job summary and uploads the HTML report. The main integration job still runs the embedded PHP.

Locally the tests cover 64.2% of the lines in legacy/src.

It also fixes a bug that this setup exposed: the wrapper copied the embedded phar to the {ENV_PREFIX}PHAR_PATH path on init, which overwrote the custom phar before it ran.

🤖 Generated with Claude Code

pjcdawkins and others added 2 commits October 26, 2026 21:23
The wrapper copied the embedded phar to the phar path on init, including a
path given by {ENV_PREFIX}PHAR_PATH, so the custom phar was replaced before it
ran. It now copies the embedded phar only to its default path in the cache
directory.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The integration tests' coverage report counts Go statements, but most of the
CLI's behavior is in the legacy PHP code. make test-integration-php-coverage
builds a CLI that runs the legacy source on the system PHP with PCOV, through
a wrapper set at build time (legacy.PHPPath), and reports line coverage by
directory, with an HTML report. A new CI job runs it, and writes the summary
to the job summary.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@upsun-dispatch upsun-dispatch Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

Changes suggested — 🟡 1 warning · 🔵 1 minor point

🔍 Full review · 8 files reviewed

Verification
  • init now skips the embedded-phar copy only when {PREFIX}PHAR_PATH is set, and pharPath still returns the cache path otherwise, so release behavior is unchanged.
  • PHPPath changes only the binary in makeCmd. The -n flag is still the first argument, which is why the shell wrapper's $1 = -n check works (Unix settings() returns nil).
  • The integration tests get TEST_CLI_PHAR_PATH from os.Environ() in testEnv, and the CLI reads it as its {PREFIX}PHAR_PATH, because the test config's env_prefix is TEST_CLI_.
  • TestInitKeepsCustomPhar would have failed before the fix: init used to write the embedded phar (an empty placeholder in CI) over the custom path.
  • report.php calls only php-code-coverage 11.0.12 APIs that exist in that version (abstract Driver start/stop/nameAndVersion, Filter::includeFile, includeUncoveredFiles).

The new Go unit test TestInitKeepsCustomPhar covers the PHAR_PATH init fix, and the CI test job runs it via make test-go. Nothing tests the coverage scripts (php, prepend.php, report.php) except the new integration-test-php-coverage CI job itself.

Review details
  • Commit: 139b570
  • Model: claude-opus-5-5

Review 1 of 10 for this pull request · View the full run

Comment thread legacy/scripts/coverage/report.php Resolved
Comment thread legacy/scripts/coverage/prepend.php Resolved
… coverage dir

The summary had no rows for files directly in src/ or src/Command/, such as
CommandBase.php. They are now reported as "*.php" and "Command/*.php".

The prepend file wrote with tempnam(), which falls back to the system temp
directory when PHP_COVERAGE_DIR does not exist, so data was lost without an
error. It now fails if the directory is missing, or if the write fails.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pjcdawkins
pjcdawkins merged commit f9ec3c9 into main Oct 27, 2026
12 checks passed
@pjcdawkins
pjcdawkins deleted the php-integration-coverage branch October 27, 2026 17:15
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.

1 participant