87 Commits

Author SHA1 Message Date
Yuki Okushi
e5ab39145f Only deny the unused_mut lint 2021-04-28 17:59:57 +09:00
Eric Huss
501499c5f9 Add report if cargo fix --edition changes features. 2021-03-16 11:39:21 -07:00
Eric Huss
c303213748 cargo fix: Remove --prepare-for option.
This was deprecated, never officially part of the stable release.
2021-02-19 14:29:45 -08:00
Eric Huss
aa61976c5f Make edition transitions easier.
This attempts to centralize all the edition stuff in one place (the
`Edition` enum) so that adding a new edition or stabilizing one should
be relatively little work (and more importantly, we don't miss things).

Importantly, this changes `cargo new` to default to the latest stable.
It also changes the `cargo fix --edition-idiom` behavior to only apply
idioms for the *current* edition.
2021-02-19 14:29:44 -08:00
Eric Huss
28850225a1 Updates to cargo fix --edition.
* `--edition` always means "next" edition.
* `--edition` when on the most recent edition is not an error, just a warning.
* Support fix to 2021 edition.
2021-02-17 22:12:46 -08:00
Eric Huss
3f2f7e30ff Add a migrating message for cargo fix --edition.
This helps indicate which edition you are moving from and to.
2021-02-17 21:36:28 -08:00
Eric Huss
820537c706 Change Fixing to Fixed, and add a verbose "Fixing".
What was previously "Fixing" was a message for after the fixes had
been applied. I think it would be clearer if it said "Fixed",
to indicate that the fixes had actually finished.

The new "Fixing" is posted just before it starts. This is verbose-only
since it is a little noisy.
2021-02-17 20:41:38 -08:00
Eduardo Broto
f838a003f1 Stabilize RUSTC_WORKSPACE_WRAPPER 2020-12-13 23:50:15 +01: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
Andy Russell
537a020267
relax deprecated diagnostic message check 2020-07-30 21:04:45 -04:00
Eric Huss
4ae79d2ffd Use fs helpers instead of File functions. 2020-04-17 07:56:16 -07:00
Jane Lusby
d9a77ce0d0 fix unix cfg on include 2020-03-13 15:31:33 -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
Kinrany
bc4c65c5d3 Do not run formats_source if rustfmt is not available
Generalized `clippy_is_available` and renamed as `command_is_available`.

No checks in `ignores_failure_to_format_source`, it's not supposed to
use `rustfmt` even if it's available
2020-02-05 10:09:43 +03:00
Eric Huss
83571aee56 Minor testsuite organization. 2019-11-24 18:42:45 -08:00
Eric Huss
91a59e6089 Fix cargo fix not showing colors. 2019-10-28 12:00:09 -07:00
Alex Crichton
61fb34b0c0 Allow a number of tests to run on stable
These tests all relied on support which has now ridden to stable at this
point, so let's let them run on stable!
2019-09-26 11:31:57 -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
Eric Huss
3c20a24335 Clean up some git test support functions. 2019-08-12 22:25:36 -07:00
Alex Crichton
45699e9f21 Add support for customizing JSON diagnostics from Cargo
Cargo has of #7143 enabled pipelined compilation by default which
affects how the compiler is invoked, especially with respect to JSON
messages. This, in some testing, has proven to cause quite a few issues
with rustbuild's current integration with Cargo. This commit is aimed at
adding features to Cargo to solve this issue.

This commit adds the ability to customize the stream of JSON messages
coming from Cargo. The new feature for Cargo is that it now also mirrors
rustc in how you can configure the JSON stream. Multiple
`--message-format` arguments are now supported and the value specified
is a comma-separated list of directives. In addition to the existing
`human`, `short`, and `json` directives these new directives have been
added:

* `json-render-diagnostics` - instructs Cargo to render rustc
  diagnostics and only print out JSON messages for artifacts and Cargo
  things.

* `json-diagnostic-short` - indicates that the `rendered` field of rustc
  diagnostics should use the "short" rendering.

* `json-diagnostic-rendered-ansi` - indicates that the `rendered` field of rustc
  diagnostics should embed ansi color codes.

The first option here, `json-render-diagnostics`, will be used by
rustbuild unconditionally. Additionally `json-diagnostic-short` will be
conditionally used based on the input to rustbuild itself.

This should be enough for external tools to customize how Cargo is
invoked and how all kinds of JSON diagnostics get printed, and it's
thought that we can relatively easily tweak this as necessary to extend
it and such.
2019-08-05 12:49:51 -07:00
Ximin Luo
b64db390c4 Work around rust-lang/rust#61440 2019-07-20 15:58:37 -07:00
bors
9f7bd62103 Auto merge of #7069 - yaahallo:master, r=ehuss
initial working version of cargo fix --clippy

closes https://github.com/rust-lang/cargo/issues/7006
2019-07-19 20:08:18 +00:00
Eric Huss
a4e9611453 Fix some formatting for some strings. 2019-07-13 16:00:47 -07:00
Jane Lusby
8b1f599dfd back in tip top shape 2019-06-26 11:34:00 -07:00
Jane Lusby
6fb65f1e4f some changes, ill clean this up in a hot sec 2019-06-26 10:45:24 -07: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
Eric Huss
87449f453b Remove unnecessary calls to masquerade_as_nightly_cargo.
These are not needed anymore.
2019-05-09 10:58:18 -07:00
Alex Crichton
f16efff150 Run cargo fmt 2019-04-10 10:42:07 -07:00
Eric Huss
50277e88fe Testsuite: remove some unnecessary is_nightly checks. 2019-03-26 13:56:14 -07:00
Eric Huss
e7124ba262 Testsuite: Make cwd() relative to project root.
It's a fairly common pattern, and it seemed natural to me.
2019-03-20 16:34:56 -07:00
Eric Huss
00c562df56 Allow cargo fix if gitignore matches root working dir. 2019-03-20 12:22:44 -07:00
bors
865cb70106 Auto merge of #6649 - pietroalbini:change-unfixable-warning, r=dwijnand
Switch from unused_imports to deprecated to test unfixable warnings

The `unused_imports` warning is going to emit fixable suggestions in the near future, but that means parts of the cargo's test suite will break. This commit switches the tests to use the `deprecated` warning, which *shouldn't* be fixable at all.
2019-02-10 15:49:37 +00:00
Pietro Albini
ea9cd6e973
switch from unused_imports to deprecated to test unfixable warnings
The unused_imports warning is going to emit fixable suggestions in the
near future, but that means parts of the cargo's test suite will break.
This commit switches the tests to use the deprecated warning, which
*shouldn't* be fixable at all.
2019-02-10 13:51:47 +01:00
Dale Wijnand
37df042ba8
Test cleanup: remove unnecessary with_status(0) 2019-02-04 18:52:33 +01:00
nasa
db09895f3c $cargo fmt --all 2019-01-27 22:39:49 +09:00
Alex Crichton
1fc4ba845c Report fix bugs to Rust instead of Cargo
I originally opted to report bugs to Cargo instead of Rust because I was
afraid of the implementation of `cargo fix` itself. These seem to all be
weeded out now (largely at least), and the overwhelming majority of bugs
are now rust-lang/rust suggestion bugs. Let's suggest reporting bugs
directly there!
2019-01-09 09:42:28 -08:00
Eric Huss
f58d107e7c testsuite: Require failing commands to check output. 2018-12-28 17:59:36 -08:00
bors
a3a3c254bd Auto merge of #6419 - ehuss:fix-show-errors, r=alexcrichton
Display errors when `cargo fix` fails.

It can be difficult to figure out what's wrong when a user reports that `cargo fix` fails. It can be hard to figure out which suggestion caused a compile error, especially if the error is in another file/location.
2018-12-14 00:11:15 +00:00
Eric Huss
41519fbf10 cargo fix: fix targets with shared sources.
If `cargo fix` attempts to fix multiple targets concurrently that have shared
source files, it would apply fixes multiple times causing corruption of the
source code. Fix this by locking on the package path instead of the target
filename, essentially serializing all targets within a package.
2018-12-13 14:29:26 -08:00
Eric Huss
fffb05d8fc Display errors when cargo fix fails.
It can be difficult to figure out what's wrong when a user reports that
`cargo fix` fails. There's often a large list of warnings, and it can
be hard to figure out which one caused a compile error.
2018-12-13 13:59:06 -08:00
Eric Huss
49d753e641 Fix flakey broken_fixes_backed_out test.
Since `fix` does `--all-targets` there is a race condition as to which target goes first. This has less than a 1% failure rate on CI, but it has been seen several times lately:

https://ci.appveyor.com/project/rust-lang-libs/cargo/builds/20878003/job/v01k5j14od50mghw
https://ci.appveyor.com/project/rust-lang-libs/cargo/builds/18699824/job/465w7uav7ew24yka
https://ci.appveyor.com/project/rust-lang-libs/cargo/builds/17283788/job/7cxp8bwm4d3i1xgl
2018-12-09 11:59:42 -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
Alex Crichton
08dc6da030 fix: Don't back out changes with --broken-code
This commit updates the behavior of `cargo fix` when the `--broken-code`
flag is passed to Cargo. Previously Cargo would always back out
automatically applied changes to files whenever the fixed code failed to
compile. Now, with the `--broken-code` flag, fixed code is left as-is.
This means that if the fixed code can be more easily inspected by
humans to detect bugs and such.

The main use case intended here is that if you're working with a large
code base then lints like the edition idiom lints aren't 100% finished
yet to work as smoothly as `cargo fix`. The idiom lints are often
useful, however, to transition code to be idiomatic (who would have
guessed!) in the new edition.

To ease the experience of using not-quite-ready lints this flag can be
used to hopefully "fix 90% of lint warnings" and then the remaining
compiler errors can be sifted through manually. The intention is that we
have edition documentation indicating this workflow which also
encourages filing bugs for anything that fails to fix, and hopefully
this new behavior will make it easier for us to narrow down what the
minimal test case is too!
2018-11-13 20:26:57 -08:00
Eric Huss
89413bd41a Fix fix_path_deps again. 2018-11-05 16:32:27 -08:00
Alex Crichton
4f784a10d1 Don't turn on edition lints for unfixed crates
Currently Cargo runs the risk of turning on the edition lints for crates
which `cargo fix` isn't actually fixing, which means you'll get a huge
deluge of lints that would otherwise be automatically fixable! Fix this
situation by only enabling lints in the same cases that we're actually
applying fixes.

Closes rust-lang-nursery/rustfix#150
2018-11-01 08:13:11 -07:00
Dale Wijnand
a7b1c4ecf7
Enable some fix tests on stable 2018-09-22 07:18:16 +01:00