Commit Graph

250 Commits

Author SHA1 Message Date
Aleksey Kladov f7be59c593 Introduce expect snapshot testing library into rustc
Snapshot testing is a technique for writing maintainable unit tests.
Unlike usual `assert_eq!` tests, snapshot tests allow
to *automatically* upgrade expected values on test failure.
In a sense, snapshot tests are inline-version of our beloved
UI-tests.

Example:

![expect](https://user-images.githubusercontent.com/1711539/90888810-3bcc8180-e3b7-11ea-9626-d06e89e1a0bb.gif)

A particular library we use, `expect_test` provides an `expect!`
macro, which creates a sort of self-updating string literal (by using
`file!` macro). Self-update is triggered by setting `UPDATE_EXPECT`
environmental variable (this info is printed during the test failure).
This library was extracted from rust-analyzer, where we use it for
most of our tests.

There are some other, more popular snapshot testing libraries:

* https://github.com/mitsuhiko/insta
* https://github.com/aaronabramov/k9

The main differences of `expect` are:

* first-class snapshot objects (so, tests can be written as functions,
  rather than as macros)
* focus on inline-snapshots (but file snapshots are also supported)
* restricted feature set (only `assert_eq` and `assert_debug_eq`)
* no extra runtime (ie, no `cargo insta`)

See https://github.com/rust-analyzer/rust-analyzer/pull/5101 for a
an extended comparison.

It is unclear if this testing style will stick with rustc in the long
run. At the moment, rustc is mainly tested via integrated UI tests.
But in the library-ified world, unit-tests will become somewhat more
important (that's why use use `rustc_lexer` library-ified library as
an example in this PR). Given that the cost of removal shouldn't be
too high, it probably makes sense to just see if this flies!
2020-08-24 15:38:42 +02:00
Eric Huss 73b7a04032 Fix crate-version with rustdoc in bootstrap. 2020-08-14 14:50:18 -07:00
Eric Huss ce717476ff Add a script to verify the Platform Support page is up-to-date. 2020-08-12 08:40:22 -07:00
Vadim Petrochenkov d3277b927a compiletest: Support ignoring tests requiring missing LLVM components 2020-08-02 20:35:24 +03:00
Ralf Jung 1a2208afc5 update Miri 2020-07-30 19:05:21 +02:00
mark 856f68fa14 reenable tests after moving std 2020-07-28 13:03:59 -05:00
mark 2c31b45ae8 mv std libs to library/ 2020-07-27 19:51:13 -05:00
bors 47ea6d90b0 Auto merge of #74091 - richkadel:llvm-coverage-map-gen-4, r=tmandry
Generating the coverage map

@tmandry @wesleywiser

rustc now generates the coverage map and can support (limited)
coverage report generation, at the function level.

Example commands to generate a coverage report:
```shell
$ BUILD=$HOME/rust/build/x86_64-unknown-linux-gnu
$ $BUILD/stage1/bin/rustc -Zinstrument-coverage \
$HOME/rust/src/test/run-make-fulldeps/instrument-coverage/main.rs
$ LLVM_PROFILE_FILE="main.profraw" ./main
called
$ $BUILD/llvm/bin/llvm-profdata merge -sparse main.profraw -o main.profdata
$ $BUILD/llvm/bin/llvm-cov show --instr-profile=main.profdata main
```
![rust coverage report only 20200706](https://user-images.githubusercontent.com/3827298/86697299-1cbe8f80-bfc3-11ea-8955-451b48626991.png)

r? @wesleywiser

Rust compiler MCP rust-lang/compiler-team#278
Relevant issue: #34701 - Implement support for LLVMs code coverage instrumentation
2020-07-19 07:25:18 +00:00
Rich Kadel a6f8b8a211 Generating the coverage map
rustc now generates the coverage map and can support (limited)
coverage report generation, at the function level.

Example:

$ BUILD=$HOME/rust/build/x86_64-unknown-linux-gnu
$ $BUILD/stage1/bin/rustc -Zinstrument-coverage \
$HOME/rust/src/test/run-make-fulldeps/instrument-coverage/main.rs
$ LLVM_PROFILE_FILE="main.profraw" ./main
called
$ $BUILD/llvm/bin/llvm-profdata merge -sparse main.profraw -o main.profdata
$ $BUILD/llvm/bin/llvm-cov show --instr-profile=main.profdata main
    1|      1|pub fn will_be_called() {
    2|      1|    println!("called");
    3|      1|}
    4|       |
    5|      0|pub fn will_not_be_called() {
    6|      0|    println!("should not have been called");
    7|      0|}
    8|       |
    9|      1|fn main() {
   10|      1|    let less = 1;
   11|      1|    let more = 100;
   12|      1|
   13|      1|    if less < more {
   14|      1|        will_be_called();
   15|      1|    } else {
   16|      1|        will_not_be_called();
   17|      1|    }
   18|      1|}
2020-07-17 11:49:35 -07:00
Jake Goulding e2b337dc57 Teach bootstrap about target files vs target triples
`rustc` allows passing in predefined target triples as well as JSON
target specification files. This change allows bootstrap to have the
first inkling about those differences. This allows building a
cross-compiler for an out-of-tree architecture (even though that
compiler won't work for other reasons).

Even if no one ever uses this functionality, I think the newtype
around the `Interned<String>` improves the readability of the code.
2020-07-17 10:08:04 -04:00
Eric Huss 26353eae4c Fix x.py test for librustc crates. 2020-07-08 08:52:48 -07:00
Tomasz Miąsko 5fa19ad2bb Remove unused RUSTC_DEBUG_ASSERTIONS
Since #73374 the rustc wrapper no longer configures debug assertions
based on RUSTC_DEBUG_ASSERTIONS environment variable.
2020-07-06 00:16:12 +02:00
Eric Huss 9154863647 Compile rustdoc less often. 2020-06-29 22:35:02 -07:00
Eric Huss 75983e137e Support configurable deny-warnings for all in-tree crates. 2020-06-25 21:17:21 -07:00
Aaron Hill d3feb8baaf
Re-enable Clippy tests 2020-06-22 12:46:29 -04:00
Ralf Jung 61c8925310
Rollup merge of #73352 - ehuss:bootstrap-metadata, r=Mark-Simulacrum
Speed up bootstrap a little.

The bootstrap script was calling `cargo metadata` 3 times (or 6 with `-v`). This is a very expensive operation, and this attempts to avoid the extra calls. On my system, a simple command like `./x.py test -h -v` goes from about 3 seconds to 0.4.

An overview of the changes:

- Call `cargo metadata` only once with `--no-deps`. Optional dependencies are filtered in `in_tree_crates` (handling `profiler_builtins` and `rustc_codegen_llvm` which are driven by the config).
- Remove a duplicate call to `metadata::build` when using `-v`. I'm not sure why it was there, it looks like a mistake or vestigial from previous behavior.
- Remove check for `_shim`, I believe all the `_shim` crates are now gone.
- Remove check for `rustc_` and `*san` for `test::Crate::should_run`, these are no longer dependencies in the `test` tree.
- Use relative paths in `./x.py test -h -v` output.
- Some code cleanup (remove unnecessary `find_compiler_crates`, etc.).
- Show suite paths (`src/test/ui/...`) in `./x.py test -h -v` output.
- Some doc comments.
2020-06-19 14:29:35 +02:00
Mark Rousskov 399bf383f4 Disable clippy tests 2020-06-15 13:57:55 -04:00
Ralf Jung fb75d4a746
Rollup merge of #73296 - ehuss:remove-msvc-aux, r=Mark-Simulacrum
Remove vestigial CI job msvc-aux.

This CI job isn't really doing anything, so it seems prudent to remove it.

For some history:
* This was introduced in #48809 when the msvc job was split in two to keep it under 2 hours (oh the good old days). At the time, this check-aux job did a bunch of things:
    * tidy
    * src/test/pretty
    * src/test/run-pass/pretty
    * src/test/run-fail/pretty
    * src/test/run-pass-valgrind/pretty
    * src/test/run-pass-fulldeps/pretty
    * src/test/run-fail-fulldeps/pretty
* Tidy was removed in #60777.
* run-pass and run-pass-fulldeps moved to UI in #63029
* src/test/pretty removed in #58140
* src/test/run-fail moved to UI in #71185
* run-fail-fulldeps removed in #51285

Over time through attrition, the job was left with one lonely thing: `src/test/run-pass-valgrind/pretty`. And of course, this wasn't actually running the "pretty" tests. The normal `run-pass-valgrind` tests ran, and then when it tried to run in "pretty" mode, all the tests were ignored because compiletest thought nothing had changed (apparently compiletest isn't fingerprinting the mode?  Needs more investigation…). `run-pass-valgrind` is already being run as part of `x86_64-msvc-1`, so there's no need to run it here.

I've taken the liberty of removing `src/test/run-pass-valgrind/pretty` as a distinct test. I'm guessing from the other PR's that the pretty tests should now live in `src/test/pretty`, and that the team has moved away from doing pretty tests on other parts of the `src/test` tree.
2020-06-15 12:01:11 +02:00
Eric Huss 607e85110e Switch bootstrap metadata to --no-deps.
This should run much faster.

There are also some drive-by cleanups here to try to simplify things.
Also, the paths for in-tree crates are now displayed as relative
in `x.py test -h -v`.
2020-06-14 15:57:21 -07:00
Eric Huss 0687b78d56 Speed up bootstrap a little. 2020-06-13 10:29:56 -07:00
Eric Huss c0aef6d816 Remove vestigial CI job msvc-aux. 2020-06-12 14:17:42 -07:00
Eric Huss 57b54c4928 Use the built cargo for cargotest. 2020-06-11 18:28:13 -07:00
Mark Rousskov 6f015768c2 Try_run must only be used if toolstate is populated
Clippy's tests were failing the build, but that failure was ignored in favor of
checking toolstate. This is the correct behavior for toolstate-checked tools,
but Clippy no longer updates its toolstate status as it should always build.
2020-06-07 10:05:27 -04:00
bors eeaf497b2a Auto merge of #72672 - seritools:remote-test-windows, r=Mark-Simulacrum
Make remote-test-client and remote-test-server compatible with windows

`compiletest` and `remote-test-client`:

The command line for `remote-test-client` was changed slightly to allow cross-platform compatible paths. The old way of supplying the support libs was by joining their paths with the executable path
with `:`. This caused Windows-style paths to be split after the directory letter. Now, the number of support libs is provided as a parameter as well, and the support lib paths are split off from the regular args in the client.

`remote-test-server`:

- Marked Unix-only parts as such and implemented Windows alternatives
- On Windows `LD_LIBRARY_PATH` doesn't exist. Libraries are loaded from `PATH` though, so that's the way around it.
- Tiny cleanup: `Command::args`/`envs` instead of manually looping over them
- The temp path for Windows has to be set via environment variable, since there isn't a global temp directory that would work on every machine (as a static string)
2020-06-02 07:54:38 +00:00
Ralf Jung 759e495bbf bump Miri, update for cargo-miri being a separate project 2020-06-01 20:17:26 +02:00
Dennis Duda 036da3a6dc Make `remote-test-client` work as cargo runner again
Since cargo appends executable/args, the support_lib count
parameter has to come first.
2020-05-31 17:36:17 +02:00
Mark Rousskov b1063b83da Clippy should always build
This just unwraps clippy's build step instead of skipping tests if clippy didn't
build. This matches e.g. cargo's behavior and seems more correct, as we always
expect clippy to successfully build.
2020-05-27 17:25:47 -04:00
Ralf Jung 7a121ad77f bootstrap: propagate test-args to miri and clippy test suites 2020-05-24 09:45:14 +02:00
bors 23ffeea307 Auto merge of #72058 - RalfJung:no-dist-lldb, r=Mark-Simulacrum
bootstrap: remove lldb dist packaging

The lldb-preview rustup package is missing on every single target, and has never been shipped beyond x86_64-apple-darwin. It was removed in #62592 which landed around a year ago, and there's not been demand that we re-enable it since, so we're now removing support entirely to cleanup the code a bit.

The hope is that this will also kill the useless "lldb-preview" row on https://rust-lang.github.io/rustup-components-history/.
2020-05-14 02:50:34 +00:00
Ralf Jung 42f70d503b update miri some more 2020-05-11 12:13:53 +02:00
Ralf Jung dc7524be27 remove lldb package from bootstrap, config and build-manifest
it's not been built since a long time ago
2020-05-10 22:43:58 +02:00
Yuki Okushi 82cb88b777
Remove code related to `test/run-fail` 2020-05-06 14:03:00 +09:00
Oliver Scherer 675b585931 Remove clippy from some leftover lists of "possibly failing" tools 2020-05-03 11:40:45 +02:00
Oliver Scherer a1824505d8 Gate on clippy on CI 2020-05-02 09:46:42 +02:00
Nicholas Nethercote a105c5c2c0 Build libstd with `-Cbitcode-in-rlib=yes`.
So that the rlibs will work with both LTO and non-LTO builds.
2020-04-22 15:22:18 +10:00
Guillaume Gomez 426055cb29 Improve rustdoc js testers code 2020-04-14 13:40:11 +02:00
Guillaume Gomez d6b75e0ef1 End cleanup on rustdoc-js tools 2020-04-11 16:32:28 +02:00
bors 853c4774e2 Auto merge of #69898 - spastorino:rename-rustc-guide2, r=Xanewok
Move rustc-guide submodule to rustc-dev-guide

r? @pietroalbini
2020-04-04 18:17:14 +00:00
Josh Stone 6067315d58 Ensure LLVM is in the link path for "fulldeps" tests
This is a follow-up to #70123, which added `llvm-config --libdir` to the
`LIBRARY_PATH` for rustc tools. We need the same for "run-make-fulldeps"
and "ui-fulldeps" tests which depend on compiler libraries, implicitly
needing to link to `-lLLVM` as well.
2020-03-30 15:40:56 -07:00
Santiago Pastorino 4387a8b96e
Move rustc-guide submodule to rustc-dev-guide 2020-03-24 15:38:53 -03:00
bors 2dcf54f564 Auto merge of #70190 - pietroalbini:gha, r=Mark-Simulacrum
Add GitHub Actions configuration

This PR adds the GitHub Actions configuration to the rust-lang/rust repository. The configuration will be run in parallel with Azure Pipelines until the evaluation finishes: the infrastructure team will then decide whether to switch.

Since GitHub Actions doesn't currently have any way to include pieces of configuration, this also adds the `src/tools/expand-yaml-anchors` tool, which serves as a sort of templating system. Otherwise the configuration is a mostly straight port from the Azure Pipelines configuration (thanks to all the PRs opened in the past).

There are still a few small things I need to fix before we can land this, but it's mostly complete and ready for an initial review.

r? @Mark-Simulacrum
2020-03-24 15:49:27 +00:00
Pietro Albini 9beb8f5477
ci: add github actions configuration 2020-03-24 15:36:07 +01:00
Nikita Popov 841558d3bd Remove trailing newline from llvm-config output 2020-03-19 20:09:57 +01:00
Mazdak Farrokhzad 61fe2e4036
Rollup merge of #69443 - ehuss:tidy-license, r=skade,Mark-Simulacrum
tidy: Better license checks.

This implements some improvements to the license checks in tidy:

* Use `cargo_metadata` instead of parsing vendored crates. This allows license checks to run without vendoring enabled, and allows the checks to run on PR builds.
* Check for stale entries.
* Check that the licenses for exceptions are what we think they are.
* Verify exceptions do not leak into the runtime.

Closes #62618
Closes #62619
Closes #63238 (I think)

There are some substantive changes here. The follow licenses have changed from the original comments:

* openssl BSD+advertising clause to Apache-2.0
* pest MPL2 to MIT/Apache-2.0
* smallvec MPL2 to MIT/Apache-2.0
* clippy lints MPL2 to MIT OR Apache-2.0
2020-03-19 06:57:30 +01:00
Oliver Middleton 3f58ab6e24 Allow `rustdoc-js` and `rustdoc-js-std` to use none default build dir location 2020-03-13 23:24:12 +00:00
Eric Huss 349fcb9ef6 tidy: Use cargo_metadata for license checks. 2020-03-12 19:19:18 -07:00
Ralf Jung 0a6f45e2e5 point cargo-miri to the right xargo binary 2020-03-04 10:31:00 +01:00
Ralf Jung 1a0e2001bc fix miri and bootstrap interaction 2020-02-21 20:45:16 +01:00
bors 7760cd0fbb Auto merge of #69293 - Dylan-DPC:rollup-imcbvgo, r=Dylan-DPC
Rollup of 5 pull requests

Successful merges:

 - #68863 (ci: switch macOS builders to 10.15)
 - #69142 (Add shared script for linkchecking books.)
 - #69248 (Don't eliminate frame pointers on thumb targets)
 - #69280 (Remove special case for `simd_shuffle` arg promotion)
 - #69284 (Reword OpenOptions::{create, create_new} doc.)

Failed merges:

r? @ghost
2020-02-19 19:10:58 +00:00
bors 7d6b8c414e Auto merge of #69198 - ollie27:rustbuild_rustdoc-js, r=Mark-Simulacrum
Fix running rustdoc-js test suite individually

Without `Compiletest.path` set running `x.py test src/test/rustdoc-js` would run the `rustdoc-js` test suite with everything filtered out.

As this was the only place setting `Compiletest.path` to `None` this removes the `Option` wrapper as well.
2020-02-19 15:55:57 +00:00