Skip to content

Add mdtests for Ruff#24617

Draft
ntBre wants to merge 7 commits intobrent/mdtest-cratefrom
brent/ruff-mdtests
Draft

Add mdtests for Ruff#24617
ntBre wants to merge 7 commits intobrent/mdtest-cratefrom
brent/ruff-mdtests

Conversation

@ntBre
Copy link
Copy Markdown
Contributor

@ntBre ntBre commented Apr 13, 2026

Summary

This PR adds the ruff_test crate, a parallel crate to ty_test for Ruff, to
enable the new mdtests in ruff_linter. I opted to follow the Db-based
structure of ty_test to simplify the integration, but we end up basically just
unpacking the files from the Db to call the test_contents function from the
linter.

Currently stacked on #24616

Test Plan

I copied over UP046_0.py into a new mdtest. This was selected basically at
random, and I should probably either pick a shorter first test to port, or also
port over the other UP046 tests and take better advantage of the mdtest format.
Currently the whole file is just in a single code block, but it demonstrates the
basic functionality, including config loading and diagnostic snapshotting.

@ntBre ntBre added the testing Related to testing Ruff itself label Apr 13, 2026
@astral-sh-bot
Copy link
Copy Markdown

astral-sh-bot bot commented Apr 13, 2026

Typing conformance results

No changes detected ✅

Current numbers
The percentage of diagnostics emitted that were expected errors held steady at 87.94%. The percentage of expected errors that received a diagnostic held steady at 83.21%. The number of fully passing files held steady at 79/133.

@astral-sh-bot
Copy link
Copy Markdown

astral-sh-bot bot commented Apr 13, 2026

Memory usage report

Memory usage unchanged ✅

@astral-sh-bot
Copy link
Copy Markdown

astral-sh-bot bot commented Apr 13, 2026

ecosystem-analyzer results

No diagnostic changes detected ✅

Full report with detailed diff (timing results)

@astral-sh-bot
Copy link
Copy Markdown

astral-sh-bot bot commented Apr 13, 2026

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Formatter (stable)

✅ ecosystem check detected no format changes.

Formatter (preview)

✅ ecosystem check detected no format changes.

Comment thread crates/ruff_linter/tests/mdtest.rs Outdated
use anyhow::anyhow;
use camino::Utf8Path;
use ruff_test::OutputFormat;
use ty_static::EnvVars;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw https://github.com/astral-sh/ruff/pull/24557/changes#r3069608578 about not using this even in ty_test, which I think makes even more sense here.

Comment thread crates/ruff_linter/tests/mdtest.rs Outdated
Comment on lines +23 to +28
let output_format = if std::env::var(EnvVars::MDTEST_GITHUB_ANNOTATIONS_FORMAT).is_ok() {
OutputFormat::GitHub
} else {
OutputFormat::Cli
};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also consider moving this into ty_test::run? Seems weird that this needs to be reated at every call site.

@ntBre ntBre force-pushed the brent/ruff-mdtests branch from 7b52254 to 39890d5 Compare April 14, 2026 20:39
ntBre added 7 commits April 15, 2026 09:06
Summary
--

This PR adds the `ruff_test` crate, a parallel crate to `ty_test` for Ruff, to
enable the new mdtests in `ruff_linter`. I opted to follow the `Db`-based
structure of `ty_test` to simplify the integration, but we end up basically just
unpacking the files from the `Db` to call the `test_contents` function from the
linter.

Currently stacked on #24616

Test Plan
--

I copied over UP046_0.py into a new mdtest. This was selected basically at
random, and I should probably either pick a shorter first test to port, or also
port over the other UP046 tests and take better advantage of the mdtest format.
Currently the whole file is just in a single code block, but it demonstrates the
basic functionality, including config loading and diagnostic snapshotting.
@ntBre ntBre force-pushed the brent/ruff-mdtests branch from 39890d5 to 7f6a3ca Compare April 15, 2026 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

testing Related to testing Ruff itself

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants