Skip to content

Refactor test generation to reduce diff noise when adding new options - #1060

Closed
uimataso wants to merge 4 commits into
pulldown-cmark:mainfrom
uimataso:update-gen-tests
Closed

uimataso wants to merge 4 commits into
pulldown-cmark:mainfrom
uimataso:update-gen-tests

Conversation

@uimataso

Copy link
Copy Markdown

Problem

While exploring how to implement my own extension, I noticed that adding a new argument to tests::test_markdown_html causes 1000+ lines of changes, because every test cases requires an additional false argument. For example, in PR #991, more than half of the diff is just adding an extra false to test_markdown_html.

So I think it is a good idea to refactor the test generation to reduce the diff noise.

Solution

Introduce a configuration struct (with #[derive(Default)]) to hold all test options. This allows new options to be added without modifying every single test invocation, only the tests that actually depend on the new option need to be updated.

@ollpu

ollpu commented Nov 14, 2025 •

Copy link
Copy Markdown
Collaborator

I have definitely thought the same. This should make the spec test system easier to scale.

I'm wondering if this needs a separate type, or if we could get away with using Options directly, maybe with a function that gives the "test defaults"?

There's actually already a new class of tests merged into branch-0.14, which would be the next release. Could you change your merge target to that and add the new class introduced in #1043?

(We have been doing branching like this, where master is the stable version and breaking changes are first merged into a separate branch. Maybe we should discuss changing that to the more typical approach where master/main/dev is the main integration branch with a static name. Non-breaking changes can then be backported on top of the stable version if deemed necessary.)

@ollpu

ollpu commented Nov 14, 2025

Copy link
Copy Markdown
Collaborator

I started a thread about branching in the old Zulip:

#pulldown-cmark > Branching strategy

cc @Martin1887 @notriddle

@uimataso

Copy link
Copy Markdown
Author

There's actually already a new class of tests merged into branch-0.14, which would be the next release. Could you change your merge target to that and add the new class introduced in #1043?

sure! I'll do that.

I'm wondering if this needs a separate type, or if we could get away with using Options directly, maybe with a function that gives the "test defaults"?

Yeah, I could use Options directly in the generated test, I think this is better too.

@uimataso
uimataso changed the base branch from master to branch-0.14 November 15, 2025 06:42
@uimataso

Copy link
Copy Markdown
Author

@ollpu I have updated the generated tests to use Options directly, and also included the new test class container_extensions.

@ollpu
ollpu changed the base branch from branch-0.14 to master November 15, 2025 15:06
@ollpu

ollpu commented Nov 15, 2025

Copy link
Copy Markdown
Collaborator

Thanks, I will take a closer look soon.

We clarified our branching strategy. master/main will be the integration point including breaking changes, so I changed the merge target back.

@ollpu

ollpu commented Aug 16, 2026

Copy link
Copy Markdown
Collaborator

Sorry, it's been a while. I have an alternative approach in #1122, which requires no changes to the test generator when adding new Options, and there are no global defaults.

@uimataso

Copy link
Copy Markdown
Author

No worries! Feel free to close this PR if this is no longer needed.

@Martin1887 Martin1887 closed this Aug 17, 2026
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.

3 participants