-
Notifications
You must be signed in to change notification settings - Fork 541
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
document the test infrastructure #47
Conversation
beb2d89
to
679f76f
Compare
src/tests/adding.md
Outdated
file, typically a Rust source file. Test files have a particular | ||
structure: | ||
|
||
- They always begin with the copyright notice; |
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.
Maybe it would be useful to link the copyright notice here!
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.
ugh. I just wish it didn't exist. But I suppose you are right.
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.
@nikomatsakis I totally understand your pain
src/tests/adding.md
Outdated
# Adding new tests | ||
|
||
**In general, we expect every PR that fixes a bug in rustc to come | ||
accompanied with a regression test of some kind.** This test should |
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.
Super nitpicky, but "accompanied by" is more common. 🤓
https://ell.stackexchange.com/a/109564
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.
Thanks! This is a great chapter :)
I left a bunch of comments. Most are nits and minor suggestions.
src/tests/intro.md
Outdated
they mean. In some cases, the test suites are linked to parts of the manual | ||
that give more details. | ||
|
||
- [`ui`](ui.html) -- tests that check the exact stdout/stderr from compilation |
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.
Where is this file? How is this passing CI?
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.
Also, would it be possible to create an Appendix and add this file to it? We could also add the ParamEnv
mini-chapter from #45
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.
link was wrong, fixed, not sure about the CI question tho
src/tests/intro.md
Outdated
generates valid Rust code from the AST | ||
- `debuginfo` -- tests that run in gdb or lldb and query the debug info | ||
- `codegen` -- tests that compile and then test the generated LLVM | ||
code to make sure that optimizing we want are kicking in etc |
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 the optimizations"
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.
Also, nit: "kicking in, etc."
src/tests/intro.md
Outdated
- `debuginfo` -- tests that run in gdb or lldb and query the debug info | ||
- `codegen` -- tests that compile and then test the generated LLVM | ||
code to make sure that optimizing we want are kicking in etc | ||
- `mir-opt` -- tests that check parts of the generated MIR to make sure we are optimizing |
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.
nit: "optimizing, etc."
src/tests/intro.md
Outdated
when certain modifications are performed, we are able to reuse the | ||
results from previous compilations. | ||
- `run-make` -- tests that basically just execute a `Makefile`; the ultimate in flexibility | ||
but annoying as all get out to write. |
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.
This sentence does not make sense to me.
src/tests/intro.md
Outdated
- `run-make` -- tests that basically just execute a `Makefile`; the ultimate in flexibility | ||
but annoying as all get out to write. | ||
- `rustdoc` -- tests for rustdoc, making sure that the generated files contain | ||
documentation for various entities etc |
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.
nit: "entities, etc."
src/tests/adding.md
Outdated
... | ||
``` | ||
|
||
Please see `ui/transmute/main.rs` and `.stderr` for a concrete usage example. |
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.
Can we link to github here?
src/tests/adding.md
Outdated
|
||
The UI tests are intended to capture the compiler's complete output, | ||
so that we can test all aspects of the presentation. They work by | ||
compiling a file (e.g., `ui/hello_world/main.rs`), capturing the 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.
Perhaps link to github here?
src/tests/adding.md
Outdated
We have not traditionally had a lot of structure in the names of | ||
tests. Moreover, for a long time, the rustc test runner did not | ||
support subdirectories (it now does), so test suites like | ||
`src/test/run-pass` have a huge mess of files in them. This is not |
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.
Perhaps link to github?
@@ -0,0 +1,273 @@ | |||
# Adding new 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.
One thing I think would be nice to add to this chapter is some sort of heuristic for what type of tests to prefer. For example, should I prefer adding a parse-fail, compile-fail, or ui test, when any of them could test what I want to test?
src/tests/running.md
Outdated
**Warning:** Note that bors only runs the tests with the full stage 2 | ||
build; therefore, while the tests **usually** work fine with stage 1, | ||
there are some limitations. In particular, `./x.py test --stage 1` | ||
(ie., |
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.
??
src/tests/running.md
Outdated
**Warning:** Note that bors only runs the tests with the full stage 2 | ||
build; therefore, while the tests **usually** work fine with stage 1, | ||
there are some limitations. In particular, `./x.py test --stage 1` | ||
(ie., |
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.
This statement seems incomplete.
src/tests/intro.md
Outdated
they mean. In some cases, the test suites are linked to parts of the manual | ||
that give more details. | ||
|
||
- [`ui`](ui.html) -- tests that check the exact stdout/stderr from compilation |
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'm confused, what does this link to?
Thanks @nikomatsakis, I find this very useful! There also seems to be some additional information captured at https://brson.github.io/2017/07/10/how-rust-is-tested that may be useful. I was wondering if some of that can maybe be brought over? I can help if desired, but my perspective is from someone who knows very little about how things work (other than reading this), so I'm uncertain if I'm qualified. |
@ehuss I also really like that blog post. I think the main concern is how to not plagiarize it... One idea would be to just mention it as a further reference.
Don't worry too much about this. I also don't know that much (except about macro parsing :P). Any help is appreciated! |
@nikomatsakis I thought of a couple of other things that we could mention here:
|
Whenever this lands, i'd like to add a chapter talking about the things specific to the rustdoc tests. If you'd like, you can crib some initial content from the header of |
@QuietMisdreavus That's sounds great! Is there a reason why it must be done after this PR merges? |
@mark-i-m Because i wanted to be the one to write it. 😜 I suppose i could make it a PR-to-the-PR, but i don't want to hold up this PR with extra content. EDIT: Also, because this PR changes the folder structure, and i want to make a new file within that new folder. |
@QuietMisdreavus Got it :D |
Here are some other test-related things that might be useful to have. Perhaps they could be added as separate PRs? This guide seems to be very focused on the core of the compiler, so I'm uncertain how much you want it to talk about testing the standard library, and the tools and components that surround the compiler.
|
src/tests/running.md
Outdated
(the same one you get with `#[test]`), so this command would wind up | ||
filtering for tests that include "issue-1234" in the name. | ||
|
||
Often, though, it's easier to just run the test by hand. More tests are |
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 guess this should be 'Most tests'?
@nikomatsakis Ping :) |
Hi =) Yes, I meant to do this last week, but stuff got away from me. Gonna take a crack at addressing the feedback right now. |
679f76f
to
c9f7e5e
Compare
Things I did not do (I will add them to the main issue, they seem like good follow-up):
|
I added those to the issue. |
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.
@nikomatsakis LGTM! Thanks!
I had a quick question about when to add dependencies from crates.io, but I think we can merge and discuss that on the tracking issue.
It is allowed to use crates from crates.io, though external | ||
dependencies should not be added gratuitously. All such crates must | ||
have a suitably permissive license. There is an automatic check which | ||
inspects the Cargo metadata to ensure 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.
Is there some sort of vetting that is done? Obviously, we don't want rustc's dependencies to explode and we don't want low-quality crates (or even malicious code).
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.
There is not. There maybe should be.
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.
cc #10
This content is mostly taken from the
COMPILER_TESTS.md
in the compiler source tree, but I added some more notes.