Skip to content

Tests: Avoid repeated test invocations in Tests_WpTokenMap - #13478

Closed
SainathPoojary wants to merge 1 commit into
WordPress:trunkfrom
SainathPoojary:fix/66074-token-map
Closed

Tests: Avoid repeated test invocations in Tests_WpTokenMap#13478
SainathPoojary wants to merge 1 commit into
WordPress:trunkfrom
SainathPoojary:fix/66074-token-map

Conversation

@SainathPoojary

@SainathPoojary SainathPoojary commented Sep 10, 2026

Copy link
Copy Markdown

Updates Tests_WpTokenMap to avoid repeated test runner overhead for each HTML5 named character reference.

Previously, test_reads_token_at_given_offset and test_detects_all_tokens each used a 2,231-item data provider (data_html5_test_dataset), creating 4,462 individual test invocations. Each invocation incurred PHPUnit test runner lifecycle overhead (setup, teardown, and event handling) for in-memory token map checks.

Both methods now retrieve the dataset via a private helper method and assert all tokens within internal loops. This reduces the test case count from 4,474 to 14 while preserving all 24,587 assertions. Failure messages have also been updated to include the token name to maintain precise diagnostics if a regression occurs.

Performance

Performance measured locally across three consecutive runs comparing trunk to this branch:

Run Trunk Test Time Trunk Wall Time Fix Test Time Fix Wall Time
Run 1 4.892s 5.277s 0.192s 0.218s
Run 2 5.628s 6.121s 0.192s 0.214s
Run 3 4.452s 4.790s 0.195s 0.232s
Average 4.991s 5.396s 0.193s 0.221s
  • Pure Test Time: ~96.1% reduction (from ~4.99s to ~0.19s).
  • PHPUnit Wall Time: ~95.9% reduction (from ~5.40s to ~0.22s).

Trac ticket: https://core.trac.wordpress.org/ticket/66074

Use of AI Tools

AI assistance: Yes
Tool(s): Github Copilot
Used for: Edge-case checks, and assistance with the PR description, implementation and testing were reviewed and verified by me.


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@github-actions

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props sainathpoojary.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

wporg-sync pushed a commit that referenced this pull request Sep 10, 2026
Check all HTML5 named character references within each token map test instead of running a separate test for every token. Preserve the per-token assertions and include token names in failure messages.

Reduce test invocations from 4,474 to 14, avoiding repeated test runner setup and teardown.

Developed in: #13478

Props sainathpoojary.
See #66074.


git-svn-id: https://develop.svn.wordpress.org/trunk@63591 602fd350-edb4-49c9-b593-d223f7449a82
@lancewillett

Copy link
Copy Markdown
Member

wporg-sync pushed a commit to WordPress/WordPress that referenced this pull request Sep 10, 2026
Check all HTML5 named character references within each token map test instead of running a separate test for every token. Preserve the per-token assertions and include token names in failure messages.

Reduce test invocations from 4,474 to 14, avoiding repeated test runner setup and teardown.

Developed in: WordPress/wordpress-develop#13478

Props sainathpoojary.
See #66074.

Built from https://develop.svn.wordpress.org/trunk@63591


git-svn-id: http://core.svn.wordpress.org/trunk@62767 1a063a9b-81f0-0310-95a4-ce76da25c4cd
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.

2 participants