rust-lang / rust-lang/rustfmt

Tests for --file-lines

Open
#7,112 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-test-harness A-test-suite C-discussion
Dominant language
Rust
Stars
7k
Forks
1.1k
Avg merge
2d 13h
Merged PRs (30d)
24

Description

I think the existing formatting tests can be made to work for testing --file-lines.

Basically, what you can do is run diff between source/target, and identify the source lines that get formatted. Then use --file-lines to:

  • only format those lines, check if it produces something identical to target
  • only format lines that aren't those, check if it produces something identical to source

This may cover many of the cases @randomPoison has been finding.

There may be cleverer ways of doing this that cover more cases

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the existing formatting tests and the --file-lines handling, then use diff between each source and target to identify formatted lines. The work is done when tests verify that formatting only those lines reproduces the target and formatting the other lines reproduces the source across the relevant cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
testing
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.