Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: tear down fixture plugins in three WP-CLI tests
e-cli-maintenance-001 wrote mu-plugins/cli-cron.php, and
e-cli-maintenance-002 and e-cli-reporting-003 wrote plugin directories,
all with no teardown. Under execution_isolation: none they stayed for
later tests, including cli-broken, which throws on every WordPress boot
while active.

Each test now removes its files, the active_plugins entries it added,
and (for maintenance-001) the options its cron callbacks write, so a
second pass over the suite starts from the same state.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
  • Loading branch information
lezama and claude committed Oct 21, 2026
commit ca9f46e437b8ee66ca3a28ed0afdc59daf05ca7d
6 changes: 4 additions & 2 deletions datasets/suites/wp-cli-v1/execution/cli-maintenance.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
"weight": 1
}
],
"exit_code": 0
"exit_code": 0,
"teardown": "$mu=WP_CONTENT_DIR.'/mu-plugins/cli-cron.php'; if(file_exists($mu)) { unlink($mu); } foreach(array('cli_job_log','cli_hold_ran','cli_future_ran') as $option) { delete_option($option); }"
},
"metadata": {
"source_refs": [
Expand Down Expand Up @@ -108,7 +109,8 @@
"weight": 1
}
],
"exit_code": 0
"exit_code": 0,
"teardown": "foreach(array('cli-broken','cli-good','cli-healthy') as $slug) { $dir=WP_PLUGIN_DIR.'/'.$slug; if(is_dir($dir)) { array_map('unlink',glob($dir.'/*')); rmdir($dir); } update_option('active_plugins',array_values(array_diff(get_option('active_plugins',array()),array($slug.'/'.$slug.'.php')))); }"
},
"metadata": {
"source_refs": [
Expand Down
3 changes: 2 additions & 1 deletion datasets/suites/wp-cli-v1/execution/cli-reporting.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@
"weight": 1
}
],
"exit_code": 0
"exit_code": 0,
"teardown": "foreach(array('cli-active','cli-inactive') as $slug) { $dir=WP_PLUGIN_DIR.'/'.$slug; if(is_dir($dir)) { array_map('unlink',glob($dir.'/*')); rmdir($dir); } update_option('active_plugins',array_values(array_diff(get_option('active_plugins',array()),array($slug.'/'.$slug.'.php')))); }"
},
"metadata": {
"source_refs": [
Expand Down
20 changes: 20 additions & 0 deletions python/tests/test_shell_runtime_integration.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Real Bash/WP-CLI execution checks; enabled by WP_BENCH_TEST_IMAGE."""
from __future__ import annotations

import base64
import json
import os
import subprocess
Expand Down Expand Up @@ -198,6 +199,25 @@ def test_rewriting_a_fixture_php_file_in_the_same_second_scores_zero(environment
assert not result.success and result.raw["runtime"]["score"] == 0, result.raw


@pytest.mark.parametrize("test_id", ["e-cli-maintenance-001", "e-cli-maintenance-002", "e-cli-reporting-003"])
def test_fixture_plugins_do_not_leak_into_the_next_test(environment, test_id) -> None:
test = next(t for t in load_tests(DatasetConfig(source="local", name="wp-cli-v1")) if t.id == test_id)
artifact = Artifact(kind="wp_cli_shell", code=test.reference_solution or "")
spec = _build_verification_spec(test, HarnessConfig())
payload = base64.b64encode(json.dumps({**artifact.payload_fields(), **spec}).encode()).decode()
environment.reset()
# What execution_isolation none hands the next test is this site after verify_payload returns.
result = environment.execute_code(
f"$GLOBALS['shell_result']=(new WPBench\\Runtime\\Verifier())->verify_payload(json_decode(base64_decode('{payload}'),true));",
{"runtime_checks": {"assertions": [{"type": "custom_assertion", "code": """
return $GLOBALS['shell_result']['success'] && glob(WP_PLUGIN_DIR.'/cli-*') === array()
&& ! file_exists(WPMU_PLUGIN_DIR.'/cli-cron.php') && ! preg_grep('/^cli-/', get_option('active_plugins'))
&& false === get_option('cli_job_log');
"""}]}},
)
assert result.success, result.raw


def test_concurrent_shell_workflows_have_private_database_and_files(environment) -> None:
barrier = threading.Barrier(2)

Expand Down
Loading