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 compare-output-lines-by-subset flag to compiletest #110444

Merged
merged 1 commit into from
Apr 20, 2023

Conversation

Veykril
Copy link
Member

@Veykril Veykril commented Apr 17, 2023

For ferrocene we have some compiletests that check the output of the cli arguments to the compiler, including printing things like the target list (--print target-list). Unfortunately those tend to change quite often so when we sync we end up with some outputs we have to re-bless constantly, even though the exact output doesn't really matter.

We added a new compiletest flag to aid writing these kinds of tests: compare-output-lines-by-subset. It checks whether the lines of the expected output are a subset (or equal) to the lines of the actual output. If the expected output is empty it will fail unless the actual output is also empty. We opened this PR hoping the flag might be helpful for other tests in the future (especially if CLI-related tests are added in the future in the rust-lang/rust repo itself).

@rustbot
Copy link
Collaborator

rustbot commented Apr 17, 2023

r? @ozkanonur

(rustbot has picked a reviewer for you, use r? to override)

@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 Apr 17, 2023
@onur-ozkan
Copy link
Member

r? @Mark-Simulacrum

src/tools/compiletest/src/header.rs Outdated Show resolved Hide resolved
let mut used = expected_lines.clone();
used.retain(|line| actual.lines().any(|l| l == *line));
// check if `expected` contains a subset of the lines of `actual`
if used.len() == expected_lines.len() && (expected.is_empty() == actual.is_empty()) {
Copy link
Member

Choose a reason for hiding this comment

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

I think you can get this with putting both sets of lines into HashSet and then calling https://doc.rust-lang.org/nightly/std/collections/hash_set/struct.HashSet.html#method.is_subset, while also avoiding both the - if I'm getting the math right - O(n^3) (n^2 for each set and another n for the copies as we remove lines, I think, in the worst case) retain loop.

Copy link
Member Author

@Veykril Veykril Apr 20, 2023

Choose a reason for hiding this comment

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

Isn't this already n^2? For each expected line this iterates through the actual output once. That aside, using a HashSet doesn't work as it join over the vecs in line 3840 which is order dependent. Unless IndexSet is used which requires adding it as a dependency to compiletest. I suppose actual.lines() could be collected into a HashSet at least.

@rust-log-analyzer

This comment has been minimized.

@Mark-Simulacrum
Copy link
Member

r=me with commits squashed

@Veykril
Copy link
Member Author

Veykril commented Apr 20, 2023

@bors r=Mark-Simulacrum

@bors
Copy link
Contributor

bors commented Apr 20, 2023

📌 Commit a30171c has been approved by Mark-Simulacrum

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 Apr 20, 2023
@bors
Copy link
Contributor

bors commented Apr 20, 2023

⌛ Testing commit a30171c with merge a57fa08...

@bors
Copy link
Contributor

bors commented Apr 20, 2023

☀️ Test successful - checks-actions
Approved by: Mark-Simulacrum
Pushing a57fa08 to master...

1 similar comment
@bors
Copy link
Contributor

bors commented Apr 20, 2023

☀️ Test successful - checks-actions
Approved by: Mark-Simulacrum
Pushing a57fa08 to master...

@bors bors added merged-by-bors This PR was explicitly merged by bors. labels Apr 20, 2023
@bors bors merged commit a57fa08 into rust-lang:master Apr 20, 2023
@rustbot rustbot added this to the 1.71.0 milestone Apr 20, 2023
@ehuss
Copy link
Contributor

ehuss commented Apr 20, 2023

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (a57fa08): 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
Improvements ✅
(secondary)
-2.4% [-2.4%, -2.4%] 1
All ❌✅ (primary) - - 0

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

Cycles

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

@Veykril
Copy link
Member Author

Veykril commented Apr 20, 2023

Sure, will do that tomorrow 👍

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)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants