-
Notifications
You must be signed in to change notification settings - Fork 28
Add libtest JSON emitter #316
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 libtest JSON emitter #316
Conversation
The PR is currently broken as I am trying to figure out how to integrate the emitter in There are also no tests at the moment. |
Oli, could you advise on how to write tests for this PR? I was looking into
And from here on, I have no idea what is going on. I don't seem to find any expected output or oracles... |
I struggled with testing and ended up copying and adapting
|
ui_test::error_on_output_conflict | ||
}, | ||
bless_command: Some("cargo test".to_string()), | ||
..Config::rustc("tests/actual_tests") |
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.
instead of copying the basic test suite, use a path here pointing to the already existing test suite
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.
How did I not think of this ... will do!
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.
Done.
There are however issues with building the auxiliary files in basic
and basic-fail
. I still need to investigate.
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.
That may just be my whacky test setup. So if there is too much trouble I'll check out your PR locally and fix it myself.
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.
I wasn't able to figure out what the source of the auxiliary file build failure is, so I could use your help Oli.
I also noticed something else - the diffing portion of the testing seems to have a character limit. This was cutting off the terminating JSON brace among other things, and I thought that there was a general issue with the escaping. Here is what I observed:
How do you want me to handle this?
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.
hmmm I see it. Maybe this is sth similar to #308 At least we have a test now 😆
please run rustfmt and clippy ( I think the reason you see some output twice is that e.g. for |
src/status_emitter/json.rs
Outdated
String::new() | ||
}; | ||
|
||
emit_test_end(&self.name, &status, &error_output); |
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.
the revision and the path are not part of the json, so you are getting duplicate messages. I'm ok with putting all of this into the name like format!("{name}({revision}): {path}")
or sth. Usually when the revision is an empty string we don't print it at all (like not even empty parentheses).
My preferred solution would be extra fields in the json, but I understand that this is suboptimal due to none of the json tooling consuming revision and path information yet.
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.
Note that I treat the path of the test as the name of the test. In addition, when creating a TestStatus
, the revision is an empty string.
Is there a better way of obtaining the name and revision of a test?
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.
You are already tracking it correctly in for_revision and
for_path. So I think you just need to print it as part of the name
bonus points if you don't need any duplication but can make it work by adding |
This is just a random idea that I don't know if it will work. Just adjusting the path but duplicating the test is fine by me |
Oli, I think the PR is in good shape. There are a couple of outstanding issues which break testing:
|
This PR adds a status emitter which outputs the libtest JSON format, as specified in `library/test/src/formatters/json.rs`. Issue: oli-obk#315
a5c6253
to
430a334
Compare
I think we can ignore that.
yea there was some weird stuff going on. I just merged the json tests into the regular test suite and that seems to have done the trick |
windows path escaping again 💀 I'll merge the PR without windows and fix it on main on my windows machine |
Thanks for bearing with me through all the change requests! I wanted a json backend for a while. On that note, I assume bogus (unknown to you) json messages or extraneous json fields don't matter to you, right? So I can just add stuff even if you are an active consumer that will suddenly see more json than they need? |
Are you kidding, it was a pleasure! I learned a lot in the process, in fact, thank you very much for keeping with my Rust inadequacies!
I think we should be fine. 👌 |
This PR adds a status emitter which outputs the libtest JSON format, as specified in
library/test/src/formatters/json.rs
.fixes #315
TODO (check if already done)