Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tidy: split dots in filename not the entire path when checking for stray stdout/stderr files #121992

Merged
merged 4 commits into from
Mar 5, 2024

Conversation

jieyouxu
Copy link
Member

@jieyouxu jieyouxu commented Mar 4, 2024

I committed a path crime by splitting the entire path on ., when I meant to split on the filename. This means that any parent folders which contain . will cause tidy failure. Added a regression test so that doesn't happen again.

Follow-up

Fixes #121986.

@rustbot
Copy link
Collaborator

rustbot commented Mar 4, 2024

r? @clubby789

rustbot has assigned @clubby789.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 4, 2024
@@ -84,7 +84,9 @@ pub fn check(tests_path: impl AsRef<Path>, bad: &mut bool) {
}
});

let Some((test_name, _)) = test.to_str().map(|s| s.split_once('.')).flatten() else {
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Could we not use some unstable features?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think I actually want file_stem semantics here, because I want to keep the test name which is everything but the "rs" extension. This split_once doesn't seem right. E.g. a.b.rs, the test name is should be a.b not a. Revisioned output gets additional .[rev].std{out,err} after the test name to the best of my knowledge.

Copy link
Member Author

Choose a reason for hiding this comment

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

Could we not use some unstable features?

Tidy requires stable no?

Copy link
Member

Choose a reason for hiding this comment

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

Oh 😢

Comment on lines +105 to +108
let filename_components = filename.split('.').collect::<Vec<_>>();
let [file_prefix, ..] = &filename_components[..] else {
continue;
};
Copy link
Member Author

@jieyouxu jieyouxu Mar 4, 2024

Choose a reason for hiding this comment

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

I think this logic here isn't robust either. If a test name is a.b.rs, and previously we use file_stem, the test name becomes a.b. But now this sibling check produces a which will silently let a.b.unknown-revision.stdout go through because there is no entry in test_info. I'll have to think about this part of the logic a bit.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm actually not sure if we can properly check here, if we don't assume test name itself to not have any dots.

According to rustc-dev-guide, a test output can take the form

<test_name>[.<revision>][.<compare_mode>].<extension>
  • but <extension> can be:
    • stderr, stdout
    • run.stderr, run.stdout
    • 64bit.stderr, 32bit.stderr
  • but <test_name> can also have dots if we don't assume it can't have dots.

Maybe it's just better to just say "we assume a test's name don't contain dots or else this tidy check won't catch stray stdout/stderr files for that test"?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I think that's necessary to assume for file names. We can assume that of a file name even if we can't assume that for the full path.

Copy link
Member

Choose a reason for hiding this comment

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

we assume a test's name don't contain dots or else this tidy check won't catch stray stdout/stderr files for that test

We may need to add an assertion with a message to ensure that it doesn't happen.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll add an aasert for if the test name contains dots, and update the dev-guide to describe this behavior.

Copy link
Member

Choose a reason for hiding this comment

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

Probably a good idea. A lot of the test infra assumes that things like e.g. .64bit.stderr remain coherent.

This is so that we can catch stray test output files, since test names
without dots can form predictable patterns we can match on.
@rust-log-analyzer

This comment has been minimized.

@jieyouxu
Copy link
Member Author

jieyouxu commented Mar 5, 2024

Is there a way to force tidy to rerun on all test files, regardless of if they are modified or not?

@onur-ozkan
Copy link
Member

Is there a way to force tidy to rerun on all test files, regardless of if they are modified or not?

Did you try --force-rerun ?

@jieyouxu
Copy link
Member Author

jieyouxu commented Mar 5, 2024

Did you try --force-rerun ?

As in ./x test tidy --force-rerun? That didn't seem to check all the test files, at least not from the "formatting xxx" messages. Unless it did check, but didn't print anything?

@onur-ozkan
Copy link
Member

onur-ozkan commented Mar 5, 2024

Did you try --force-rerun ?

As in ./x test tidy --force-rerun? That didn't seem to check all the test files, at least not from the "formatting xxx" messages. Unless it did check, but didn't print anything?

Probably doesn't do anything then

@jieyouxu
Copy link
Member Author

jieyouxu commented Mar 5, 2024

Probably doesn't do anything then

I'll just write an external script to go through all the test files to check if there's any multi-dot test names.

@onur-ozkan onur-ozkan assigned onur-ozkan and unassigned clubby789 Mar 5, 2024
@onur-ozkan
Copy link
Member

@bors r+ p=1 (as this fixes a very noisy tidy issue)

@bors
Copy link
Contributor

bors commented Mar 5, 2024

📌 Commit 247a080 has been approved by onur-ozkan

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 5, 2024
@bors
Copy link
Contributor

bors commented Mar 5, 2024

⌛ Testing commit 247a080 with merge c7beecf...

@bors
Copy link
Contributor

bors commented Mar 5, 2024

☀️ Test successful - checks-actions
Approved by: onur-ozkan
Pushing c7beecf to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Mar 5, 2024
@bors bors merged commit c7beecf into rust-lang:master Mar 5, 2024
12 checks passed
@rustbot rustbot added this to the 1.78.0 milestone Mar 5, 2024
@jieyouxu jieyouxu deleted the fix-tidy-unpaired-revision branch March 5, 2024 16:33
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (c7beecf): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
3.2% [3.2%, 3.2%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 643.644s -> 644.654s (0.16%)
Artifact size: 175.01 MiB -> 175.03 MiB (0.01%)

@onur-ozkan
Copy link
Member

Is there a way to force tidy to rerun on all test files, regardless of if they are modified or not?

As far as I see we already doing this. Could you tell what made you think that tidy doesn't already do that?

@jieyouxu
Copy link
Member Author

jieyouxu commented Mar 5, 2024

As far as I see we already doing this. Could you tell what made you think that tidy doesn't already do that?

I'm actually not sure, probably because the formatting modified entries messages came first, and then I subconsciously ignored the other messages? (this is moreso me being :ferrisClueless: than anything)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tons of tidy failures on master
10 participants