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

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

Closed

Conversation

Rejyr
Copy link
Contributor

@Rejyr Rejyr commented Jul 18, 2024

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
Copy link
Collaborator

rustbot commented Jul 18, 2024

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
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.

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
Copy link
Contributor Author

Rejyr commented Jul 18, 2024

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
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
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
Copy link
Contributor

bors commented Jul 31, 2024

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

@JohnCSimon
Copy link
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
Copy link
Contributor Author

Rejyr commented Sep 4, 2024

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