You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Running the test suite (php run-tests.php -n tests/) silently deletes tracked legacy test filestests/<name>.php whenever a tests/<name>.phpt with the same basename exists.
Observed during the #177 session: a full suite run deleted 49–50 legacy files from the working tree (restored manually with git checkout -- tests/).
Root cause
run-tests.php (bundled from php-src) derives the executable path from the .phpt basename in the same directory and unlinks it unconditionally — with no guard against deleting pre-existing/git-tracked files:
// run-tests.php:1942 / 1952$main_file_name = basename($file, 'phpt');
$test_file = $test_dir . DIRECTORY_SEPARATOR . $main_file_name . 'php';
// run-tests.php:1982–1991 — runs before every test, no existence check// unlink old test results
@unlink($test_file); // ← deletes a pre-existing tracked file too
The file is then overwritten with generated test code (save_text($test_file, ...), line 2276) and unlinked again after the run (line 2618) unless --keep-php is used. --keep-php does not prevent the pre-test unlink at line 1991.
Impact
git status shows dozens of unexpected deletions after any suite run
ls tests/bug_0002.php # exists (tracked in git)
php -n run-tests.php --no-progress tests/bug_0002.phpt >/dev/null 2>&1
ls tests/bug_0002.php # No such file or directory
git checkout -- tests/bug_0002.php
Problem
Running the test suite (
php run-tests.php -n tests/) silently deletes tracked legacy test filestests/<name>.phpwhenever atests/<name>.phptwith the same basename exists.Observed during the #177 session: a full suite run deleted 49–50 legacy files from the working tree (restored manually with
git checkout -- tests/).Root cause
run-tests.php(bundled from php-src) derives the executable path from the.phptbasename in the same directory and unlinks it unconditionally — with no guard against deleting pre-existing/git-tracked files:The file is then overwritten with generated test code (
save_text($test_file, ...), line 2276) and unlinked again after the run (line 2618) unless--keep-phpis used.--keep-phpdoes not prevent the pre-test unlink at line 1991.Impact
git statusshows dozens of unexpected deletions after any suite run.phpfiles intests/currently share a basename with a.phpt(legacy migrated tests awaiting removal per migration task chore: cleanup php/ directory — move examples, remove embeddings.php #24)Reproduction (empirical, verified)
Suggested fixes
.phpfiles from git in a dedicated migration PR (they are fully superseded by.phpt; task chore: cleanup php/ directory — move examples, remove embeddings.php #24) — removes the root hazard.phpfiles overlap with.phptbasenamesAGENTS.mdthat suite runs mutatetests/until the migration lands