-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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 UI testing framework #33588
add UI testing framework #33588
Conversation
6499374
to
cc19830
Compare
fn compare_output(&self, kind: &str, actual: &[u8], expected: &[u8]) -> usize { | ||
if self.config.verbose { | ||
println!("normalized {}:\n{}\n", kind, str::from_utf8(actual).unwrap_or("not utf8")); | ||
println!("expected {}:\n{}\n", kind, str::from_utf8(expected).unwrap_or("not utf8")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May be worth using String::from_utf8_lossy
instead of "not uf8" on invalid utf-8
It is possible to create a console screen buffer, redirect rustc to that, and then read the output including all the color attributes. A bit complicated, but nonetheless very much possible. |
Nice! Some thoughts:
I'd personally want to get rustbuild running these tests as well as printing the actual/expected on failure, but other than that the remaining pieces seem like they're nice-to-have and we can add later. Having a script to blanket overwrite all the previous output may also be a bit heavy-handed? In theory these shouldn't be too hard to run by hand, right? I'd just be worried that having these scripts checked in makes it "too easy" to blanket change the rustc output without thinking much. |
I may try to at least get diffs of the output working.
I agree those are necessary.
This was sort of the goal =) I figured we'd make it easy to update, then use review + git diff to check the results.
Cool. Nonetheless, after discussing with @jonathandturner and @alexcrichton, we were thinking we'd just move all color checking to operate at a more semantic level rather than using this framework (i.e., if we get more "presentation" info in the JSON as discussed here, we can check that this is as expected, and then we'll just trust that the translation to ANSI/Windows goes swimmingly). |
@nikomatsakis all sounds good to me! |
@alexcrichton ok, I did the following:
I chose not to:
|
@@ -111,6 +111,8 @@ macro_rules! targets { | |||
(check_pfail, CheckPFail { compiler: Compiler<'a> }), | |||
(check_codegen, CheckCodegen { compiler: Compiler<'a> }), | |||
(check_codegen_units, CheckCodegenUnits { compiler: Compiler<'a> }), | |||
(check_incremental, CheckIncremental { compiler: Compiler<'a> }), | |||
(check_ui, CheckUi { compiler: Compiler<'a> }), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you be sure to add these to the blanket Check
target below?
Looks good to me! Just one minor nit and otherwise r=me |
5f73f52
to
3ff521b
Compare
@bors r=alexcrichton |
📌 Commit 3ff521b has been approved by |
⌛ Testing commit 3ff521b with merge 9c87f71... |
⛄ The build was interrupted to prioritize another pull request. |
⌛ Testing commit 3ff521b with merge 9bbfe4d... |
💔 Test failed - auto-linux-64-opt-rustbuild |
This failed tidy. |
@bors r=alexcrichton |
📌 Commit 474eb38 has been approved by |
474eb38
to
24cfa1e
Compare
@bors r=acrichto |
📌 Commit 24cfa1e has been approved by |
add UI testing framework This adds a framework for capturing and tracking the precise output of rustc, which allows us to check all manner of minor details with the output. It's pretty strict right now -- the output must match almost exactly -- and hence maybe a bit too strict. But I figure we can add wildcards or whatever later. There is also a script intended to make updating the references easy, though the script could make things a *bit* easier (in particular, it'd be nice if it would find the build directory for you automatically). One thing I was wondering about is the best way to test colors. Since windows doesn't embed those in the output stream, this test framework can't test colors on windows -- so I figure we can just write tests that are ignored on windows and which pass `--color=always` or whatever to rustc. cc @jonathandturner r? @alexcrichton
This adds a framework for capturing and tracking the precise output of rustc, which allows us to check all manner of minor details with the output. It's pretty strict right now -- the output must match almost exactly -- and hence maybe a bit too strict. But I figure we can add wildcards or whatever later. There is also a script intended to make updating the references easy, though the script could make things a bit easier (in particular, it'd be nice if it would find the build directory for you automatically).
One thing I was wondering about is the best way to test colors. Since windows doesn't embed those in the output stream, this test framework can't test colors on windows -- so I figure we can just write tests that are ignored on windows and which pass
--color=always
or whatever to rustc.cc @jonathandturner
r? @alexcrichton