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

document the test infrastructure #47

Merged
merged 10 commits into from
Feb 17, 2018

Conversation

nikomatsakis
Copy link
Contributor

@nikomatsakis nikomatsakis commented Feb 7, 2018

cc #10

This content is mostly taken from the COMPILER_TESTS.md in the compiler source tree, but I added some more notes.

file, typically a Rust source file. Test files have a particular
structure:

- They always begin with the copyright notice;

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!

Copy link
Contributor Author

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.

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

# 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
Copy link

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

Copy link
Member

@mark-i-m mark-i-m left a 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.

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
Copy link
Member

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?

Copy link
Member

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

Copy link
Contributor Author

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

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
Copy link
Member

Choose a reason for hiding this comment

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

"that the optimizations"

Copy link
Member

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."

- `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
Copy link
Member

Choose a reason for hiding this comment

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

nit: "optimizing, etc."

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.
Copy link
Member

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.

- `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
Copy link
Member

Choose a reason for hiding this comment

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

nit: "entities, etc."

...
```

Please see `ui/transmute/main.rs` and `.stderr` for a concrete usage example.
Copy link
Member

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?


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,
Copy link
Member

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?

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
Copy link
Member

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
Copy link
Member

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?

**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.,
Copy link
Member

Choose a reason for hiding this comment

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

??

**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.,
Copy link
Contributor

Choose a reason for hiding this comment

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

This statement seems incomplete.

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
Copy link
Contributor

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?

@ehuss
Copy link
Contributor

ehuss commented Feb 7, 2018

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.

@mark-i-m
Copy link
Member

mark-i-m commented Feb 7, 2018

@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.

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.

Don't worry too much about this. I also don't know that much (except about macro parsing :P). Any help is appreciated!

@mark-i-m
Copy link
Member

mark-i-m commented Feb 7, 2018

@nikomatsakis I thought of a couple of other things that we could mention here:

  • crater: what is it and why is it useful? What kinds of changes need a crater run?
  • tidy

@QuietMisdreavus
Copy link
Member

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 htmldocck.py. That's the best documentation for rustdoc tests at this point, and i'd like to bring it out of the test script.

@mark-i-m
Copy link
Member

mark-i-m commented Feb 7, 2018

@QuietMisdreavus That's sounds great! Is there a reason why it must be done after this PR merges?

@QuietMisdreavus
Copy link
Member

QuietMisdreavus commented Feb 7, 2018

@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.

@mark-i-m
Copy link
Member

mark-i-m commented Feb 7, 2018

@QuietMisdreavus Got it :D

@ehuss
Copy link
Contributor

ehuss commented Feb 8, 2018

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.

  • More discussion of the testing infrastructure. In particular, bors/homu, travis/appveyor, platform emulation, etc.
  • At least briefly mention the other tests that get run, such as:
    • Unittests. In particular, how to run individual tests, roughly which libraries are automatically tested, etc. So far the guide seems to focus on just the tests in the test/ directory.
    • Doctests. How to run the doc tests in the standard library. Other doc testing steps like linkchecker.
    • distcheck
    • tidy
    • Mention that tests also get run for individual packages, such as bootstrap, cargo, rls, rustfmt, miri, clippy, cargotest.
  • crater/cargobomb?
  • Is fuzzing in active use by the team?
  • How does performance testing enter the picture?

(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
Copy link
Member

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 nikomatsakis mentioned this pull request Feb 12, 2018
20 tasks
@mark-i-m mark-i-m added the S-waiting-on-author Status: this PR is waiting for additional action by the OP label Feb 15, 2018
@mark-i-m
Copy link
Member

@nikomatsakis Ping :)

@nikomatsakis
Copy link
Contributor Author

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.

@nikomatsakis
Copy link
Contributor Author

Things I did not do (I will add them to the main issue, they seem like good follow-up):

  • crater: what is it and why is it useful? What kinds of changes need a crater run?
    • maybe talk about "perf runs" too
  • rustdoc tests
  • these things

@nikomatsakis
Copy link
Contributor Author

I added those to the issue.

Copy link
Member

@mark-i-m mark-i-m left a 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.
Copy link
Member

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).

Copy link
Contributor Author

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mark-i-m mark-i-m mentioned this pull request Feb 17, 2018
8 tasks
@mark-i-m mark-i-m merged commit c7c80ab into rust-lang:master Feb 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: this PR is waiting for additional action by the OP
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants