Skip to content

Add trailing newline check for rustc --print in run-make-support#127887

Closed
rejyr wants to merge 2 commits into
rust-lang:masterfrom
rejyr:run-make-support-print-newline-check
Closed

Add trailing newline check for rustc --print in run-make-support#127887
rejyr wants to merge 2 commits into
rust-lang:masterfrom
rejyr:run-make-support-print-newline-check

Conversation

@rejyr

@rejyr rejyr commented Jul 18, 2024

Copy link
Copy Markdown
Contributor

From this comment.

Checks that rustc --print stdout ends with a newline.
Adds CompletedProcess check closures to Command.
Unfortunately, this means that #[derive(Debug)] macro for Command no longer works.

Part of #121876.

r? @jieyouxu

@rustbot rustbot added A-run-make Area: port run-make Makefiles to rmake.rs S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 18, 2024
@rustbot

rustbot commented Jul 18, 2024

Copy link
Copy Markdown
Collaborator

The run-make-support library was changed

cc @jieyouxu

This PR modifies tests/run-make/. If this PR is trying to port a Makefile
run-make test to use rmake.rs, please update the
run-make port tracking issue
so we can track our progress. You can either modify the tracking issue
directly, or you can comment on the tracking issue and link this PR.

cc @jieyouxu

@rejyr rejyr changed the title Run make support print newline check Add trailing newline check for rustc --print in run-make-support Jul 18, 2024

@jieyouxu jieyouxu left a comment

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.

I don't really like the Vec<(String, Box<dyn Fn(&CompletedProcess)>)> related extra complexity here. Why is the

assert!(out.stdout_utf8().ends_with('\n'));

check not sufficient?

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 18, 2024
@rejyr

rejyr commented Jul 18, 2024

Copy link
Copy Markdown
Contributor Author

I don't really like the Vec<(String, Box<dyn Fn(&CompletedProcess)>)> related extra complexity here. Why is the

assert!(out.stdout_utf8().ends_with('\n'));

check not sufficient?

This checks that every rustc invocation with --print is checked with a newline, instead of manually for every invocation.

The Vec<(String, Box<dyn Fn(&CompletedProcess)>)> is not great, it could be implemented with

#[derive(Debug)] // this works now
pub struct Command {
    cmd: StdCommand,
    stdin: Option<Box<[u8]>>,
    assert_stdout_ends_with_newline: bool,
    drop_bomb: DropBomb,
}

and

// Command::command_output
if self.assert_stdout_ends_with_newline {
    completed_process.assert_stdout_ends_with_newline();
}

@jieyouxu

Copy link
Copy Markdown
Member

@rustbot review

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 20, 2024
pub struct Command {
cmd: StdCommand,
stdin: Option<Box<[u8]>>,
completed_process_checks: Vec<(String, Box<dyn Fn(&CompletedProcess)>)>,

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.

#[derive(Debug)] // this works now
pub struct Command {
    cmd: StdCommand,
    stdin: Option<Box<[u8]>>,
    assert_stdout_ends_with_newline: bool,
    drop_bomb: DropBomb,
}

and

// Command::command_output
if self.assert_stdout_ends_with_newline {
    completed_process.assert_stdout_ends_with_newline();
}

Let's use a simple bool for now, if there are more check-hooks that we wish to register upon construction, then we can always refactor into the hook form when it comes to it.

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 22, 2024
@bors

bors commented Jul 31, 2024

Copy link
Copy Markdown
Collaborator

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

@JohnCSimon

Copy link
Copy Markdown
Member

@rejyr
ping from triage - can you post your status on this PR? This PR has not received an update in a few months.

FYI: when a PR is ready for review, send a message containing
@rustbot ready to switch to S-waiting-on-review so the PR is in the reviewer's backlog.

Or if you're not going to continue, please close it. Thank you!

@rejyr

rejyr commented Sep 4, 2024

Copy link
Copy Markdown
Contributor Author

I think checking rustc --print would be better accomplished with a dedicated test for all options instead of a hook.

@rejyr rejyr closed this Sep 4, 2024
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 S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants