69 Commits

Author SHA1 Message Date
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
bors
18c8c5fb99 Auto merge of #6065 - zachlute:change-project-to-package, r=dwijnand
Replace 'project' with 'package' in many strings and comments.

Partial fix for #6056.

Shouldn't be anything too interesting or surprising in here.

Still need to do documentation, but will do that as a different PR.
2018-09-21 23:34:08 +00:00
Eduard-Mihai Burtescu
afdde6081d Remove fix::local_paths_no_fix, as crate_in_paths is getting stabilized. 2018-09-21 18:44:38 +03:00
Zach Lute
3492a3905c Replace 'project' with 'package' in many strings and comments. 2018-09-20 23:47:09 -07:00
steveklabnik
d277c8447d No longer warn about #![feature(rust_2018_preview)]
This is no longer needed, and so the warning is outdated.

Fixes #6050
2018-09-18 15:15:02 -04:00
bors
56ee6204de Auto merge of #5984 - alexcrichton:stabilize-edition, r=ehuss
Stabilize `edition` key and add `cargo new --edition`

This commit stabilizes the `edition` key in `Cargo.toml`, both in the
`[package]` section and inside subtargets. Additionally the `cargo new` and
`cargo init` subcommands have been enhanced with a `--edition` flag to allow
explicitly specifying the edition to be generated.

This commit does not yet change the default edition that's generated.

Closes #5980
2018-09-06 22:17:24 +00:00
Alex Crichton
3d0290398a Stabilize edition key and add cargo new --edition
This commit stabilizes the `edition` key in `Cargo.toml`, both in the
`[package]` section and inside subtargets. Additionally the `cargo new` and
`cargo init` subcommands have been enhanced with a `--edition` flag to allow
explicitly specifying the edition to be generated.

This commit does not yet change the default edition that's generated.

Closes #5980
2018-09-06 11:28:10 -07:00
Alex Crichton
51be74244b fix: Fix unusual errors with RUSTC_WRAPPER
This commit fixes the interaction of `cargo fix` and `RUSTC_WRAPPER`, ensuring
that Cargo at least doesn't die internally. For now `RUSTC_WRAPPER` is
overridden for normal execution but we can eventually one day probably support
`RUSTC_WRAPPER`!

Closes #5981
2018-09-05 15:18:40 -07:00
bors
aecaef3e23 Auto merge of #5944 - dwijnand:fix-force-rebuild, r=alexcrichton
Force `cargo fix` to rebuild

Fixes #5736

This is a resubmit of @killercup's #5750, rebased on current master.

@alexcrichton From browsing the code I feel like `-p` would still restrict the packages to rebuild, despite the rebuild flag added. But I might be misreading or not-fully-reading the code. Could you give me some mentoring instructions for the test cases you're concerned with?
2018-08-31 22:43:25 +00:00
Dale Wijnand
7a42790a7c
Assert fix::doesnt_rebuild_dependencies stderr fully
Gives more confidence.
2018-08-30 07:28:20 +02:00
Dale Wijnand
b98ba8e289
Test that cargo fix doesn't aggressively rebuild 2018-08-29 21:24:16 +02:00
Pascal Hertleif
616e0ad3bf
Always rebuild targets when using cargo-fix 2018-08-29 01:57:52 +02:00
Dale Wijnand
8c2d0dffa4
Merge branch 'master' into fix-allow-staged
* master: (25 commits)
  Migrate from tests fom assert_that/execs to .run()
  Wrap ProcessBuilder in Execs & make .cargo return that
  Make old Execs methods take not consume self
  Extract Execs::match_process
  Add #[must_use] to Execs
  Inline Execs::_with_stderr
  Remove an unrun "cargo build" ProcessBuilder
  Add documentation for creating test dependencies.
  Only use non-absolute paths for `path` dependencies
  Fix test failure on nightly due to `codemap::Span` change.
  New metabuild strategy using custom src_path enum.
  Remove unnecessary change.
  Address review comments.
  Metabuild (RFC 2196)
  Handle Window's missing file error message
  Make "cargo uninstall" uninstall the cwd bins
  update comment based on further research
  List URL in HTTP download failures
  Fix compilation error
  Improve the `cargo install` deprecation messaging
  ...
2018-08-29 01:20:18 +02:00
Dale Wijnand
85984a8700
Migrate from tests fom assert_that/execs to .run() 2018-08-28 15:08:12 +02:00
Dale Wijnand
b5ee3635ef
Wrap ProcessBuilder in Execs & make .cargo return that 2018-08-28 09:24:37 +01:00
Jordan Justen
2bbbca3126
fix: Add test warns_about_staged_working_directory
Signed-off-by: Jordan Justen <jljusten@gmail.com>
2018-08-21 00:12:30 -07:00
Jordan Justen
6a616cb7c2
fix: Add --allow-staged switch to cargo fix
This change splits out staged changes from dirty changes, and lets the
user know if they should consider using the --allow-staged flag.

Signed-off-by: Jordan Justen <jljusten@gmail.com>
2018-08-21 00:12:30 -07:00
Jordan Justen
4539ff2191
fix: Prepare error message for --allow-staged
Signed-off-by: Jordan Justen <jljusten@gmail.com>
2018-08-21 00:12:30 -07:00
Dale Wijnand
16aeb0cd4f
Default test support's Execs to exit code 0 2018-08-03 07:44:42 +01:00