Commit graph

77 commits

Author SHA1 Message Date
Scott Schafer 8ff8eaa496 add a note that some warnings can be auto-fixed 2022-10-27 19:07:59 -05:00
Scott Schafer 8625d7274a fix(cargo): Add a warning on [project] table being used in a manifest 2022-09-26 10:32:48 -06:00
Scott Schafer cabee4f511 fix(cargo): Add a warning on package and project in the same Cargo.toml 2022-09-26 10:32:07 -06:00
Scott Schafer ab18bd40d5 refactor(testsuite): Replace [project] with [package] 2022-09-26 09:51:16 -06:00
Eric Huss 8a487abedd Make the empty rustc-wrapper test more explicit. 2022-07-24 13:10:35 -07:00
Scott Schafer c239e407e7 add a reason to masquerade_as_nightly_cargo so it is searchable 2022-07-15 21:32:23 -05:00
Loïc BRANSTETT 2d0ca84b0e Move check cfg tests to their own module 2022-05-06 22:42:28 +02:00
Loïc BRANSTETT 6a9f094c8c Convert the testsuite to use the new -Zcheck-cfg flag and syntax 2022-05-06 22:40:08 +02:00
bors 403c6bd257 Auto merge of #10486 - Urgau:check-cfg-well-known, r=weihanglo
Add support for rustc --check-cfg well known names and values

This pull-request add support for `rustc` `--check-cfg` well known names and values.

### What does this PR try to resolve?

This pull-request add support for `rustc` `--check-cfg` well known names and values:

- `-Z check-cfg-well-known-names`: `--check-cfg names()` well known names
- `-Z check-cfg-well-known-values`: `--check-cfg values()` well known values

### How should we test and review this PR?

#### Testing

`cargo check -Z check-cfg-well-known-names` and
`cargo check -Z check-cfg-well-known-values`

#### Review

This PR contains one commit that split `features_args` into `check_cfg_args`, add the well known support in it, adds call to that new function and add documentation and test for those new flags.

### Additional information

This was implemented as two new additional flags because it's most likely that these flags will not be stabilize at the same time and also because some of these flags may become the default.

RFC: https://github.com/rust-lang/rfcs/pull/3013
`-Z check-cfg-features`: https://github.com/rust-lang/cargo/pull/10408
`cargo doc` support: https://github.com/rust-lang/cargo/pull/10428
2022-04-12 14:36:40 +00:00
David Tolnay 4e45f58852
Unstable --keep-going flag 2022-03-21 18:36:40 -07:00
Loïc BRANSTETT 02cd9442c7 Add support for rustc --check-cfg well known names and values 2022-03-18 22:14:39 +01:00
Loïc BRANSTETT a864c81549 Disable -Z check-cfg-features tests on windows due to weird normalization issues
See https://github.com/rust-lang/cargo/runs/5290789288?check_suite_focus=true
Where the expected is: --check-cfg 'values(feature, "f_a", "f_b")'
But we got: --check-cfg "values(feature, /"f_a/", /"f_b/")"
2022-02-22 18:33:03 +01:00
Loïc BRANSTETT 03fbb2eda8 Add -Z check-cfg-features to enable compile-time checking of features 2022-02-22 16:47:52 +01:00
Joshua Nelson 9c7cc545d7 Combine rustc and cargo's diagnostic summaries
This works by introspecting rustc's error output, using the JSON format
to determine whether it's a warning or error, then skipping it
altogether if it's a summary of the diagnostics printed.

Before:

```
src/main.rs:1:10: warning: trait objects without an explicit `dyn` are deprecated
src/main.rs:1:1: error[E0601]: `main` function not found in crate `wrong`
src/main.rs:1:9: error[E0038]: the trait `Clone` cannot be made into an object
error: aborting due to 2 previous errors; 1 warning emitted
error: could not compile `wrong`

```

After:

```
$ cargo check --message-format short
src/main.rs:1:10: warning: trait objects without an explicit `dyn` are deprecated
src/main.rs:1:1: error[E0601]: `main` function not found in crate `wrong`
src/main.rs:1:9: error[E0038]: the trait `Clone` cannot be made into an object
error: could not compile `wrong` due to 2 previous errors; 1 warning emitted
```
2021-07-06 19:46:27 -04:00
Eric Huss 7b229bbe39 Move the rustc-echo-wrapper to be shared across tests.
This helps avoid rebuilding the same project several times.
2021-06-09 17:13:33 -07:00
Eduardo Broto f838a003f1 Stabilize RUSTC_WORKSPACE_WRAPPER 2020-12-13 23:50:15 +01:00
Weihang Lo 8f0664f02a
test: normalize raw string indentation. 2020-10-10 07:44:57 +08:00
Weihang Lo 5e3dc46753
test: be consistent on error message styles 2020-10-10 06:58:06 +08:00
Weihang Lo 8d5e11a520
test(check): glob support for package selection 2020-10-05 01:24:43 +08:00
Eric Huss 6f8c7d5a87 Normalize raw string indentation. 2020-09-26 17:59:58 -07:00
Camelid 82c834cec2 Update tests 2020-09-07 10:57:00 -07:00
bors 7302186d7b Auto merge of #7533 - yaahc:clippy-banishment, r=ehuss
Close the front door for clippy but open the back
2020-03-14 20:50:15 +00:00
Eric Huss ac79b537e1 Bump to 0.45.0. 2020-03-13 19:31:06 -07:00
Jane Lusby 76797b5c2a switch from bash script to rust program 2020-03-13 14:59:41 -07:00
Jane Lusby b0351e4d87 Close the front door for clippy but open the back 2020-03-12 19:27:48 -07:00
Esteban Küber e0787ec2b3 Modify test to make rustc PR mergeable
Modify a test to be less succeptible to failure for wording changes.
2020-02-12 13:45:09 -08:00
Eduard-Mihai Burtescu 4d3b738a3c test: allow some flexibility in check::error_from_deep_recursion's expected diagnostic. 2020-01-24 18:40:34 +02:00
Eric Huss 83571aee56 Minor testsuite organization. 2019-11-24 18:42:45 -08:00
bors b03182a8ff Auto merge of #7450 - ehuss:stabilize-cache-messages, r=alexcrichton
Stabilize cache-messages

This stabilizes the -Zcache-messages feature, making it always enabled.

## What is stabilized?

This feature is intended to redisplay previous warnings on a "fresh" build instead of displaying no output.

Users have occasionally indicated frustration when they know there are warnings, but no output is displayed when the build is fresh. This also improves the interaction between `cargo check` and `cargo clippy-preview`. This also simplifies the code, and opens more possibilities for `rustc` to send side-channel messages to Cargo.

Cargo will now use JSON output from `rustc` and `rustdoc` 100% of the time (`rustdoc --test` does not use JSON). Previously Cargo would only use JSON for pipelined crates.

Cargo will save the JSON output into a file named `output` in the `.fingerprint` directory. This file is only created when the compiler outputs a diagnostic message.

If a crate is being recompiled, and Cargo considers it to be "fresh", it will replay the output file to the console.

## Notable changes in this PR

- Fixed a bug where replays were erroneously including pipeline rmeta artifact json messages.
- clippy-preview is now included in the metadata hash, to force its artifacts to be separate from `cargo check`.
- clippy-preview is no longer force-enabled, under the assumption that caching and fingerprinting is accurate, and the cached messages will be replayed.
- clippy-preview's arguments are included in the fingerprint now that it is not force-enabled.
- Rustdoc colors and short messages were fixed when pipelining was stabilized, so updated tests.

Closes #6986
Closes #6848
Closes #6664
Closes #2458

## Concerns

The only notable issue with this is that switching between short and long human messages only replays the format from the first invocation.  That is, if you do `cargo build` and it generates warnings, then running again with `--message-format=short` will still show the full length human messages. I'm personally fine with that behavior, even though it is not ideal. I think this feature overall improves the situation (where before *no* output was displayed). Being able to re-render between short/long is a very difficult problem, and unlikely to be fixable in the foreseeable future.

There was some concern expressed about being able to disable this. I think that would only be necessary if a severe bug is discovered. I do not feel that this change is risky enough to warrant a configurable option. If it does cause a problem, it can be quickly reverted with a one-line change to set `OutputOptions::cache_cell` to `None`. Since pipelining has been using JSON output for a while now without complaints, I feel pretty confident in it.
2019-10-15 13:48:13 +00:00
Dan Aloni 9dc70a3dab Rustfmt lint 2019-10-08 11:07:19 +03:00
Dan Aloni e04099e6a3 tests: cover issue #7488 2019-10-08 09:49:25 +03:00
Eric Huss bd73e8dab5 Stabilize cache-messages 2019-09-30 14:04:10 -07:00
Jonas Schievink 26229cd8ad Uncapitalize "Could not compile" error message
"could not compile ..." matches other Cargo and rustc errors and
warnings better.
2019-09-17 00:50:49 +02:00
Alex Crichton 9115b2c326 Extract support directory to its own crate
Extract out all our test support code to its own standalone crate so it
can be shared between multiple test suites if necessary.
2019-09-16 11:47:09 -07:00
k-nasa 7176df01d6 Change --all to --workspace 2019-09-03 17:14:34 -07:00
Vadim Petrochenkov 695931608a Update two tests for changes in rustc output 2019-08-10 01:57:00 +03:00
Jethro Beekman 0e0d968825 Update #[test] attribute on all tests in the testsuite
sed -i 's/^#\[test\]/#[cargo_test]/' $(rg -l '^#\[test\]')

Manual fixes:
* proc_macro::proc_macro_doctest
2019-06-07 12:41:26 -07:00
bors 2e09266f66 Auto merge of #6883 - alexcrichton:pipelining-v2, r=ehuss
Implement the Cargo half of pipelined compilation (take 2)

This commit starts to lay the groundwork for #6660 where Cargo will
invoke rustc in a "pipelined" fashion. The goal here is to execute one
command to produce both an `*.rmeta` file as well as an `*.rlib` file
for candidate compilations. In that case if another rlib depends on that
compilation, then it can start as soon as the `*.rmeta` is ready and not
have to wait for the `*.rlib` compilation.

Initially attempted in #6864 with a pretty invasive refactoring this
iteration is much more lightweight and fits much more cleanly into
Cargo's backend. The approach taken here is to update the
`DependencyQueue` structure to carry a piece of data on each dependency
edge. This edge information represents the artifact that one node
requires from another, and then we a node has no outgoing edges it's
ready to build.

A dependency on a metadata file is modeled as just that, a dependency on
just the metadata and not the full build itself. Most of cargo's backend
doesn't really need to know about this edge information so it's
basically just calculated as we insert nodes into the `DependencyQueue`.
Once that's all in place it's just a few pieces here and there to
identify compilations that *can* be pipelined and then they're wired up
to depend on the rmeta file instead of the rlib file.

Closes #6660
2019-05-10 14:36:30 +00:00
Alex Crichton 6b28a0c050 Fix fingerprint handling in pipelining mode
This commit fixes an issue when pipelining mode is used in handling
recompilations. Previously a sequence of compilations could look like:

* Crate A starts to build
* Crate A produces metadata
* Crate B, which depends on A, starts
* Crate B finishes
* Crate A finishes

In this case the mtime for B is before that of A, which fooled Cargo
into thinking that B needed to be recompiled. In this case, however, B
doesn't actually need to be recompiled because it only depends on the
metadata of A, not the final artifacts.

This unfortunately resulted in some duplication in a few places, but not
really much moreso than already exists between fingerprinting and compilation.
2019-05-08 11:28:07 -07:00
Zach Lute 782266aaee Changed RUST_LOG usage to CARGO_LOG to avoid confusion. 2019-05-08 10:53:02 -07:00
Alex Crichton 127fdfeb89 Implement the Cargo half of pipelined compilation
This commit starts to lay the groundwork for #6660 where Cargo will
invoke rustc in a "pipelined" fashion. The goal here is to execute one
command to produce both an `*.rmeta` file as well as an `*.rlib` file
for candidate compilations. In that case if another rlib depends on that
compilation, then it can start as soon as the `*.rmeta` is ready and not
have to wait for the `*.rlib` compilation.

Initially attempted in #6864 with a pretty invasive refactoring this
iteration is much more lightweight and fits much more cleanly into
Cargo's backend. The approach taken here is to update the
`DependencyQueue` structure to carry a piece of data on each dependency
edge. This edge information represents the artifact that one node
requires from another, and then we a node has no outgoing edges it's
ready to build.

A dependency on a metadata file is modeled as just that, a dependency on
just the metadata and not the full build itself. Most of cargo's backend
doesn't really need to know about this edge information so it's
basically just calculated as we insert nodes into the `DependencyQueue`.
Once that's all in place it's just a few pieces here and there to
identify compilations that *can* be pipelined and then they're wired up
to depend on the rmeta file instead of the rlib file.
2019-05-08 08:10:26 -07:00
Eric Huss 27a95d0e74 Some fingerprint cleanup. 2019-03-26 13:22:49 -07:00
Dale Wijnand 45ce445c58
Warn when excluding non-existing packages 2019-02-20 16:06:12 +00:00
Eric Huss f58d107e7c testsuite: Require failing commands to check output. 2018-12-28 17:59:36 -08:00
Alex Crichton fecb724643 Format with cargo fmt 2018-12-08 03:19:47 -08:00
Dale Wijnand 04ddd4d0fc
Upgrade to Rust 2018 2018-12-06 20:18:35 +01:00
Eric Huss 61f9588cfd Don't hardlink rmeta files. 2018-11-08 21:05:17 -08:00
David Tolnay d1218d2961
Fix missing messages when --message-format=json is deeply nested
This commit switches from serde_json::Value to RawValue, which can
process arbitrarily deeply nested JSON content without recursion.
2018-09-23 14:12:10 -07:00
kennytm 4779dbfe85
Update the testsuite to include the explicit '--color' flags. 2018-09-12 11:59:08 +08:00
Dale Wijnand 9b67b272ba
Don't use an empty RUSTC_WRAPPER 2018-09-06 08:09:08 +01:00