3284 Commits

Author SHA1 Message Date
Eric Huss
0a2f691381 Switch azure to macOS 10.15. 2020-02-19 16:46:29 -08:00
Eric Huss
1d5d7a269f Support --config path_to_config.toml cli syntax. 2020-02-18 09:30:27 -08:00
bors
e02974078a Auto merge of #7697 - ehuss:bin-test-env, r=alexcrichton
Set an environment variable for tests to find executables.

This adds the environment variable `CARGO_BIN_EXE_<name>` so that integration tests can find binaries to execute, instead of doing things like inspecting `env::current_exe()`.

The use of uppercase is primarily motivated by Windows whose Rust implementation behaves in a strange way.  It always ascii-upper-cases keys to implement case-insensitive matching (which loses the original case).  Seems less likely to result in confusion?

Closes #5758.
2020-02-18 15:24:43 +00:00
Eric Huss
0d44a8267b Rework internal errors. 2020-02-17 19:03:57 -08:00
Eric Huss
fd258634c9 Improvements to StringList config handling. 2020-02-16 15:29:59 -08: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
bors
3c53211c3d Auto merge of #7857 - ehuss:fix-build-script-dupe, r=alexcrichton
Fix BuildScriptOutput when a build script is run multiple times.

When I implemented profile build overrides, I created a scenario where a build script could run more than once for different scenarios.  See the test for an example.

However, the `BuildScriptOutputs` map did not take this into consideration.  This caused multiple build script runs to stomp on the output of previous runs.  This is further exacerbated by the new feature resolver in #7820 where build scripts can run with different features enabled.

The solution is to make the map key unique for the Unit it is running for.  Since this map must be updated on different threads, `Unit` cannot be used as a key, so I chose just using the metadata hash which is hopefully unique.  Most of this patch is involved with the fussiness of getting the correct metadata hash (we want the RunCustomBuild unit's hash).  I also added some checks to avoid collisions and assert assumptions.
2020-02-07 15:35:03 +00:00
Eric Huss
499f917c03 Switch to case-sensitive environment variable. 2020-02-06 08:30:09 -08:00
Eric Huss
3489428921 Set an environment variable for tests to find executables. 2020-02-06 08:15:08 -08:00
bors
db0dac507e Auto merge of #7827 - Kinrany:7656-format-placeholder-code-when-generating-a-crate, r=ehuss
Format placeholder code when generating a crate

When generating source files in `cargo new` and `cargo init`, try to run `rustfmt` CLI on them.

If it fails, log the error and proceed.

Tests:
* Works for `cargo init --lib`
* No changes in behavior if `rustfmt` is missing

Closes #7656
2020-02-05 16:50:49 +00: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
bors
19d38e5575 Auto merge of #7865 - ehuss:fix-rebuild_sub_package_then_while_package, r=alexcrichton
Fix rebuild_sub_package_then_while_package on HFS.

This test was flaky on HFS ([azure failure](https://dev.azure.com/rust-lang/cargo/_build/results?buildId=20144&view=logs&j=a5e52b91-c83f-5429-4a68-c246fc63a4f7&t=d4864165-4be3-5e34-b483-a6b05303aa68&l=2018)), resulting in this error:

```
   Compiling foo v0.0.1 (/Users/runner/runners/2.164.7/work/1/s/target/cit/t750/foo)
error[E0460]: found possibly newer version of crate `b` which `a` depends on
 --> src/lib.rs:1:1
  |
1 | extern crate a; extern crate b; pub fn toplevel() {}
  | ^^^^^^^^^^^^^^^
  |
  = note: perhaps that crate needs to be recompiled?
  = note: the following crate versions were found:
          crate `b`: /Users/runner/runners/2.164.7/work/1/s/target/cit/t750/foo/target/debug/deps/libb-98160c67a5811c37.rlib
          crate `b`: /Users/runner/runners/2.164.7/work/1/s/target/cit/t750/foo/target/debug/deps/libb-98160c67a5811c37.rmeta
          crate `a`: /Users/runner/runners/2.164.7/work/1/s/target/cit/t750/foo/target/debug/deps/liba-7d2b9ccd932a36e9.rmeta
```

There are two race-condition bugs here.

Race 1: The second cargo build command (`cargo build -pb`) would sometimes not build, because it thought `b` is fresh.  This can happen when the first build finishes and changing `b/src/lib.rs` happen within the same second. (#5918)  The test silently ignored this failure, this is not the cause of the CI failure, though.

Race 2: The first and second build commands work as expected.  The third build command fails because it thinks both `a` and `b` are "fresh".  However, `b` was just rebuilt, and `a` depends on it, so `a` should have been rebuilt.  It thinks `a` is fresh because `a`'s mtime is equal to `b` when `b` finishes compiling within the same second that the first build finished.

The solution here is to make sure the second step happens well after the first.  The underlying problem is #5918.
2020-02-05 04:16:45 +00:00
Eric Huss
da8d17429f Fix rebuild_sub_package_then_while_package on HFS. 2020-02-04 17:42:09 -08:00
Kinrany
68a1c781d5 Merge branch 'master' into 7656-format-placeholder-code-when-generating-a-crate 2020-02-04 22:46:44 +03:00
Eric Huss
2296af27ae Fix BuildScriptOutput when a build script is run multiple times. 2020-02-02 13:26:22 -08:00
Eric Huss
cafec11467 Fix required-features using renamed dependencies.
The dep_name/feat_name syntax in required-features should use the
"name in toml" for dep_name, not the actual package name.
2020-02-02 09:59:15 -08:00
bors
972b9f55a7 Auto merge of #7837 - ehuss:fix-global-opt-alias, r=alexcrichton
Fix using global options before an alias.

Options before an alias were being ignored (like `cargo -v b`).  The solution is to extract those global options before expanding an alias, and then merging it later.

An alternative to this is to try to avoid discarding the options during expansion, but I couldn't figure out a way to get the position of the subcommand in the argument list.  Clap only provides a way to get the arguments *following* the subcommand.

I also cleaned up some of the code in `Config::configure`, which was carrying some weird baggage from previous refactorings.

Fixes #7834
2020-01-31 21:56:58 +00:00
Eric Huss
0279e8e63a Fix using global options before an alias. 2020-01-31 13:56:06 -08:00
Eric Huss
f8fafbc3de Bump to 0.44.0. 2020-01-31 12:05:14 -08:00
bors
f9132126af Auto merge of #7823 - ehuss:stabilize-config-profile, r=alexcrichton
Stabilize config-profile.

This is a proposal to stabilize config-profiles. This feature was proposed in [RFC 2282](https://github.com/rust-lang/rfcs/pull/2282) and implemented in #5506. Tracking issue is rust-lang/rust#48683.

This is intended to land in 1.43 which will reach the stable channel on April 23rd.

This is a fairly straightforward extension of profiles where the exact same syntax from `Cargo.toml` can be specified in a config file. Environment variables are supported for everything except the `package` override table, where we do not support the ability to read arbitrary keys in the environment name.
2020-01-31 11:50:31 +00:00
Kinrany
1695b89b50 Merge branch 'master' into 7656-format-placeholder-code-when-generating-a-crate 2020-01-31 01:40:01 +03:00
Kinrany
ea4f53cbd4 Fix tests on Linux/MacOS
The tests were failing with error:
"could not determine the current user, please set $USER"
2020-01-28 00:46:56 +03:00
bors
c326fcb37e Auto merge of #7810 - giraffate:support_out_dir_in_build_section, r=alexcrichton
Support out-dir in build section of Cargo configuration file

Fixed #7555.
2020-01-27 19:41:32 +00:00
bors
328b7d6b16 Auto merge of #7768 - chrisduerr:install-workspaces-from-git, r=ehuss
Search for root manifest with ephemeral workspaces

Fixes #5495.

This seems like it's too simple to just work like this, but after trying a few different things, this was the only solution which worked reliably for me.

I've verified that no `/target` is present in the actual checkout location, the target directory used is actually the one created in `/tmp`.

I've also verified that both workspaces and "normal" packages still install through git and that a normal `cargo install --path` works too (though that doesn't use ephemeral workspaces anyways).
2020-01-27 18:13:10 +00:00
Kinrany
6baf6bca01 Add tests
Test 1: init a library crate with a `rustfmt.toml` config file in it.
Expect the generated source files to be formatted according to the
config file.

Test 2: same as test 1, but with missing `rustfmt`. Expect `cargo init`
to ignore the absence of `rustfmt` and generate source files
with default formatting.
2020-01-27 19:42:20 +03: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
8e935d4d20 Stabilize config-profile. 2020-01-23 12:05:02 -08:00
bors
6de33f0ccd Auto merge of #7818 - giraffate:add_some_tests, r=alexcrichton
Add tests for `cargo owner -a/-r` / `cargo yank --undo`

Follow up 5e15286.

There were no tests for `cargo owner -a/-r` and `cargo yank --undo`. However, These commands in tests had empty response. So I also update response handling with reference to 7dd0f932a8.
2020-01-23 15:15:49 +00:00
Takayuki Nakata
58ae3d06b9 Revert fixes of response handling and fix tests 2020-01-22 09:19:59 +09:00
Eric Huss
7be3c2f09b Fix cache replay including extra newlines. 2020-01-21 16:03:35 -08:00
Takayuki Nakata
798f9942c8 Update response handling to add tests for cargo yank --undo
Follow up 5e152863f.
2020-01-21 09:09:39 +09:00
Takayuki Nakata
e632bdb906 Update response handling to add tests for cargo owner -a/-r
Follow up 5e152863f.
2020-01-21 09:06:06 +09:00
Eric Huss
10e9bc9dfe Fix doc_target test which no longer works on stable/beta. 2020-01-20 11:16:53 -08:00
Christian Duerr
ae8dee513d
Test that git install reads virtual manifest 2020-01-20 00:41:30 +01:00
Christian Duerr
a08fe088b3
Fix failing test 2020-01-20 00:41:30 +01:00
Takayuki Nakata
4a1ba1c8e5 Support out-dir in build section of Cargo configuration file
Fixed #7555.
2020-01-17 23:19:35 +09:00
Matthias Krüger
a6a395c690 fix some clippy warnings 2020-01-17 12:20:11 +01:00
bors
0a4ec29176 Auto merge of #7774 - giraffate:update_credentials, r=ehuss
Load credentials only when needed

Credentials are always loaded, even if these are not used. If
access to confidential files such as credentials is not given,
`cargo build` fails despite not using credentials.

Fixes #7624.
2020-01-15 00:31:05 +00:00
Takayuki Nakata
8076f578a3 Refactoring of creating files in tests
Use `mkdir_p` and `fs::write`.
2020-01-14 16:15:29 +09:00
Eric Huss
dafacbb76b Update tests for formatting changes due to anyhow changes. 2020-01-13 13:36:20 -08:00
Eric Huss
77ee608de3 Add named config profiles. 2020-01-13 13:27:33 -08:00
bors
6e4a159978 Auto merge of #7783 - alexcrichton:error-tweaks, r=Eh2406
Some small tweaks around error in configuration

Some minor changes I found when investigating https://github.com/rust-lang/cargo/issues/7780
2020-01-10 16:29:14 +00:00
Alex Crichton
d7b45f9992 Use context to create a chain of errors
There's an existing bug (#7782) in Cargo which exacerbates the issue
here but in general having a stack of errors is a bit easier to read and
work with than having a big long error message.
2020-01-09 10:29:22 -08:00
Takayuki Nakata
5e152863f4 Load credentials and add tests for yank and owner commands 2020-01-09 22:22:32 +09:00
bors
6dd57b2045 Auto merge of #7779 - ehuss:fix-cargo-lock-ignore, r=alexcrichton
Fix .gitignore of Cargo.lock in a subdirectory.

The code for checking if `Cargo.lock` is ignored was erroneously assuming it was at the root of the git repo.  This would cause a problem if `Cargo.lock` is in `.gitignore` in a subdirectory.

Fixes issue noted in https://github.com/rust-lang/cargo/issues/7705#issuecomment-572027382
2020-01-08 22:28:54 +00:00
Eric Huss
3cedb8e33c Fix .gitignore of Cargo.lock in a subdirectory. 2020-01-08 10:40:17 -08:00
Alex Crichton
3a18c89a55 Migrate from the failure crate to anyhow
The `anyhow` crate interoperates with the `std::error::Error` trait
rather than a custom `Fail` trait, and this is the general trend of
error handling in Rust as well.

Note that this is mostly mechanical (sed) and intended to get the test
suite passing. As usual there's still more idiomatic cleanup that can
happen, but that's left to later commits.
2020-01-07 16:50:09 -08:00
Takayuki Nakata
4b70f14903 Load credentials only when needed
Credentials are always loaded, even if these are not used. If
access to confidential files such as credentials is not given,
`cargo build` fails despite not using credentials.

Fixes #7624.
2020-01-07 23:40:58 +09:00
bors
5cca88f0c6 Auto merge of #7763 - ehuss:fix-target-cfg-env, r=alexcrichton
Fix CARGO_TARGET_triple_LINKER environment variable.

#7649 caused an unfortunate regression where the `CARGO_TARGET_triple_LINKER` environment variable stopped working. I did not realize `serde(flatten)` caused serde to switch to `deserialize_map` which does not support environment variables.

The solution here is to essentially revert back to how the `[target]` table used to be loaded by loading each key individually.

This also removes the `ar` field which is not used by `rustc`.
2020-01-06 17:18:52 +00:00
bors
1081bc7e66 Auto merge of #7756 - ehuss:dep-kinds-dedup, r=alexcrichton
Remove metadata dep_kinds duplicates.

In `cargo metadata`, an entry could appear multiple times in the `dep_kinds` array if it is used by multiple workspace members with different features activated.  This fixes it by de-duplicating the entries.

This is kinda related to `cargo metadata` not handling workspaces and features very well. But workspaces and features are a bit awkward overall.

Fixes #7752
2020-01-06 16:25:33 +00:00