Commit graph

2311 commits

Author SHA1 Message Date
Eric Huss 7318014fb1 Fix tests when CARGO_TARGET_DIR is set.
Fixes #5536
2018-05-15 07:52:24 -07:00
Eduard-Mihai Burtescu 62faec8511
Remove -Zno-trans test. 2018-05-15 10:14:03 +03:00
Eric Huss 1a715aaec9 Ignore <tab> in libtest output.
rust-lang/rust#50387 is changing the output from libtest which affected a few Cargo tests.
2018-05-14 22:02:34 -07:00
bors b24b455c32 Auto merge of #5522 - DarkDrek:user_agent_option, r=alexcrichton
Add option to set user-agent

Fixes #5494
2018-05-11 23:38:48 +00:00
DarkDrek ab4b8b9d83 Add option to set user-agent
Fixes #5494
2018-05-12 01:19:00 +02:00
Alex Crichton 5e76cbc55a Fix mode generated in maybe_lib
The new `mode` for the library dependency is dependent on the library target
rather than the target which is the reason for the dependency on the library!

Closes rust-lang/rust#50640
2018-05-11 08:04:55 -07:00
Eric Huss 3071734d6f Fix panic for binaries built during tests.
Fixes #5435

Also re-enable tests now that #5460 has landed.
2018-05-10 14:25:17 -07:00
bors 13c258ecae Auto merge of #5301 - mshal:build-plan, r=matklad
Add --build-plan for 'cargo build'

With 'cargo build --build-plan', cargo does not actually run any
commands, but instead prints out what it would have done in the form of
a JSON data structure.

Fixes #3815
2018-05-10 19:55:02 +00:00
Eric Huss f4dc629d9e Fix broken test. 2018-05-10 08:46:02 -07:00
Eric Huss 27edc433c9 Be more conservative about which files are linked to the output dir.
This changes it so that only top-level targets requested on the command-line will be included in the output directory.  Dependencies are no longer included.

Fixes #5444.
2018-05-10 08:46:02 -07:00
Eric Huss a187ba8a9c Fix cargo rustc for test with implicit binary.
Fixes #5502
2018-05-08 17:23:28 -07:00
Mike Shal 72e6b9d326 Add --build-plan for 'cargo build'
With 'cargo build --build-plan', cargo does not actually run any
commands, but instead prints out what it would have done in the form of
a JSON data structure.

Fixes #3815
2018-05-07 17:35:47 -04:00
Eric Huss 352114472f Fix random Windows CI error for changing_bin_features_caches_targets
Fixes #5481.
2018-05-06 15:19:07 -07:00
Eric Huss 5415a341a5 Add package spec support to profile overrides.
Note: It errors out if multiple overrides match the same package.  This could potentially merge the overrides together with a hierarchy similar to CSS specificity.  However, that seems overkill for now.
2018-05-05 16:51:50 -07:00
bors d0d3cb5ac9 Auto merge of #5461 - matklad:meta-rename, r=alexcrichton
Support crate renames in `cargo metadata`

This adds information about (currently unstable) crate renames to metadata. Unfortunately, we already expose dependencies as a list of package ids (which are strings), so we can't easily add a `rename` field easily. For this reason, I've added a parallel `deps` key, which basically deprecates `dependencies` field.

So, the new format looks like this

```JavaScript
{
    "dependencies": [
        "bar 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
        "bar 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)"
    ],
    "deps": [
        {
            "extern_crate_name": "baz", // this one is actually renamed
            "id": "bar 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)"
        },
        {
            "extern_crate_name": "bar",
            "id": "bar 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)"
        }
    ],
    "features": [],
    "id": "foo 0.5.0 (path+file://[..])"
},
```

Questions:

* Is there a better name for `extern_crate_name`? This name is precise, but it's longer than I like, and might become opaque in meaning if we remove `extern crate` from the language :)
* Should we feature gate this (i.e, only produce `deps` if we have a feature in `Cargo.toml`)? I think the answer is yes, but that'll require threading `Features` to `Workspace`...

r? @alexcrichton
2018-05-05 21:32:18 +00:00
Aleksey Kladov a312c55dcb Expand dependency info of cargo --metadata
The old `dependencies` key in `resolve` is deprecated.

Instead, the new `deps` key introduced which lists dependencies kinds
(dev/build/normal) as well as `extern crate` name for the dep.
2018-05-06 00:14:02 +03:00
bors 757112c39f Auto merge of #5490 - alexcrichton:fix-thrash, r=matklad
Factor in `used_in_plugin` to target filenames

This prevents thrashing the cache of compiled libraries for when they're used in
a plugin or not.
2018-05-05 20:41:12 +00:00
Alex Crichton 9df7370733 Factor in used_in_plugin to target filenames
This prevents thrashing the cache of compiled libraries for when they're used in
a plugin or not.
2018-05-05 12:59:50 -07:00
Alex Crichton 1759b30cf7 Cop out on fixing a spurious test failure
This commit cops out trying to fix `rename_with_link_search_path` by simply
adding a loop on Windows to retry the operation that looks to need retrying.
2018-05-05 11:47:41 -07:00
bors 07c0784642 Auto merge of #5487 - matklad:mixed-deps, r=alexcrhiton
FIx false positive warning

We warn if a feature was specified corresponding to a dependency which
is not optional. However, a dependency can be both optional and
required, and we shouldn't warn in that case.

cc https://github.com/rust-lang/cargo/pull/5480

r? @alexcrichton
2018-05-05 17:19:01 +00:00
Aleksey Kladov 739cc2078d FIx false positive warning
We warn if a feature was specified corresponding to a dependency which
is not optional. However, a dependency can be both optional and
required, and we shouldn't warn in that case.
2018-05-05 20:18:37 +03:00
Eric Huss e881999fb3 Deprecate doc profile.
Fixes #5434
2018-05-05 08:52:19 -07:00
bors 556f80f3dc Auto merge of #5485 - patriksvensson:feature/GH-5474, r=matklad
Do not allow running library examples.

This is my first contribution to anything Rust related that I haven't written myself, and I'm not a very proficient Rust programmer (yet), so would love some feedback on improvements.

I also might have solved this the wrong way... 😄

Closes #5474

(cc @matklad)
2018-05-05 14:24:55 +00:00
Patrik Svensson 8da2908056 Made adjustments based on feedback from review. 2018-05-05 16:20:53 +02:00
Patrik Svensson 5b49778719 Do not allow running library examples.
Closes #5474
2018-05-05 10:51:48 +02:00
bors 5986492773 Auto merge of #5480 - alexcrichton:fix-regr, r=matklad
Fix optional deps in multiple sections

This commit fixes an issue where an optional dependency was listed multiple
times in a manifest (multiple sections). This regression was introduced by #5415
and happened because in the resolver we didn't record a `Dependency` as it was
accidentally deduplicated too soon.

The fix here was to ensure that all `Dependency` annotations make their way into
`Resolve` now that we rely on the listed `Dependency` values for correctness.

Closes #5475
2018-05-04 21:07:15 +00:00
Alex Crichton 2f88a70407 Fix optional deps in multiple sections
This commit fixes an issue where an optional dependency was listed multiple
times in a manifest (multiple sections). This regression was introduced by #5415
and happened because in the resolver we didn't record a `Dependency` as it was
accidentally deduplicated too soon.

The fix here was to ensure that all `Dependency` annotations make their way into
`Resolve` now that we rely on the listed `Dependency` values for correctness.

Closes #5475
2018-05-04 14:06:59 -07:00
Eric Huss a994fc6e36 Disable --all-targets panic tests until we can land a fix. 2018-05-04 10:51:20 -07:00
bors 23af593083 Auto merge of #5479 - matklad:ghost-hunting, r=alexcrichton
Investigating spurious windows errors

r? @alexcrichton
2018-05-04 16:07:30 +00:00
Aleksey Kladov 25cab498a5 Try to diagnose/fix spurious windows error with better rm -r 2018-05-04 18:02:57 +03:00
Aleksey Kladov d57f6b0563 Revert "Attmept to fix a spurious failure on AppVeyor"
This reverts commit db3328f8f7.

We get spurious errors for thouse tests even with debug info disabled,
so let's reenable it back.
2018-05-04 17:53:10 +03:00
bors 1ca44da30b Auto merge of #5476 - dwijnand:Registry-vs-Source-confusion, r=matklad
Try & simplify Registry vs Source confusion

Refs #3006.

I tried to go further and replace references of `Registry` with `PackageRegistry`, but I ran into lifetime issue in `ops::resolve_with_previous` which I think has to do with no longer passing `PackageRegistry` as a `Registry` trait object (with a new and distinct lifetime).
2018-05-04 14:37:41 +00:00
Dale Wijnand f947326a0c
Start moving methods from Registry to Source
For now just move `supports_checksums` and `requires_precise` methods
down from `Registry` to `Source`, as they're not as entangled as
`query`.
2018-05-04 08:19:40 +01:00
bors 0dd53841d3 Auto merge of #5472 - alexcrichton:rename-rust, r=matklad
Rename the `rust` manifest key to `edition`

This'll hopefully jive better with the terminology of "edition" throughout the
rest of Rust!
2018-05-03 19:39:24 +00:00
Alex Crichton 8413008937 Rename the rust manifest key to edition
This'll hopefully jive better with the terminology of "edition" throughout the
rest of Rust!
2018-05-03 11:45:04 -07:00
bors 9aad27b8da Auto merge of #5470 - alexcrichton:hopeful-fix, r=matklad
Attmept to fix a spurious failure on AppVeyor

I *think* the issue is that `link.exe` is generating debuginfo in the background
which keeps the file open and prevents us from deleting it, but hopefully by
disabling debug information we'll either be able to confirm or deny this
hypothesis.
2018-05-03 17:03:06 +00:00
Alex Crichton db3328f8f7 Attmept to fix a spurious failure on AppVeyor
I *think* the issue is that `link.exe` is generating debuginfo in the background
which keeps the file open and prevents us from deleting it, but hopefully by
disabling debug information we'll either be able to confirm or deny this
hypothesis.
2018-05-03 08:57:36 -07:00
Aleksey Kladov ecd1e5df0f Tweak error messages
By convention, all errors should start with a lowercase letter
2018-05-03 18:31:23 +03:00
Aleksey Kladov d49910fd21 Make alias handling more straightforward
Previously, `execute_subcommand` was called recursively, and each call
would `.configure` the `config` again. It worked, but seemed rather
fragile.

This commit handles aliases more explicitly, ensures that `.configure`
is called once and, as a bonus, adds a warning for when an alias is
shadowed by the built in.
2018-05-03 18:29:51 +03:00
bors 4dc5db2db5 Auto merge of #5464 - ehuss:restore-example-test, r=alexcrichton
Partially revert change to testing examples.

Fixes #5437

I don't think changing the behavior was quite the correct thing to do.  This new behavior is very similar to the old with a few small differences:

```
cargo test
    ORGINAL: Only builds examples.
    NEW: Builds all examples.  Any example with `test` set is tested.

cargo test --tests
    ORIGINAL: Runs all examples as tests.
    NEW: Only runs examples as tests if `test` is set.

cargo test --examples
    ORIGINAL: Runs all examples as tests.
    NEW: (SAME)

cargo test --example foo
    ORIGINAL: Runs the given example as a test.
    NEW: (SAME)

cargo test --all-targets
    ORIGINAL: Runs all examples as tests.
    NEW: (SAME)
```
2018-05-03 13:43:38 +00:00
Aleksey Kladov f1dabb7ec9 Fix the test 2018-05-03 13:22:03 +03:00
Eric Huss dffc5baeb2 Partially revert change to testing examples.
Fixes #5437

I don't think changing the behavior was quite the correct thing to do.  This new behavior is very similar to the old with a few small differences:

```
cargo test
    ORGINAL: Only builds examples.
    NEW: Builds all examples.  Any example with `test` set is tested.

cargo test --tests
    ORIGINAL: Runs all examples as tests.
    NEW: Only runs examples as tests if `test` is set.

cargo test --examples
    ORIGINAL: Runs all examples as tests.
    NEW: (SAME)

cargo test --example foo
    ORIGINAL: Runs the given example as a test.
    NEW: (SAME)

cargo test --all-targets
    ORIGINAL: Runs all examples as tests.
    NEW: (SAME)
```
2018-05-02 20:17:53 -07:00
Aleksey Kladov 658343aa10 Don't install pre-releases by default 2018-05-03 01:32:06 +03:00
bors 420f9ec576 Auto merge of #5456 - LukasKalbertodt:patch-1, r=matklad
Show elapsed time in minutes if >= 60 secs

In large projects with long compile times, seeing "428.65 secs" isn't as clear to humans as seeing the number of minutes (and seconds).

**Old**:
```
Finished dev [unoptimized + debuginfo] target(s) in 2.23 secs
Finished dev [unoptimized + debuginfo] target(s) in 63.94 secs
Finished dev [unoptimized + debuginfo] target(s) in 428.65 secs
```

**New**:
```
Finished dev [unoptimized + debuginfo] target(s) in 2.23s
Finished dev [unoptimized + debuginfo] target(s) in 1m 3.94s
Finished dev [unoptimized + debuginfo] target(s) in 7m 8.65s
```

Note that I also changed `secs` to `s`, because `7 mins 8.65 secs` and `7m 8.65 secs` both look strange IMO. But if you disagree and you'd prefer `secs`, just tell me and I'll change it.

I *didn't* add a check for `secs >= 3600` to print the time in hours. I *hope* this is not necessary...
2018-05-02 17:17:27 +00:00
bors 31b38fe7e0 Auto merge of #5458 - alexcrichton:track-panic, r=matklad
Track panic mode in fingerprint

Ensure that if we've previously compiled a crate with panic=abort and we later
need it for panic=unwind we correctly recompile it.

Closes #5445
2018-05-02 16:35:38 +00:00
Lukas Kalbertodt 357281374d Adjust tests to new time output format 2018-05-02 18:34:59 +02:00
bors 1b26ece291 Auto merge of #5454 - alexcrichton:fix, r=matklad
Fix optional dependencies and required dev-deps

This fixes an accidental bug introduced in #5300 by ensuring a local map keeps
track of the fact that there can be multiple dependencies for one name

Closes #5453
2018-05-02 15:35:33 +00:00
bors 2eebc86056 Auto merge of #5446 - csmoe:new_name, r=alexcrichton
Emit correct project name with --name

Fixes #5440
2018-05-02 14:40:15 +00:00
Alex Crichton 7f44648616 Track panic mode in fingerprint
Ensure that if we've previously compiled a crate with panic=abort and we later
need it for panic=unwind we correctly recompile it.

Closes #5445
2018-05-02 07:34:19 -07:00
Alex Crichton 02b0dba36b Fix optional dependencies and required dev-deps
This fixes an accidental bug introduced in #5300 by ensuring a local map keeps
track of the fact that there can be multiple dependencies for one name

Closes #5453
2018-05-01 17:03:23 -07:00
DarkDrek 2ea2fafca9 Add cargo clean --doc 2018-05-01 17:38:22 +02:00
bors 181de52b2e Auto merge of #5447 - ehuss:ws-error-message, r=alexcrichton
Better error message for `cargo rustc` in a workspace.

Fixes #5371
2018-05-01 13:50:13 +00:00
bors f2abbe8b54 Auto merge of #5448 - ehuss:debug_env, r=alexcrichton
Fix "DEBUG" env var in build.rs for debug=0

Fixes #5370
2018-05-01 03:49:32 +00:00
Eric Huss 037a879dbd Better error message for cargo rustc in a workspace.
Fixes #5371
2018-04-30 20:39:07 -07:00
csmoe 1edfd9b190 add test for project name 2018-05-01 09:39:22 +08:00
bors 4963d884a4 Auto merge of #5300 - djc:namespaced-features, r=alexcrichton
Introduction of namespaced features (see #1286)

I think this basically covers all of the plans from #1286, although it still needs a bunch of tests and documentation updates. Submitting this PR to get some early feedback on the direction.
2018-04-30 17:52:35 +00:00
Eric Huss 83b8c234a1 Fix "DEBUG" env var in build.rs for debug=0.
Fixes #5370
2018-04-30 10:17:43 -07:00
Dirkjan Ochtman 0b6f420670 Put namespaced features behind a feature gate 2018-04-30 17:33:36 +02:00
bors 122fd5be52 Auto merge of #5430 - matklad:bring-old-features-back, r=alexcrichton
Revert "Enable new behavior of `--feature`"

This reverts commit 038eec5cb3.

As discussed at https://github.com/rust-lang/cargo/issues/5364, the new behavior unfortunately causes real-life breakage, so we have to revert it.

This is kinda sad, this is a part of the larger issue with feature selection, which, at the moment, has a behavior which I would classify (loosely speaking) as unsound:

* `cargo build -p foo` and `cargo build -p foo -p bar` might produce different artifacts for `foo` ([repro](https://github.com/matklad/workspace-vs-feaures))
* `cargo build -p foo` might produce different artifacts, depending on cwd ([repro](https://github.com/matklad/features-cwd))

The new feature behavior specifically addressed the second point.

It is unclear what we could do with this... One option, instead of flatly erroring out, as the revreted commit does, is to print a warning, but change the set of activated features. It will still be a breaking change, but it at least has  a chance of working by accident.

r? @alexcrichton
2018-04-28 18:02:36 +00:00
bors 07d022dc70 Auto merge of #5425 - matklad:rename-fingerprint, r=alexcrichton
Package renames should affect fingerprints
2018-04-28 16:44:31 +00:00
Aleksey Kladov 30e52ca906 Extend dashes forwarding test 2018-04-28 17:57:03 +03:00
Aleksey Kladov d369f97c19 Revert "Enable new behavior of --feature"
This reverts commit 038eec5cb3.
2018-04-28 17:28:39 +03:00
Dirkjan Ochtman dc5d023482 Add tests for namespaced features 2018-04-28 13:41:18 +02:00
Dirkjan Ochtman a9f163e390 Keep track of namespaced-features flag in Summary objects
For now, all Summaries from a registry have it set to false.
2018-04-28 13:41:18 +02:00
Aleksey Kladov fc72bcb449 Mix package renames into fingerprints 2018-04-28 13:38:16 +03:00
Eric Huss 195520b853 Avoid building libs and bins twice in cargo build --all-targets --release.
This changes it so that `Build` mode is not set in the Unit, since there is
no difference between Bench and Test once the profile has been selected.
2018-04-27 13:42:30 -07:00
Eric Huss 025e23b83e Update tests now that cargo check does not re-check bins. 2018-04-27 13:42:30 -07:00
Eric Huss b9181ef3b5 Add some more tests. 2018-04-27 13:42:30 -07:00
Eric Huss 10a6da6298 Add thorough tests for target/profile selection. 2018-04-27 13:42:30 -07:00
Eric Huss 9ca36de444 Move profile override tests to a dedicated file. 2018-04-27 13:42:30 -07:00
Eric Huss ec7be849e3 Some test cleanup for profiles. 2018-04-27 13:42:30 -07:00
Eric Huss c667fc231d Add more profile override validation tests. 2018-04-27 13:42:30 -07:00
Eric Huss ba537d73b9 Add test for profile override on non-dev/release. 2018-04-27 13:42:30 -07:00
Eric Huss 36b8769025 Add warning if panic is set in test or bench profile. 2018-04-27 13:42:30 -07:00
Eric Huss a0a880c36e Add warnings for unknown profile overrides. 2018-04-27 13:42:30 -07:00
Eric Huss 7dc9e071c7 Minor tweaks on how examples are handled with tests, and some panic propagation. 2018-04-27 13:42:30 -07:00
Eric Huss 7051b630c8 Update for some review comments. 2018-04-27 13:42:29 -07:00
Eric Huss 62d6f0d023 Minor cleanup. 2018-04-27 13:22:01 -07:00
Eric Huss 575d6e819c Profile Overrides (RFC #2282 Part 1) 2018-04-27 13:22:00 -07:00
Alex Crichton ce5bbbc7d6 Fix renaming crates as they come from 2 sources
Previously there was a verification in manifest parsing that the same dependency
must come from the same source, but this erroneously triggered an error to get
emitted when the `package` key was used to rename crates. The first change here
was to update that clause to key off the `rename` field rather than the `name`
field.

Afterwards, though, this exposed an existing bug in the implementation. During
compilation we have a `Resolve` which is a graph of crates, but we don't know
*why* each edge in the dependency graph exists. In other words we don't know,
when looking at an edge of the graph, what `Dependency` caused that edge to be
drawn. We need to know this when passing `--extern` flags because the
`Dependency` is what lists what's being renamed.

This commit then primarily refactors `Resolve::deps` from an iterator of package
ids to an iterator of a tuples. The first element is the package id from before
and the second element is a list of `Dependency` directives which caused the
edge to ber driven.

This refactoring cleaned up a few places in the backend where we had to work
around the lack of this knowledge. Namely this also fixes the extra test added
here.

Closes #5413
2018-04-27 10:48:34 -07:00
bors d998906598 Auto merge of #5349 - bmwill:fetch-by-target, r=alexcrichton
cargo-fetch: add option to fetch for a target

Teach cargo-fetch how to optionally fetch dependencies based on a target
platform by specifying the target triple via `--target <TRIPLE>`.

#5216
2018-04-27 15:36:16 +00:00
bors 9eece36013 Auto merge of #5410 - klnusbaum:edition_5406, r=matklad
switch to using the --edition flag

Now that we have an `--edition` flag in the rust compiler, let's switch to using it.

fixes #5406
2018-04-27 15:14:03 +00:00
Brandon Williams 1956c5d8ba cargo-fetch: add option to fetch for a target
Teach cargo-fetch how to optionally fetch dependencies based on a target
platform by specifying the target triple via `--target <TRIPLE>`.

Signed-off-by: Brandon Williams <bmwill@google.com>
2018-04-26 10:07:01 -07:00
bors 9092298d44 Auto merge of #5394 - henriklaxhuber:master, r=alexcrichton
Pass linker path to build script

This change adds the environment variable LINKER to pass the path of the linker used by cargo to the build script. This complements the variable RUSTC (the rustc binary used) to give the build script full knowledge of its environment.

A specific usage example would be automatically generating bindings to system headers in cross compilation, e.g. by locating jni.h for android targets.
2018-04-24 14:36:52 +00:00
Simon Smith 0b530c3086 Add target directory parameter: address suggestions 2018-04-24 02:52:41 -04:00
Henrik Laxhuber 3ebdc722c6
Moved RUSTC_LINKER test into its own fn 2018-04-24 08:18:33 +02:00
Simon Smith dd0b7a2cda Add target directory parameter --target-dir 2018-04-23 18:23:48 -04:00
Henrik Laxhuber 4628011e79
Fixed RUSTC_LINKER test for Windows hosts 2018-04-23 18:28:38 +02:00
Henrik Laxhuber 1469523348
Fixed build script env var test 2018-04-23 17:45:17 +02:00
Henrik Laxhuber 1d36411cc4
Added tests for RUSTC_LINKER buils script env var
Added tests for the environment variable RUSTC_LINKER that is
passed to the build script.
Also slightly improved readability of the code responsible for
passing the env var.
2018-04-23 17:11:10 +02:00
Kurtis Nusbaum 0b2aaaffe9 switch to using the --edition flag 2018-04-22 12:14:21 -07:00
Aleksey Kladov 14067b952e Remove some is_nightly checks from tests 2018-04-22 18:08:31 +03:00
Dale Wijnand ab5ac28a42
backtick auto-discovery key usage advice 2018-04-20 22:23:08 +01:00
Dale Wijnand d3f5fefa5c
manually line wrap warnings at 80 characters 2018-04-20 22:22:41 +01:00
Dale Wijnand 54e7bc51a2
prefer PathBuf::display over {:?} 2018-04-20 22:21:33 +01:00
Dale Wijnand abbd69e747
avoid windows path assertion bug 2018-04-20 22:20:31 +01:00
Dale Wijnand e471745e47
Introduce autoXXX keys for target auto-discovery
In Rust 2015 absence of the configuration makes it default to not
include auto-discovered targets (i.e false), with a warnings message.

In Rust 2018 absence makes it default to include auto-discovered
targets (i.e true).

Fixes #5330
2018-04-20 20:57:24 +01:00
Dale Wijnand 6828380e56
Move edition earlier in TomlManifest::to_real_manifest
and fix a typo in the error message
2018-04-20 19:45:59 +01:00
bors db90cfeaab Auto merge of #5391 - varkor:check-message, r=alexcrichton
Print "Checking" for cargo check

I often alternate between `check` and `build` and I'd like to be able to tell which is currently happening (short-term memory being what it is, and "compiling" implying to me that codegen is occurring). Changing the message to "Checking" seemed to be reasonable (and there was precedent for `doc` with "Documenting").
2018-04-19 22:21:08 +00:00
varkor 97b971a775 Update tests to check for Checking 2018-04-19 19:19:11 +01:00
bors 0a33eb2a75 Auto merge of #5390 - matklad:new-feature-behavior, r=alexcrichton
Enable new behavior of `--feature`

So far, the feedback on https://internals.rust-lang.org/t/help-us-test-the-breaking-bug-fix-to-cargo-features/7317 has been positive, so here's a PR to try this in nightly.

Note that the logic is slightly tweak for the case `cargo build -p not-a-workspace-member`: we want not only to resolve all ws members in this case, but to enable all of their features as well!

As a sanity check, this seems to be forward compatible with further improvements to features:

1) when we solve the grand bug of features being unified across the whole workspace, `cargo build -p not-a-member` would hopefully just work without additional contortions.
2) we might add a way to specify features per package, like `cargo build -p foo -p bar --features "foo/serde bar/serde"`
2018-04-19 14:30:48 +00:00
bors a04e2e5bd9 Auto merge of #5392 - ehuss:test-does-not-contain, r=alexcrichton
cargotest: Fix `with_*_does_not_contain` to support `[..]` and macro matching.

I changed it so that it is essentially the opposite of `with_*_contains` to keep it symmetric.

Any in-flight PRs using the old style will need to be updated (else they will incorrectly silently pass).  Alternatively, we could rename the method to avoid that.

The following tests contained brackets, so they were not checking what they thought they were checking.  I did a cursory look at them, but perhaps someone else could double-check that they make sense.  Asserting what *doesn't* happen can be tricky since there is an infinite number of things that won't happen.  Preferably a test would assert that it appears in one scenario and not another (like `incremental_profile` does), but some of them don't or can't.

```
build::incremental_profile
build::incremental_config
build::cargo_compile_with_workspace_excluded
build::build_all_exclude
build::targets_selected_default
check::targets_selected_default
check::check_filters
rustc::targets_selected_default
rustc_info_cache::rustc_info_cache
warn_on_failure::no_warning_on_bin_failure
warn_on_failure::warning_on_lib_failure
```

BTW, would you be interested in a PR that adds some documentation to `cargotest`?
I've discovered things I didn't know where there.  I think some docstrings on some of the methods, and a short guide for new contributors would be helpful.
2018-04-19 14:08:29 +00:00
Eric Huss e7896a2f68 Fix with_*_does_not_contain to support [..] and macro matching. 2018-04-18 22:13:30 -07:00
Aleksey Kladov 038eec5cb3 Enable new behavior of --feature 2018-04-19 00:34:45 +03:00
Aleksey Kladov f7fa1f2ac5 Don't try to use the same info if target == host
The info might be different due to RUSTFLAGS, which, in general,
are applied only to target.
2018-04-18 18:00:21 +03:00
Aleksey Kladov 1be3579396 Improve rustc cache
Even if we've failed to calculate fingerprint and thus can't persist
cache to disk, it is still valid to cache rustc output within single
process.
2018-04-18 17:44:23 +03:00
Yusuf Simonson d4162ed115 Explicitly test for new package metadata fields 2018-04-18 15:16:50 +07:00
Yusuf Simonson d1cacfedf3 Added new metadata fields.
`cargo metadata` should now include all of the non-optional suggested fields in the API guidelines (see section C-METADATA.)
2018-04-18 15:08:18 +07:00
Alex Crichton 039ca019d7 Bump version of filetime dependency 2018-04-17 15:08:04 -07:00
bors 30bf81b575 Auto merge of #5361 - derekdreery:issue_5345, r=matklad
Fix issue 5345

Fixes #5345.

Also adds some docs and Debug impls.
2018-04-17 13:39:04 +00:00
bors d0829a2e47 Auto merge of #5359 - matklad:rustc-cache, r=alexcrichton
Rustc cache

This implements rustc caching, to speed-up no-op builds.

The cache is per-project, and stored in `target` directory. To implement this, I had to move `rustc` from `Config` down to `BuildConfig`.

closes https://github.com/rust-lang/cargo/issues/5315
2018-04-16 17:23:53 +00:00
Aleksey Kladov 501823b0bb Handle non-rustup cargo + rustup rustc in rustc cache 2018-04-16 18:51:31 +03:00
Richard Dodd 066f9a02c9 Better test description 2018-04-15 14:00:36 +01:00
Richard Dodd 466196959f [Wip] fix issue 5345 2018-04-15 13:56:22 +01:00
Andy Russell 2efeeda17b
include package metadata in cargo metadata
Fixes #4819.
2018-04-14 15:07:23 -04:00
Aleksey Kladov c473479ab0 Add env-var to suppress rustc caching 2018-04-14 14:09:23 +03:00
Aleksey Kladov 6b1dc52b86 Speedup no-op builds by caching rustc invocations 2018-04-14 13:39:59 +03:00
Dirkjan Ochtman 90954d700c Correct formatting with cargo fmt 2018-04-13 19:59:55 +02:00
Aleksey Kladov 8d0b31b975 New semantics for --features flag
Historically, feature-related flags like `--all-features`,
`--no-default-features` and `--features` operated on the *current*
package. That is, `cargo --package foo --feature feat` would activate
`feat` for the package at the current working directory, and not for the
`foo` package. `-Z package-features` flag implements the more obvious
semantics for this combination of flags. This changes behavior, and that
is why we want to start with an unstable opt-in. The changes are:

* `--feature` flag affects the selected package. It is an error to
  specify `--feature` with more than a single `-p`, or with `-p` outside
  workspace (the latter could work in theory, but would be hard to
  implement).

* `--all-features` and `--no-default-features` affect all selected
  packages, and not the one at cwd.

* The package in `cwd` is not implicitly enabled when doing feature
  selection. That is, `cargo build -Z package-features -p foo` could
  select *less* features for various packages than `cargo build -p foo`.
2018-04-13 17:36:09 +03:00
Dirkjan Ochtman 5c241e1027 Correct formatting with cargo fmt 2018-04-11 23:16:17 +02:00
Dale Wijnand d8f78286f1
more cargo install usage adaptations in the same tests 2018-04-10 16:34:47 +01:00
Dale Wijnand 6df5210253
adapt legitimate cargo install usage to avoid the new warning/error 2018-04-10 16:05:18 +01:00
Dale Wijnand 3ba58ae987
add the inverse is_not has_installed_exe assertion 2018-04-10 15:13:26 +01:00
Dale Wijnand e201a8949c
warn in 2015, error in 2018 2018-04-10 15:10:38 +01:00
Dale Wijnand 6086f26f91
enable cargo edition feature & bump to 2018 2018-04-10 06:44:59 +01:00
Dale Wijnand 4676820fea
Warn about cargo installing the cwd in 2018 edition
Fixes #5327
2018-04-10 01:37:12 +01:00
Aleksey Kladov 53f8501286 Properly use unstable options for out-dir 2018-04-08 14:47:35 +03:00
Alex Crichton c7a11056e2 Fix another issue of poisoning too eagerly
This commit extends the fix in #5288 by moving the logic added farther up in the
loop over package dependencies. This means that we won't recursively look at
optional/dev path dependencies which aren't members of the workspace. This
should fix the new issue that came up in #5257

Closes #5257
2018-04-06 12:37:29 -07:00
bors b9aa315158 Auto merge of #5299 - ehuss:rustdoc-edition, r=matklad
Pass edition to rustdoc.

Fixes #5279.
2018-04-05 15:26:56 +00:00
Eric Huss 187bb0ad9a Don't use .arg() in test. 2018-04-05 06:04:45 -07:00
Eric Huss bbb2b92ef8 Pass edition to rustdoc.
Fixes #5279.
2018-04-05 05:39:50 -07:00
bors 75ec2d3a8d Auto merge of #5280 - klausi:clippy-191-trvials, r=matklad
chore(clippy): Simplify minor stuff found by clippy

Executed clippy 0.0.191, fixed the trivial stuff.
Filed https://github.com/rust-lang-nursery/rust-clippy/issues/2615 for all the format_err!() false positives.
2018-04-05 09:22:15 +00:00
memoryleak47 57a7e12679 fixed a few typos 2018-04-05 03:45:15 +02:00
Klaus Purer 51d19d01c3 chore(clippy): Fix test assertion and simplify code in crates-io 2018-04-04 23:09:59 +02:00
Dirkjan Ochtman 540bd4585f Revert serialization of features to string type 2018-04-04 20:07:57 +02:00
Dirkjan Ochtman 7b542268f5 Introduce FeatureValue enum for tracking feature types 2018-04-04 18:03:40 +02:00
bors 1d7a0bb5eb Auto merge of #5288 - alexcrichton:another-fix, r=matklad
Less aggressively poison sources on builds

Discovered in #5257 the changes in #5215 were slightly too aggressively
poisoning sources to require updates, thinking that a manifest changed when it
actually hadn't.

Non-workspace-member path dependencies with optional/dev-dependencies
don't show up in the lock file, so the previous logic would recognize this and
think that the dependency missing from the lock file was just added and would
require a registry update.

The fix in this commit effectively just skips all of these dependencies in
non-workspace members. This means that this will be slightly buggy if an
optional dependency that's activated is added, but that's hopefully something we
can tackle later.

Closes #5257
2018-04-03 23:41:50 +00:00
Alex Crichton 0790db9888 Less aggressively poison sources on builds
Discovered in #5257 the changes in #5215 were slightly too aggressively
poisoning sources to require updates, thinking that a manifest changed when it
actually hadn't.

Non-workspace-member path dependencies with optional/dev-dependencies
don't show up in the lock file, so the previous logic would recognize this and
think that the dependency missing from the lock file was just added and would
require a registry update.

The fix in this commit effectively just skips all of these dependencies in
non-workspace members. This means that this will be slightly buggy if an
optional dependency that's activated is added, but that's hopefully something we
can tackle later.

Closes #5257
2018-04-03 14:35:02 -07:00
Aleksey Kladov c9191180e1 Fix tests for mac 2018-04-03 21:02:43 +03:00
Aleksey Kladov b7976d1e37 Test out-dir edge cases 2018-04-03 16:08:09 +03:00
Aleksey Kladov 028a7b6306 Feature gate --out-dir 2018-04-03 15:52:45 +03:00
Aleksey Kladov 5baac6b3b8 Implement --out-dir option 2018-04-03 15:52:21 +03:00
Kurtis Nusbaum 3bbe93cef6 rename epoch to edition 2018-04-01 11:01:28 -07:00
bors 59e6b6ca24 Auto merge of #5269 - orestisf1993:issue-5265, r=matklad
cargo_new: remove redundant leading new lines from ignore files

Only add a leading new line in `.gitignore`/`.hgignore`/`.ignore` files when
the file existed before `cargo new`.

Fixes #5265.
2018-03-31 14:51:14 +00:00
Orestis Floros dbb1abd814
cargo_new: remove redundant leading new lines from ignore files
Only add a leading new line in .gitignore/.hgignore/.ignore files when
the file existed before 'cargo new'.

Fixes #5265.
2018-03-31 17:40:44 +03:00
Klaus Purer 9af095adab tests(help): Fix assertion by using the full line text 2018-03-31 11:33:14 +02:00
Klaus Purer a4104914ea tests(help): Add test for -Z help output 2018-03-31 11:19:28 +02:00
Aleksey Kladov 31e6c96848 Restore --features args for cargo rustdoc
It was accidentally omited when migrating to clap
2018-03-28 13:45:20 +03:00
bors d079a10b79 Auto merge of #5205 - gibix:i2773, r=alexcrichton
fix #2773 with new precise encode

Changed the precise encode from <pkg>=<precise> to <pkg>=<present_version>-><future_version> in order to check the correct requirements.

cc @lu-zero
2018-03-27 12:19:45 +00:00
bors 715fc78caa Auto merge of #5228 - phil-opp:target-spec, r=alexcrichton
Add support for absolute target.json paths

Builds upon https://github.com/rust-lang/rust/pull/49019 with the goal to provide a solution to https://github.com/rust-lang/cargo/issues/4905.

This PR does two things:

~~1. It appends a hash of the target path to the target folder name if a `*.json` path is passed as `--target`, like it's done in https://github.com/rust-lang/rust/pull/49019. This helps differentiating targets with the same JSON file name and avoids sysroot clashes in `xargo`.~~ See https://github.com/rust-lang/cargo/pull/5228#discussion_r176827531
2. It canonicalizes the passed target path (if it's a `*.json` path), so that the path stays valid when building dependencies and setting the `RUST_TARGET_PATH` environment variable is no longer necessary.
2018-03-26 13:00:26 +00:00
Bastien Orivel 8daf81e193 Replace tempdir by tempfile
The former has been deprecated in favor of the latter
2018-03-26 13:29:02 +02:00
Philipp Oppermann 6ab70197e5 Add custom target tests 2018-03-25 12:53:22 +02:00
gibix 1a26e86cc7
add precise test 2018-03-24 20:04:19 +01:00
Eh2406 a7a1341cf5 address suggestions 2018-03-24 11:32:26 -04:00
Eh2406 91c062ee17 test the new backtracking does all of its bookkeeping 2018-03-24 11:32:24 -04:00
Eh2406 efefe00177 problematic extension and solution 2018-03-24 11:31:38 -04:00
Eh2406 66e3d1c345 Add a test for https://github.com/rust-lang/cargo/issues/4810#issuecomment-357553286 2018-03-23 17:23:33 -04:00
bors bcd0300f0e Auto merge of #5200 - klausi:minimal_versions, r=Eh2406
feat(resolver): Add CLI option to resolve minimal version dependencies

Fixes #4100

Test cases are still missing. We need to come up with a plan what cases we want to cover.

Thanks a lot to @Eh2406 for very helpful instructions to kick this off.
2018-03-23 19:20:10 +00:00
Klaus Purer a38184ffe9 tests(resolver): Group integration test with other minimal version test 2018-03-23 20:06:49 +01:00
Klaus Purer 131c3e2891 tests(resolver): Add integration test for -Z minimal-versions 2018-03-23 19:58:56 +01:00
Klaus Purer 115d356d58 fix(resolver): Preserve lock file when sorting for minimal versions, document tests 2018-03-23 18:28:51 +01:00
Lukas Lueg 81ed0620bc Assert that Dependency::name is never empty, prevent 'install ""' from crashing
An explicit `cargo install ""` would cause clap to pass an empty crate-name,
leading to a panic(). We now assert() that Dependency::name is never the
empty string and prevent the situation in the first place by not allowing
the crate-name to be empty for `install`.

Fixes #5229
2018-03-23 16:07:01 +01:00
bors bc83efe323 Auto merge of #5217 - matklad:known-crate-types, r=alexcrichton
Preprobe info for known crate type

Previously, we've calculated the set of crate types to learn about by
recursively walking the graph of units. However, to actually know
dependencies of a unit exactly, we must know target specific info, and
we don't know it at this moment (in fact, we are trying calculating it).

Note that crate-type calculation is already lazy, we don't have to calc
all crate-types upfront. So, let's just scrape this info once for
well-known crate types, and fill whatever is left lazily.

@alexcrichton would this approach work at all? I think it would, if `KNOWN_CRATE_TYPES` are all available for all target-tripples we support. Is it a valid assumption?

The larger picture is that I am trying to make unit dependency resolution eager and move it into the separate file. I even got something working, but I have to run dependency resolution three times, because it is not exactly idempotent for various reasons, including this target-info stuff :)

```
    cx.prepare()?;
    cx.build_unit_map(units.clone())?; // resolve dependencies
    cx.probe_target_info(&units)?;
    cx.build_unit_map(units.clone())?; // resolve again
    cx.build_used_in_plugin_map(&units)?;
    custom_build::build_map(&mut cx, &units)?;
    cx.build_unit_map(units.clone())?; // and resolve one final time :)
```
2018-03-22 14:07:49 +00:00
bors b0a2252063 Auto merge of #5186 - infinity0:stricter-need-dev-deps, r=alexcrichton
Stricter need_dev_deps behaviour

The previous PR (#5012) contained an unnecessary work-around for behaviour of `--all-targets` that was misunderstood. This PR removes that work-around and adds some tests and comments to clarify the behaviour for future contributors, which may help to make easier a future fix for #5177 and #5178.
2018-03-21 14:19:11 +00:00
bors 4dde7264b5 Auto merge of #5204 - lukaslueg:issue5199, r=alexcrichton
Do not allow crate-type or proc-macro for [[bin]]-targets

Fixes #5199

This simply disallows `proc-macro` and `crate-type` to be set to anything for binary targets. Is this the best way to go or does a warning about the unused setting suffice?
2018-03-21 13:56:00 +00:00
Aleksey Kladov 9f7618b36c Preprobe info for known crate type
Previously, we've calculated the set of crate types to learn about by
recursively walking the graph of units. However, to actually know
dependencies of a unit exactly, we must know target specific info, and
we don't know it at this moment (in fact, we are trying calculating it).

Note that crate-type calculation is already lazy, we don't have to calc
all crate-types upfront. So, let's just scrape this info once for
well-known crate types, and fill whatever is left lazily.
2018-03-21 10:54:15 +03:00
Klaus Purer 5907a8bcfa docs(tests): Add comment 2018-03-20 23:05:20 +01:00
Klaus Purer f2610df06d tests(resolver): Add test for minimum dependency versions 2018-03-20 22:33:10 +01:00
Alex Crichton 0deaae9e52 Don't require cargo update when bumping versions
One historical annoyance I've always had with Cargo that I've found surprising
is that in some situations when you bump version numbers you'll have to end up
running `cargo update` later on to get everything to build. You get pretty wonky
error messages in this case as well saying a package doesn't exist when it
clearly does at a particular location!

I've had difficulty historically nailing down a test case for this but it looks
like we ironically already had one in our test suite and I also jury-rigged up
one from a case I ran into in the wild today.
2018-03-20 12:05:33 -07:00
Lukas Lueg 257c23323d Do not allow crate-type or proc-macro for [[bin]]-targets
in the current workspace.

Fixes #5199.
2018-03-20 16:51:03 +01:00
Aleksey Kladov deb1c1e15c Fix regression when passing arguments to subcommands 2018-03-20 03:34:37 +03:00
Aleksey Kladov a1735c7aff Regression tests for #5201
Better safe than sorry!
2018-03-19 23:51:49 +03:00
Ximin Luo 0bc1155753 Split tests, apparently cargo clean does not work well on windows 2018-03-19 18:20:54 +01:00
bors bdc6fc297c Auto merge of #5187 - Eh2406:faster_resolver, r=alexcrichton
Faster resolver: clean code and the `backtrack_stack`

This is a small extension to #5168 and is inspired by https://github.com/rust-lang/cargo/pull/4834#issuecomment-363518370

After #5168 these work (and don't on cargo from nightly.):
- `safe_core = "=0.22.4"`
- `safe_vault = "=0.13.2"`

But these don't work (and do on cargo from this PR.)
- `crust = "=0.24.0"`
- `elastic = "=0.3.0"`
- `elastic = "=0.4.0"`
- `elastic = "=0.5.0"`
- `safe_vault = "=0.14.0"`

It took some work to figure out why they are not working, and make a test case.

This PR remove use of `conflicting_activations` before it is extended with the conflicting from next.
https://github.com/rust-lang/cargo/pull/5187#issuecomment-373830919
However the `find_candidate(` is still needed so it now gets the conflicting from next before being called.

It often happens that the candidate whose child will fail leading to it's failure, will have older siblings that have already set up `backtrack_frame`s. The candidate knows that it's failure can not be saved by its siblings, but sometimes we activate the child anyway for the error messages. Unfortunately the child does not know that is uncles can't save it, so it backtracks to one of them. Leading to a combinatorial loop.

The solution is to clear the `backtrack_stack` if we are activating just for the error messages.

Edit original end of this message, no longer accurate.
#5168 means that when we find a permanent problem we will never **activate** its parent again. In practise there afften is a lot of work and `backtrack_frame`s between the problem and reactivating its parent. This PR removes `backtrack_frame`s where its parent and the problem are present. This means that when we find a permanent problem we will never **backtrack** into it again.

An alternative is to scan all cashed problems while backtracking, but this seemed more efficient.
2018-03-17 17:49:24 +00:00
Aleksey Kladov e5971b935c Slightly improve ergonomics of writing Cargo tests 2018-03-17 00:08:23 +03:00
bors 8cc8f3bd0a Auto merge of #5192 - matklad:hash-set-all-the-way-down, r=alexcrichton
Avoid intermediate vector

Just a microoptimization to avoid intermediate `Vec`
2018-03-16 16:06:28 +00:00
Aleksey Kladov 116ecaa635 Avoid intermediate vector 2018-03-16 18:09:44 +03:00
bors d6c3983fe3 Auto merge of #5196 - matklad:clapclapclap, r=alexcrichton
Fix a regression with parsing multivalue options

By default, clap interprets

```
cargo run --bin foo bar baz
```

as

```
cargo run --bin foo --bin bar --bin baz
```

This behavior is different from docopt and does not play nicely with
positional arguments at all. Luckily, clap has a flag to get the
behavior we want, it just not the default! It will become the default in
the next version of clap, but, until that time, we should be careful
when using the combination of `.long`, `.value_name` and
`.multiple(true)`, and don't forget to specify `.number_of_values(1)` as
well.

@alexcrichton I'd love to merge this fix before updating cargo at rust-lang/rust :)
2018-03-16 15:08:24 +00:00
Aleksey Kladov 70ff33a537 Fix a regression with parsing multivalue options
By default, clap interprets

```
cargo run --bin foo bar baz
```

as

```
cargo run --bin foo --bin bar --bin baz
```

This behavior is different from docopt and does not play nicely with
positional arguments at all. Luckily, clap has a flag to get the
behavior we want, it just not the default! It will become the default in
the next version of clap, but, until that time, we should be careful
when using the combination of `.long`, `.value_name` and
`.multiple(true)`, and don't forget to specify `.number_of_values(1)` as
well.
2018-03-16 17:35:13 +03:00
Aleksey Kladov 81713956f3 Deny warnings in tests 2018-03-16 12:32:31 +03:00
Eh2406 1291c50e86 cargo +stable fmt 2018-03-15 15:02:40 -04:00
Eh2406 617856ec2b add a test 2018-03-15 13:30:42 -04:00
Ximin Luo 0bf8e541db Add tests for --all-targets 2018-03-15 17:08:40 +01:00
Ximin Luo 89d274875f Revert "Work around #5134 for now"
This reverts commit d46db71b3f.
2018-03-15 17:05:13 +01:00
bors b3df526dc5 Auto merge of #5180 - alexcrichton:transitive-update, r=matklad
Don't abort resolution on transitive updates

This commit is directed at fixing #4127, allowing the resolver to automatically
perform transitive updates when required. A few use casese and tagged links are
hanging off #4127 itself, but the crux of the issue happens when you either add
a dependency or update a version requirement in `Cargo.toml` which conflicts
with something listed in your `Cargo.lock`. In this case Cargo would previously
provide an obscure "cannot resolve" error whereas this commit updates Cargo to
automatically perform a conservative re-resolution of the dependency graph.

It's hoped that this commit will help reduce the number of "unresolvable"
dependency graphs we've seen in the wild and otherwise make Cargo a little more
ergonomic to use as well. More details can be found in the source's comments!

Closes #4127
2018-03-15 15:22:32 +00:00
Alex Crichton 51d235606a Don't abort resolution on transitive updates
This commit is directed at fixing #4127, allowing the resolver to automatically
perform transitive updates when required. A few use casese and tagged links are
hanging off #4127 itself, but the crux of the issue happens when you either add
a dependency or update a version requirement in `Cargo.toml` which conflicts
with something listed in your `Cargo.lock`. In this case Cargo would previously
provide an obscure "cannot resolve" error whereas this commit updates Cargo to
automatically perform a conservative re-resolution of the dependency graph.

It's hoped that this commit will help reduce the number of "unresolvable"
dependency graphs we've seen in the wild and otherwise make Cargo a little more
ergonomic to use as well. More details can be found in the source's comments!

Closes #4127
Closes #5182
2018-03-15 07:44:35 -07:00
Aleksey Kladov 005bd4b4fb Add a helper method to show stdout/err in tests 2018-03-15 10:52:42 +03:00
Aleksey Kladov b0c181d91c Prettify rustfmted single-line strings 2018-03-14 17:48:44 -07:00
Alex Crichton 1e6828485e cargo fmt 2018-03-14 17:48:23 -07:00
bors 1eb4c8f1b4 Auto merge of #5181 - alexcrichton:selectively-write-dep-info, r=matklad
Don't rewrite dep-info files if they don't change

Similar to how we treat lock files, read the contents, compare, and if they're
the same don't actually write the file.

Closes #5172
2018-03-14 22:17:18 +00:00
bors 83a3084cdd Auto merge of #5179 - matklad:uplink-pdb, r=alexcrichton
Copy `.pdb` files to `target` directory

`.pdb` files are for windows debug info (unlike on linux, debug info is
in a separate file). Windows executable actually hard-code paths to
`.pdb` files, so debugging mvsc rust programs works even without this
patch. However, if you want to distribute the executable to other
machines, you'd better distribute both `foo.exe` and `foo.pdb`, because
absolute paths won't work on another machine. Having same-named .pdb
file alongside the binary would work though.

closes #4960
2018-03-14 21:49:10 +00:00
Aleksey Kladov f930609404 Don't check for filenames in message-format tests
Depending on the OS, there might be an additional artifacts for
debuginfo (dSYM folder for macs, .pbd file for windows). Given that we
can't disable `.pdb` for windows[1], let's just ignore all filenames!

[1]: https://github.com/rust-lang/rust/pull/28505)
2018-03-15 00:37:26 +03:00
Alex Crichton f60567666f Don't rewrite dep-info files if they don't change
Similar to how we treat lock files, read the contents, compare, and if they're
the same don't actually write the file.

Closes #5172
2018-03-14 13:27:54 -07:00
Aleksey Kladov 9c0d3f2980 Copy .pdb files to target directory
`.pdb` files are for windows debug info (unlike on linux, debug info is
in a separate file). Windows executable actually hard-code paths to
`.pdb` files, so debugging mvsc rust programs works even without this
patch. However, if you want to distribute the executable to other
machines, you'd better distribute both `foo.exe` and `foo.pdb`, because
absolute paths won't work on another machine. Having same-named .pdb
file alongside the binary would work though.

closes #4960
2018-03-14 22:31:19 +03:00
bors 1891a62d5c Auto merge of #5175 - matklad:conv, r=alexcrichton
Use conventions to specify the integration tests
2018-03-14 18:00:32 +00:00
bors 3a06fde076 Auto merge of #5168 - Eh2406:faster_resolver, r=alexcrichton
Faster resolver: Cache past conflicting_activations, prevent doing the same work repeatedly.

This work is inspired by @alexcrichton's [comment](https://github.com/rust-lang/cargo/issues/4066#issuecomment-303912744) that a slow resolver can be caused by all versions of a dependency being yanked. Witch stuck in my brain as I did not understand why it would happen. If a dependency has no candidates then it will be the most constrained and will trigger backtracking in the next tick. Eventually I found a reproducible test case. If the bad dependency is deep in the tree of dependencies then we activate and backtrack `O(versions^depth)`  times. Even tho it is fast to identify the problem that is a lot of work.

**The set up:**
1. Every time we backtrack cache the (dep, `conflicting_activations`).
2. Build on the work in #5000, Fail to activate if any of its dependencies will just backtrack to this frame. I.E. for each dependency check if any of its cached `conflicting_activations` are already all activated. If so we can just skip to the next candidate. We also add that bad `conflicting_activations` to our set of  `conflicting_activations`, so that we can...

**The pay off:**
 If we fail to find any candidates that we can activate in lite of 2, then we cannot be activated in this context, add our (dep, `conflicting_activations`) to the cache so that next time our parent will not bother trying us.

I hear you saying "but the error messages, what about the error messages?" So if we are at the end `!has_another` then we disable this optimization. After we mark our dep as being not activatable then we activate anyway. It won't resolve but it will have the same error message as before this PR. If we have been activated for the error messages then skip straight to the last candidate, as that is the only backtrack that will end with the user.

I added a test in the vain of #4834. With the old code the time to run was `O(BRANCHING_FACTOR ^ DEPTH)` and took ~3min with DEPTH = 10; BRANCHING_FACTOR = 5; with the new code it runs almost instantly with 200 and 100.
2018-03-14 16:19:30 +00:00
Aleksey Kladov cbd14ee8f0 Use conventions to specify the integration tests 2018-03-14 14:55:19 +03:00
Eh2406 d903259423 test that cashing works with constraints correctly 2018-03-13 11:16:10 -04:00
bors 3cfb23bc56 Auto merge of #5152 - matklad:clap, r=alexcrichton
Clap

Reopening of #5129

So, looks like all tests are 🍏 on my machine!

I definitely want to refactor it some more, and also manually checked that we haven't regressed any help messages, but all the major parts are in place already.
2018-03-13 14:46:45 +00:00
Eh2406 61e78c10f1 make sure cashing works whether there is an answer or not 2018-03-12 17:36:02 -04:00
Aleksey Kladov 74f4089387 Fix spelling of quiet 2018-03-12 23:08:49 +03:00
Eh2406 5ae3468d74 if we are just here_for the error_messages then only try the last candidate 2018-03-11 22:21:38 -04:00
Eh2406 d8cb25e5ba cache past conflicting_activations use them to prevent doing the same work repeatedly 2018-03-11 22:21:37 -04:00
Eh2406 7515d2d9c8 this test is slow because it runs the same searches repeatedly 2018-03-11 22:21:37 -04:00
Aleksey Kladov a64df78ea6 Relax tests for windows
On windows, clap prints `cargo.exe` rather than just `cargo`.
2018-03-10 18:46:32 +03:00
Tatsuyuki Ishi db58fd709a
Remove unused import 2018-03-10 15:21:25 +09:00
bors d147e10374 Auto merge of #5126 - gilescope:cycle-error-message, r=alexcrichton
Error message for package "depends on itself" lists the packages in the cycle.

I got a cycle while trying to build someone else's code and cargo's error message didn't point me in the right direction, just mentioned there was a cycle. I thought we could be a bit more helpful.

Don't know what you think of {:#?} as the display but it seemed minimal code so I thought I'd start with that. I could compress the output to one package per line if preferred.
2018-03-09 19:40:03 +00:00
Aleksey Kladov 67968e6b0e Validate that jobs argument is a number 2018-03-09 11:05:47 +03:00
Aleksey Kladov 16bde4e0ae Unwind stack for cli errors 2018-03-09 10:43:00 +03:00
Aleksey Kladov cc3ce0007d Fix --explain 2018-03-08 23:31:56 +03:00
Aleksey Kladov 0470d77575 Support list subcommand
All tests are green 🎉
2018-03-08 23:31:56 +03:00
Aleksey Kladov 93875b88da Support aliases 2018-03-08 23:31:56 +03:00
Aleksey Kladov 6783272a82 Fix more tests by updating error messages 2018-03-08 23:31:56 +03:00
Aleksey Kladov 89c6d7761f Unignore test which now passes 2018-03-08 23:31:56 +03:00
Aleksey Kladov af88c9f203 Disable cargo help -h 2018-03-08 23:31:56 +03:00
Aleksey Kladov 63d4e5c8b2 Fix verify-project command 2018-03-08 23:31:56 +03:00
Aleksey Kladov 35365a6f39 Support built-in aliases 2018-03-08 23:31:56 +03:00
Aleksey Kladov 81ce3e1bef Support external subcommands 2018-03-08 23:31:56 +03:00
Aleksey Kladov 4d3ca92150 Use exit code 1 for command line parsing errors
Note that while we use 101 in majority of cases, sometimes we use 1 as
well.
2018-03-08 23:31:56 +03:00
Aleksey Kladov 31ea0d93f7 Fix some trivially fixable tests 2018-03-08 23:31:56 +03:00
Aleksey Kladov c327245ca5 Drop old commands 2018-03-08 23:31:56 +03:00
Aleksey Kladov 666e232b59 Move the rest of the commands to clap 2018-03-08 23:30:47 +03:00
Aleksey Kladov 444101a6b3 Move search to clap 2018-03-08 23:30:47 +03:00
Aleksey Kladov 8e8e924e3f Move rustc to clap 2018-03-08 23:30:47 +03:00
Aleksey Kladov 7bf1619c01 Move run to clap 2018-03-08 23:30:47 +03:00
Aleksey Kladov 062a6e7a08 Move new to clap 2018-03-08 23:30:46 +03:00
Aleksey Kladov 6022d022ab Move metadata to clap 2018-03-08 23:30:46 +03:00
Aleksey Kladov 57789d7ddc Move install to clap 2018-03-08 23:30:46 +03:00
Aleksey Kladov 4131bdbe72 Move init to clap 2018-03-08 23:30:46 +03:00
Aleksey Kladov 0ac7251831 Move check to clap 2018-03-08 23:30:46 +03:00
Aleksey Kladov 178b16d12b Temporarly ignore some tests 2018-03-08 23:30:46 +03:00
Giles Cope 74deb8c96d Switch to exhaustive matches in tests. 2018-03-08 18:37:30 +00:00
Giles Cope 32c7ac144b As pointed out by Jacob, we can display the ordered cycle in the error message. 2018-03-07 22:56:47 +00:00
bors 879f48324d Auto merge of #5012 - infinity0:pr4988, r=alexcrichton
Don't require dev-dependencies when not needed in certain cases

Specifically, when running `cargo install` and add a flag for this behaviour in `cargo build`.

This closes #4988.
2018-03-07 15:39:24 +00:00
Ximin Luo d46db71b3f Work around #5134 for now 2018-03-07 14:46:43 +01:00
bors dd4f46e7dd Auto merge of #5135 - matklad:drop-ignored-tests, r=alexcrichton
Drop ignored tests

r? @alexcrichton

These tests are ignored, so its better to remove them. `run` does not supports `--bins` argument, so I've left a single test that checks specifically for this.

cc https://github.com/rust-lang/cargo/pull/3901
2018-03-06 22:34:32 +00:00
Aleksey Kladov 96a4aa836e Drop ignored tests 2018-03-06 23:28:52 +03:00
Ximin Luo 31f6f84eff Merge remote-tracking branch 'upstream/master' into pr4988 2018-03-06 19:56:35 +01:00
Giles Cope 3cd7708774 Neater error message. Tests now check the cycle is output. 2018-03-06 09:30:37 +00:00
Giles Cope 2ee2741e80 Error message for package cycles lists the packages in the cycle. 2018-03-06 00:41:21 +00:00
Alex McArther 6a2b6468ca Repair the other metadata tests 2018-03-05 06:36:12 -08:00
Alex McArther 3904562fe7 Emit resolve.features in "cargo metadata" 2018-03-04 22:04:27 -08:00
Alex Crichton d6d1f3ab7d Update a test to not clone the real index
A local index should work ok!
2018-03-04 12:51:31 -08:00
Ximin Luo 9c5eecd419 Merge remote-tracking branch 'upstream/master' into pr4988 2018-03-03 12:56:08 +01:00
bors 4429f4efa1 Auto merge of #5110 - alexcrichton:reset-harder, r=matklad
Try a lot harder to recover corrupt git repos

We've received a lot of intermittent bug reports historically about corrupt git
repositories. These inevitably happens as Cargo is ctrl-c'd or for whatever
other reason, and to provide a better user experience Cargo strives to
automatically handle these situations by blowing away the old checkout for a new
update.

This commit adds a new test which attempts to pathologically corrupt a git
database and checkout in an attempt to expose bugs in Cargo. Sure enough there
were some more locations that we needed to handle gracefully for corrupt git
checkouts. Notable inclusions were:

* The `fetch` operation in libgit2 would fail due to corrupt references. This
  starts by adding an explicit whitelist for classes of errors coming out of
  `fetch` to auto-retry by blowing away the repository. We need to be super
  careful here as network errors commonly come out of this function and we don't
  want to too aggressively re-clone.

* After a `fetch` succeeded a repository could fail to actual resolve a
  git reference to the actual revision we want. This indicated that we indeed
  needed to blow everything away and re-clone entirely again.

* When creating a checkout from a database the `reset` operation might fail due
  to a corrupt local database of the checkout itself. If this happens we needed
  to just blow it away and try again.

There's likely more lurking situations where we need to re-clone but I figure we
can discover those over time.
2018-03-02 23:37:29 +00:00
Alex Crichton c933673e7d Try a lot harder to recover corrupt git repos
We've received a lot of intermittent bug reports historically about corrupt git
repositories. These inevitably happens as Cargo is ctrl-c'd or for whatever
other reason, and to provide a better user experience Cargo strives to
automatically handle these situations by blowing away the old checkout for a new
update.

This commit adds a new test which attempts to pathologically corrupt a git
database and checkout in an attempt to expose bugs in Cargo. Sure enough there
were some more locations that we needed to handle gracefully for corrupt git
checkouts. Notable inclusions were:

* The `fetch` operation in libgit2 would fail due to corrupt references. This
  starts by adding an explicit whitelist for classes of errors coming out of
  `fetch` to auto-retry by blowing away the repository. We need to be super
  careful here as network errors commonly come out of this function and we don't
  want to too aggressively re-clone.

* After a `fetch` succeeded a repository could fail to actual resolve a
  git reference to the actual revision we want. This indicated that we indeed
  needed to blow everything away and re-clone entirely again.

* When creating a checkout from a database the `reset` operation might fail due
  to a corrupt local database of the checkout itself. If this happens we needed
  to just blow it away and try again.

There's likely more lurking situations where we need to re-clone but I figure we
can discover those over time.
2018-03-02 15:32:24 -08:00
bors 078f333f10 Auto merge of #5095 - tdbgamer:master, r=matklad
Issue #5087

* remove Workspace::current_manifest
* remove incorrect logging
* move empty check to Packages::into_package_id_specs
* add test case mentioned in issue
2018-03-02 18:43:11 +00:00
Eh2406 d9c97debbb This test should pass if we have tried to update registry evan if the command otherwise fails 2018-03-02 08:49:42 -05:00
Timothy Bess 891d673764 Merge remote-tracking branch 'upstream/master' 2018-03-01 17:17:06 -05:00
bors 382967ad10 Auto merge of #5000 - Eh2406:i4347, r=alexcrichton
backtrack if can not activate

This is a fix for #4347
Unfortunately this too regressed error messages for the case that you specified a dependency feature that does not  exist.
@alexcrichton advice on improving the message?
2018-03-01 21:27:17 +00:00