Skip to content

implement stdout streaming in render_tests::Renderer #112541

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

Merged
merged 1 commit into from
Jun 12, 2023

Conversation

onur-ozkan
Copy link
Member

This way, we can show the test dot characters on the console immediately, without having to wait for the entire line to finish.

cc @GuillaumeGomez

@rustbot
Copy link
Collaborator

rustbot commented Jun 12, 2023

r? @clubby789

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

@rustbot rustbot added 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 Jun 12, 2023
@onur-ozkan onur-ozkan changed the title replace render_tests::try_run_test with Builder::run replace render_tests::try_run_test with Builder::run for rustdoc-gui tests Jun 12, 2023
@onur-ozkan onur-ozkan marked this pull request as draft June 12, 2023 09:22
@onur-ozkan onur-ozkan 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 12, 2023
@onur-ozkan
Copy link
Member Author

Will keep this draft for now. I want to look into render_tests::try_run_test and see if I should fix this there.

@GuillaumeGomez
Copy link
Member

Thanks for looking into it in any case!

@onur-ozkan onur-ozkan changed the title replace render_tests::try_run_test with Builder::run for rustdoc-gui tests implement stdout streaming in render_tests::Renderer Jun 12, 2023
@onur-ozkan
Copy link
Member Author

I want to look into render_tests::try_run_test and see if I should fix this there.

Yeap, this is much better. Could be useful for other use cases too.

@rustbot ready

@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jun 12, 2023
@onur-ozkan onur-ozkan marked this pull request as ready for review June 12, 2023 10:01
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 12, 2023
@clubby789
Copy link
Contributor

@bors r+

@bors
Copy link
Collaborator

bors commented Jun 12, 2023

📌 Commit 6c966dc has been approved by clubby789

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 12, 2023
@klensy
Copy link
Contributor

klensy commented Jun 12, 2023

This way, we can show the test dot characters on the console immediately, without having to wait for the entire line to finish.

But this already works that way, why change anything?

python x.py --stage=1 --jobs=4 test tests/ui/
[cut]
Check compiletest suite=ui mode=ui (x86_64-pc-windows-msvc -> x86_64-pc-windows-msvc)

running 15130 tests
iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii    88/15130
iiiiiiiiiiiiiiiiiiiiiiiiiiii............................................................   176/15130
.......iiiiiiiiiiiiiii.....................i..................i....i....................   264/15130
........................................................................................   352/15130
........................................................................................   440/15130
......

@GuillaumeGomez
Copy link
Member

Not for rustdoc-gui.

@onur-ozkan
Copy link
Member Author

This way, we can show the test dot characters on the console immediately, without having to wait for the entire line to finish.

But this already works that way, why change anything?

python x.py --stage=1 --jobs=4 test tests/ui/
[cut]
Check compiletest suite=ui mode=ui (x86_64-pc-windows-msvc -> x86_64-pc-windows-msvc)

running 15130 tests
iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii    88/15130
iiiiiiiiiiiiiiiiiiiiiiiiiiii............................................................   176/15130
.......iiiiiiiiiiiiiii.....................i..................i....i....................   264/15130
........................................................................................   352/15130
........................................................................................   440/15130
......

fn render_all(mut self) {
let mut line = Vec::new();
loop {
line.clear();
match self.stdout.read_until(b'\n', &mut line) {
Ok(_) => {}
Err(err) if err.kind() == std::io::ErrorKind::UnexpectedEof => break,
Err(err) => panic!("failed to read output of test runner: {err}"),
}
if line.is_empty() {
break;
}
match serde_json::from_slice(&line) {
Ok(parsed) => self.render_message(parsed),
Err(_err) => {
// Handle non-JSON output, for example when --nocapture is passed.
let mut stdout = std::io::stdout();
stdout.write_all(&line).unwrap();
let _ = stdout.flush();
}
}
}
}

this reads the stdout line by line

@klensy
Copy link
Contributor

klensy commented Jun 12, 2023

Ok, in that case what command didn't worked that way before?

@GuillaumeGomez
Copy link
Member

All of them (well at least all rustdoc test suites and test/ui).

@klensy
Copy link
Contributor

klensy commented Jun 12, 2023

All of them (well at least all rustdoc test suites and test/ui).

In my case, dots printed one by one and digits printed when dots reach right side, that's why i asked about that change.

@GuillaumeGomez
Copy link
Member

rustdoc-gui got migrated recently to a rust test runner and after that change, the dots are only displayed when the line is complete. It's not a problem in itself but it's not great compared to how it was working previously.

@onur-ozkan
Copy link
Member Author

onur-ozkan commented Jun 12, 2023

All of them (well at least all rustdoc test suites and test/ui).

In my case, dots printed one by one and digits printed when dots reach right side, that's why i asked about that change.

What is your HEAD ref? Do you have src/tools/rustdoc-gui-test tool in your tree ?

--

After the rustdoc-gui-test tool, we started using render_test::try_run_tests which reads/writes stdout line by line.

@klensy
Copy link
Contributor

klensy commented Jun 12, 2023

What is your HEAD ref? Do you have src/tools/rustdoc-gui-test tool in your tree ?

head is 34d64ab, src/tools/rustdoc-gui-test exist
works on fd0a331. I'll try to clean all and rebuild.

@onur-ozkan
Copy link
Member Author

What is your HEAD ref? Do you have src/tools/rustdoc-gui-test tool in your tree ?

head is 34d64ab, src/tools/rustdoc-gui-test exist

Hmm. By looking to the code, I don't know why it works on your side :)

@klensy
Copy link
Contributor

klensy commented Jun 12, 2023

fd0a331:

python x.py clean
python x.py --stage=1 --jobs=4 test tests/ui/

Still the same, dots perfectly printed one by one.

tests

@onur-ozkan
Copy link
Member Author

onur-ozkan commented Jun 12, 2023

Still the same, dots perfectly printed one by one.

try x test rustdoc-gui

@klensy
Copy link
Contributor

klensy commented Jun 12, 2023

Still the same, dots perfectly printed one by one.

try x test rustdoc-gui

Ughh, under windows here multiple issues which prevents this run. Fixed some of them, but looks like browser-ui-test still broken in some way.

@bors
Copy link
Collaborator

bors commented Jun 12, 2023

⌛ Testing commit 6c966dc with merge b963a57...

@klensy
Copy link
Contributor

klensy commented Jun 12, 2023

Ok, it print dots for ./x.ps1 test rustdoc-gui all at once, but for other tests it already worked.

@bors
Copy link
Collaborator

bors commented Jun 12, 2023

☀️ Test successful - checks-actions
Approved by: clubby789
Pushing b963a57 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jun 12, 2023
@bors bors merged commit b963a57 into rust-lang:master Jun 12, 2023
@rustbot rustbot added this to the 1.72.0 milestone Jun 12, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (b963a57): 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

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.6% [3.6%, 3.6%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.7% [-2.7%, -2.7%] 1
All ❌✅ (primary) 3.6% [3.6%, 3.6%] 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: 647.661s -> 649.999s (0.36%)

@onur-ozkan onur-ozkan deleted the gtfx branch June 12, 2023 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

7 participants