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

Migrate link-arg, link-dedup and issue-26092 run-make tests to rmake format #125500

Merged
merged 3 commits into from
Jun 17, 2024

Conversation

Oneirical
Copy link
Contributor

@Oneirical Oneirical commented May 24, 2024

Part of #121876 and the associated Google Summer of Code project.

All of these tests check if rustc's output contains (or does not) contain certain strings. Does that mean these could be better suited to becoming UI/codegen tests?

try-job: x86_64-msvc

@rustbot
Copy link
Collaborator

rustbot commented May 24, 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 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) labels May 24, 2024
@Oneirical Oneirical force-pushed the bundle-them-up-why-not branch 2 times, most recently from ace8f1d to 678efb6 Compare May 24, 2024 15:58
@rust-log-analyzer

This comment has been minimized.

@jieyouxu
Copy link
Member

Yes, I think it would be good to try converting them to UI tests

@Oneirical Oneirical force-pushed the bundle-them-up-why-not branch from 678efb6 to 70a3ac6 Compare May 24, 2024 18:34
@rust-log-analyzer

This comment has been minimized.

@jieyouxu
Copy link
Member

@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 May 28, 2024
@Oneirical Oneirical force-pushed the bundle-them-up-why-not branch from 70a3ac6 to 841f4cc Compare June 4, 2024 15:54
@Oneirical
Copy link
Contributor Author

Oneirical commented Jun 4, 2024

Unfortunately, porting these tests to UI tests turned out to be non-trivial:

  • link-dedup is not only looking for strings in the output, but precisely that strings appear in a specific order and exactly once.
  • link-arg is passing a flag to the compiler twice in a row.
  • no-panic-blank-output is reliant on passing a weird flag to the compiler (blank output) which can interfere with the default flags used in UI tests.

It's very possible that some existing UI test features would allow supporting these tests in UI form, but it seems to me that there is a reason they were run-make tests in the first place.

Of all 3, link-arg looks the most susceptible of being UI-ified, but I am not sure if it's worth trying to force the conversion. Tell me what you think.

@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 Jun 4, 2024
@Oneirical Oneirical marked this pull request as ready for review June 4, 2024 16:02
@rustbot
Copy link
Collaborator

rustbot commented Jun 4, 2024

Some changes occurred in run-make tests.

cc @jieyouxu

@rust-log-analyzer

This comment has been minimized.

@Oneirical
Copy link
Contributor Author

Oneirical commented Jun 4, 2024

Some strange test failures here. Perhaps link-dedup was not truly equivalent to the original test in the final line:

$(RUSTC) empty.rs 2>&1 | $(CGREP) -v '"-ltesta" "-ltesta" "-ltesta"'

let output = String::from_utf8(rustc().input("empty.rs").command_output().stderr).unwrap();
assert_eq!(output.matches("-ltesta").count(), 1);

I have tried replacing it with an inefficient alternative just to see if it makes the test pass, though this is likely a bad implementation.

let output = rustc().input("empty.rs").command_output().stderr;
let pattern = b"\"-ltesta\" \"-ltesta\" \"-ltesta\"";
for window in output.windows(pattern.len()) {
    if window == pattern {
        panic!("ltesta was repeated too many times");
    }
}

As for the other error, it's quite strange - the rewrite seems really equivalent to the original Makefile. It could be interesting to debug and see what the output is actually printing.

@rust-log-analyzer

This comment has been minimized.

@Oneirical Oneirical force-pushed the bundle-them-up-why-not branch from 1368307 to 2942fc6 Compare June 4, 2024 19:25
@rust-log-analyzer

This comment has been minimized.

@jieyouxu
Copy link
Member

jieyouxu commented Jun 5, 2024

@Oneirical becareful with the grep -v flag:

grep -v "foo" takes input line by line, and outputs only the lines in which "foo" does not appear.

So if the input to grep -v "foo" contains "foo", then it will exit with status 1 failing the test. I think this is checking that there is in fact, no matches. Needs double checking though.

@jieyouxu
Copy link
Member

jieyouxu commented Jun 5, 2024

@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 Jun 5, 2024
@Oneirical
Copy link
Contributor Author

Oneirical commented Jun 5, 2024

@Oneirical becareful with the grep -v flag:

grep -v "foo" takes input line by line, and outputs only the lines in which "foo" does not appear.

So if the input to grep -v "foo" contains "foo", then it will exit with status 1 failing the test. I think this is checking that there is in fact, no matches. Needs double checking though.

That is what I thought too, hence the assert!(!output.contains("-ltestb"));.

However, the last one is the confusing one:

$(CGREP) -v '"-ltesta" "-ltesta" "-ltesta"'

This is testing that the string "-ltesta" "-ltesta" "-ltesta" never appears, with the quotation marks as part of the output, I suppose... Let me try it with assert!(!output.contains("\"-ltesta\" \"-ltesta\" \"-ltesta\""));

EDIT: Actually, most of this logic was really overkill, let's try something much simpler.

@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 Jun 13, 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.

Thanks, looks good in general, just have a few nits.

src/tools/run-make-support/src/command.rs Outdated Show resolved Hide resolved
/// Checks that trimmed `stdout` contains trimmed `content`.
#[track_caller]
pub fn assert_stdout_contains<S: AsRef<str>>(&self, needle: S) -> &Self {
assert!(self.stdout_utf8().contains(needle.as_ref()));
Copy link
Member

Choose a reason for hiding this comment

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

Suggestion: I think we really want to expand these asserts to verbosely log the stdout and the expected/unexpected, but that can be done in a follow-up PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, that's already the case (this PR was not rebased fully, I don't know why it didn't complain about merge conflicts). Only the assert_x_equals need verbose logging.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I chose to add it right away, as it's fairly trivial.

tests/run-make/link-arg/rmake.rs Outdated Show resolved Hide resolved
tests/run-make/link-dedup/rmake.rs Outdated Show resolved Hide resolved
@@ -5,7 +5,6 @@ use run_make_support::rustdoc;

fn main() {
let output = rustdoc().input("input.rs").arg("--test").run_fail().stdout_utf8();

Copy link
Member

Choose a reason for hiding this comment

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

Question: where did these formatting diffs from come?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just me waving around autoformatting a little too liberally, I have restored it.

@jieyouxu
Copy link
Member

@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 Jun 15, 2024
@Oneirical Oneirical force-pushed the bundle-them-up-why-not branch from 12fa410 to 0813858 Compare June 17, 2024 14:58
@Oneirical
Copy link
Contributor Author

@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 Jun 17, 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.

Thanks, just a few minor nits left, then r=me.

src/tools/run-make-support/src/command.rs Outdated Show resolved Hide resolved
src/tools/run-make-support/src/lib.rs Outdated Show resolved Hide resolved
src/tools/run-make-support/src/lib.rs Outdated Show resolved Hide resolved
tests/run-make/clear-error-blank-output/rmake.rs Outdated Show resolved Hide resolved
@Oneirical Oneirical force-pushed the bundle-them-up-why-not branch from 0813858 to d2e8671 Compare June 17, 2024 16:59
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 found some more nits... Sorry!

src/tools/run-make-support/src/command.rs Outdated Show resolved Hide resolved
src/tools/run-make-support/src/command.rs Outdated Show resolved Hide resolved
src/tools/run-make-support/src/command.rs Outdated Show resolved Hide resolved
src/tools/run-make-support/src/command.rs Outdated Show resolved Hide resolved
src/tools/run-make-support/src/command.rs Outdated Show resolved Hide resolved
src/tools/run-make-support/src/command.rs Outdated Show resolved Hide resolved
src/tools/run-make-support/src/lib.rs Outdated Show resolved Hide resolved
use run_make_support::rustc;

fn main() {
let output = rustc().output("").stdin(b"fn main() {}").run_fail();
Copy link
Member

Choose a reason for hiding this comment

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

Question: I think this needs an .arg("-")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Testing it locally did not result in any problems.

Copy link
Member

Choose a reason for hiding this comment

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

Cool 😎

@jieyouxu
Copy link
Member

After fixing the nits, can you try to run ./x doc src/tools/run-make-support to check if the intra-doc link passes? Otherwise it fails very late into the CI pipeline.

@Oneirical Oneirical force-pushed the bundle-them-up-why-not branch from d2e8671 to 6228b3e Compare June 17, 2024 17:51
@Oneirical
Copy link
Contributor Author

Oneirical commented Jun 17, 2024

After fixing the nits, can you try to run ./x doc src/tools/run-make-support to check if the intra-doc link passes? Otherwise it fails very late into the CI pipeline.

Indeed, it failed, because the correct way to write it is /// Prefer to use [Self::run] and [Self::run_fail]. (with backticks) Fixed.

@Oneirical
Copy link
Contributor Author

Oneirical commented Jun 17, 2024

Thanks, just a few minor nits left, then r=me.

@bors r=@jieyouxu

@bors
Copy link
Contributor

bors commented Jun 17, 2024

📌 Commit 6228b3e has been approved by jieyouxu

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 Jun 17, 2024
@bors
Copy link
Contributor

bors commented Jun 17, 2024

⌛ Testing commit 6228b3e with merge 59e2c01...

@bors
Copy link
Contributor

bors commented Jun 17, 2024

☀️ Test successful - checks-actions
Approved by: jieyouxu
Pushing 59e2c01 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jun 17, 2024
@bors bors merged commit 59e2c01 into rust-lang:master Jun 17, 2024
7 checks passed
@rustbot rustbot added this to the 1.81.0 milestone Jun 17, 2024
@Oneirical Oneirical deleted the bundle-them-up-why-not branch June 18, 2024 01:04
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (59e2c01): comparison URL.

Overall result: ✅ improvements - no action needed

@rustbot label: -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.4% [-0.4%, -0.3%] 6
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.4% [-0.4%, -0.3%] 6

Max RSS (memory usage)

Results (primary 0.9%, secondary -3.4%)

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

Cycles

Results (secondary -0.9%)

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)
4.5% [3.4%, 6.3%] 3
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.2% [-3.9%, -2.6%] 7
All ❌✅ (primary) - - 0

Binary size

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

Bootstrap: 669.558s -> 670.994s (0.21%)
Artifact size: 320.53 MiB -> 320.50 MiB (-0.01%)

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-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

7 participants