From 43bb10048db387a2215e46df5d0054446829e9e8 Mon Sep 17 00:00:00 2001 From: l0ng-ai <24760907+l0ng-ai@users.noreply.github.com> Date: Fri, 6 Nov 2026 05:58:13 +0800 Subject: [PATCH] test(phpstan): read the pause before logging the run (#1632) The fake PHP logged its run before reading the pause file, so a test that reset the pause on seeing the run could make that run skip its pause on a slow machine and finish before the next save cancelled it. --- crates/ide-host/src/phpstan.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/ide-host/src/phpstan.rs b/crates/ide-host/src/phpstan.rs index 807b94e7..e74d7ac3 100644 --- a/crates/ide-host/src/phpstan.rs +++ b/crates/ide-host/src/phpstan.rs @@ -611,7 +611,7 @@ mod tests { } /// A project with PHPStan whose PHP logs each run, waits `pause` seconds, prints `stderr` and - /// reports `report`. + /// reports `report`. `pause` is read before the run is logged, so a test that sees the run can change it. #[cfg(unix)] struct Fixture { _dir: tempfile::TempDir, @@ -634,8 +634,8 @@ mod tests { // Named php8.5: the selected PHP runs vendor/bin/phpstan, whatever its name. let php = base.join("php/php8.5"); std::fs::create_dir_all(php.parent().unwrap()).unwrap(); - let script = "#!/bin/sh\nshift\necho \"$XDEBUG_MODE $*\" >> runs.log\n\ - sleep \"$(cat pause 2>/dev/null || echo 0)\"\ncat stderr >&2 2>/dev/null\ncat report\n"; + let script = "#!/bin/sh\nshift\npause=\"$(cat pause 2>/dev/null || echo 0)\"\n\ + echo \"$XDEBUG_MODE $*\" >> runs.log\nsleep \"$pause\"\ncat stderr >&2 2>/dev/null\ncat report\n"; std::fs::write(&php, script).unwrap(); std::fs::set_permissions(&php, std::fs::Permissions::from_mode(0o755)).unwrap(); std::fs::create_dir_all(root.join(".openidea")).unwrap();