Skip to content

Fix dev check rejecting exercises with CRLF line endings - #2425

Merged
senekor merged 2 commits into
rust-lang:mainfrom
SandmeyerX:main
Jul 31, 2026
Merged

Fix dev check rejecting exercises with CRLF line endings#2425
senekor merged 2 commits into
rust-lang:mainfrom
SandmeyerX:main

Conversation

@SandmeyerX

Copy link
Copy Markdown
Contributor

Problem

On Windows (or whenever an editor saves an exercise with CRLF line endings),
rustlings dev check fails with:

The file `exercises/XX/xxx.rs` doesn't contain any tests.

even though the exercise clearly contains #[test] functions.

Solution

Normalize CRLF to LF when checking whether an exercise contains tests, and add some unit tests.

@SandmeyerX

SandmeyerX commented Jul 31, 2026

Copy link
Copy Markdown
Contributor Author

Close #2424

@senekor

senekor commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Can we just omit the line ending? i.e. just check for #[test] instead of #[test]\n. Not sure, haven't thought too much about it.

@SandmeyerX

SandmeyerX commented Jul 31, 2026

Copy link
Copy Markdown
Contributor Author

Can we just omit the line ending? i.e. just check for #[test] instead of #[test]\n. Not sure, haven't thought too much about it.

@senekor Thanks for the review! I'd lean toward keeping the \n check - reasoning:

The trailing newline was actually added deliberately in e74f2a4 — the check originally was a bare contains("#[test]"), and I suppose the \n was introduced to avoid false positives where #[test] merely appears in prose, e.g.:

// TODO: write a #[test] function here

With a bare #[test] match, that comment would make the exercise count as "containing tests".

Maybe "More means better".

@senekor senekor left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I see, makes sense. Thanks for digging. Looks good to me.

@senekor
senekor merged commit 2f99667 into rust-lang:main Jul 31, 2026
7 checks passed
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