Skip to content

run-make-support: add wrapper for fs operations#125736

Merged
bors merged 1 commit intorust-lang:masterfrom
Oneirical:run-make-file-management
Jun 11, 2024
Merged

run-make-support: add wrapper for fs operations#125736
bors merged 1 commit intorust-lang:masterfrom
Oneirical:run-make-file-management

Conversation

@Oneirical
Copy link
Contributor

@Oneirical Oneirical commented May 29, 2024

Suggested by #125728.

The point of this wrapper is to stop silent fails caused by forgetting to unwrap fs functions. However, functions like fs::read which return something and get stored in a variable should cause a failure on their own if they are not unwrapped (as the Result will be stored in the variable, and something will be done on that Result that should have been done to its contents). Is it still pertinent to wrap fs::read_to_string, fs::metadata and so on?

Closes: #125728

try-job: x86_64-msvc
try-job: i686-mingw

@rustbot
Copy link
Collaborator

rustbot commented May 29, 2024

r? @jieyouxu

rustbot has assigned @jieyouxu.
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 the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 29, 2024
@rustbot
Copy link
Collaborator

rustbot commented May 29, 2024

The run-make-support library was changed

cc @jieyouxu

Some changes occurred in run-make tests.

cc @jieyouxu

@rust-log-analyzer

This comment has been minimized.

@Oneirical Oneirical force-pushed the run-make-file-management branch from 05c396f to ef50eda Compare May 29, 2024 19:56
@rust-log-analyzer

This comment has been minimized.

@Oneirical Oneirical force-pushed the run-make-file-management branch 2 times, most recently from 6d89045 to 5405489 Compare May 29, 2024 20:56
@rust-log-analyzer

This comment has been minimized.

@Oneirical Oneirical force-pushed the run-make-file-management branch from 5405489 to 285ddae Compare May 29, 2024 21:06
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented May 30, 2024

☔ The latest upstream changes (presumably #125744) made this pull request unmergeable. Please resolve the merge conflicts.

@Oneirical Oneirical force-pushed the run-make-file-management branch from 285ddae to 413d8b1 Compare May 30, 2024 14:29
@Oneirical Oneirical marked this pull request as draft May 30, 2024 14:49
@Oneirical Oneirical force-pushed the run-make-file-management branch 2 times, most recently from 6940dae to 249fd58 Compare May 30, 2024 14:58
@Oneirical Oneirical marked this pull request as ready for review May 30, 2024 14:59
@rust-log-analyzer

This comment has been minimized.

@Oneirical Oneirical marked this pull request as draft May 30, 2024 16:53
@Oneirical Oneirical force-pushed the run-make-file-management branch from 249fd58 to 2c0f892 Compare May 30, 2024 16:58
@rust-log-analyzer

This comment has been minimized.

@Oneirical Oneirical force-pushed the run-make-file-management branch from 2c0f892 to 14ea2a5 Compare May 30, 2024 19:15
@rust-log-analyzer

This comment has been minimized.

Copy link
Member

@jieyouxu jieyouxu left a comment

Choose a reason for hiding this comment

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

Good changes, I think tests are less busy to read without all the .unwrap()s.

@Oneirical Oneirical force-pushed the run-make-file-management branch from 14ea2a5 to e551456 Compare May 31, 2024 13:55
@rust-log-analyzer

This comment has been minimized.

@Oneirical Oneirical force-pushed the run-make-file-management branch from e551456 to 9404d9e Compare May 31, 2024 14:56
@rust-log-analyzer

This comment has been minimized.

@Oneirical Oneirical force-pushed the run-make-file-management branch from 9404d9e to 1094107 Compare May 31, 2024 16:46
@rustbot rustbot added PG-exploit-mitigations Project group: Exploit mitigations 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. T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jun 9, 2024
@rustbot

This comment has been minimized.

@Oneirical
Copy link
Contributor Author

Oneirical commented Jun 9, 2024

@Kobzol, in my defense, all I did was follow orders.

I'm joking!! It's my bad, I copypasted the block of commands and didn't check the git diff.

At this step: git fetch origin master I should have synced with upstream first.

Sorry, once again, to anyone wrongfully pinged.

EDIT: Alright, the spillage looks contained. Just need to cleave off the irrelevant tags now!

@Kobzol
Copy link
Member

Kobzol commented Jun 9, 2024

LGTM! Although the first two commits of this PR should be removed. If you're still brave enough to trust my git command suggestions, you can do it e.g. like this:

$ git rebase -i HEAD~4
(delete the first two lines starting with "pick")
(check that the git history is ok and contains just two commits that against the base branch)
$ git push --force-with-lease

@Oneirical
Copy link
Contributor Author

LGTM! Although the first two commits of this PR should be removed. If you're still brave enough to trust my git command suggestions, you can do it e.g. like this:

$ git rebase -i HEAD~4
(delete the first two lines starting with "pick")
(check that the git history is ok and contains just two commits that against the base branch)
$ git push --force-with-lease

Hehe, thankfully I've had to do a bunch of rebases like this to keep the commit count low in my other PRs.

@rustbot review

@jieyouxu
Copy link
Member

jieyouxu commented Jun 9, 2024

Oh I was a bit confused for a moment, because the commit messages look as if they had nothing to do with the PR title lol. Ah, the first commit also has conflict markers... maybe split the changes into one commit for the library and another for updating tests, or squash them together?

Copy link
Member

@jieyouxu jieyouxu left a comment

Choose a reason for hiding this comment

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

Thank you for working on this, the tests do look a lot cleaner! I left some review comments, but looks good to me overall.

Comment on lines 32 to 37
for (output_file, emit) in flags {
fs::remove_file(output_file).unwrap_or_default();
compile(output_file, emit);
fs::remove_file(output_file);
compile(&bin_name(output_file), emit);
}
Copy link
Member

Choose a reason for hiding this comment

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

Concern: I would like to see the remove_files remain because they also check the output filenames with no --emit, single-artifact --emit and multi-artifact --emits. See 8d182e3 (#126197).

Copy link
Member

Choose a reason for hiding this comment

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

This was my change, sorry. The previous code was highly non-obvious (I suspect that the removes were there because previously the code wasn't run in a temporary directory). I'd suggest to do this:

  1. Explicitly add the expected paths as a third tuple item in the flags array
  2. Add something like assert!(is_file(expected_filename)) for each of the expected filenames. That makes it much more obvious than removing the file.

Copy link
Member

@jieyouxu jieyouxu Jun 9, 2024

Choose a reason for hiding this comment

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

Thanks, yeah, that's a much better way to doing this.

@Oneirical could we instead check for the expected files (have -o's filename include the expected extensions apart from the multioutput case, and check that an output artifact is in fact produced for the respective --emit?

@jieyouxu
Copy link
Member

jieyouxu commented Jun 9, 2024

@rustbot author

@Oneirical
Copy link
Contributor Author

Oh I was a bit confused for a moment, because the commit messages look as if they had nothing to do with the PR title lol. Ah, the first commit also has conflict markers... maybe split the changes into one commit for the library and another for updating tests, or squash them together?

Right, a side-effect of the little commit spillage. I put everything in one commit with a reasonable name and changed the PR title too.

All requested changes applied.

@rustbot review

@jieyouxu
Copy link
Member

jieyouxu commented Jun 9, 2024

Ah, just a suggestion for checking if we have expected output file instead of trying to remove files as a proxy (#125736 (comment)), then r=me.

@rust-log-analyzer

This comment has been minimized.

@jieyouxu
Copy link
Member

@rustbot blocked (waiting on #125752 to merge)

@Kobzol
Copy link
Member

Kobzol commented Jun 11, 2024

#125752 was merged, so this needs a rebase.

@jieyouxu
Copy link
Member

@rustbot author (no longer blocked)

Copy link
Member

@jieyouxu jieyouxu left a comment

Choose a reason for hiding this comment

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

Just one small problem with an intra-doc link, r=me after fixing that because it might fail in CI when ./x doc src/tools/run-make-support and after PR CI is green.

@jieyouxu
Copy link
Member

The current rollup contains some rmake.rs that uses std::fs, but we should land this PR ASAP to prevent more bitrotting or conflicts (I will fixup the rolled up tests after this PR).

@jieyouxu
Copy link
Member

@bors r+ rollup=never p=1 (some other run-make PRs are blocked on this)

@bors
Copy link
Collaborator

bors commented Jun 11, 2024

📌 Commit c84afee has been approved by jieyouxu

It is now in the queue for this repository.

@bors
Copy link
Collaborator

bors commented Jun 11, 2024

⌛ Testing commit c84afee with merge 3ea5e23...

@bors
Copy link
Collaborator

bors commented Jun 11, 2024

☀️ Test successful - checks-actions
Approved by: jieyouxu
Pushing 3ea5e23 to master...

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (3ea5e23): 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 (primary 3.3%)

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)
3.3% [3.3%, 3.3%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 3.3% [3.3%, 3.3%] 1

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: 679.328s -> 676.994s (-0.34%)
Artifact size: 320.10 MiB -> 320.03 MiB (-0.02%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-run-make Area: port run-make Makefiles to rmake.rs 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-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

run-make-support: add helpers for fs operations

7 participants