39 Commits

Author SHA1 Message Date
Dale Wijnand
689f412c2f
Resolve 2 needless_pass_by_value lint warnings
TIL Rust doesn't have equational reasoning.. :-/
(can't inline the new "exec" bindings)
2018-07-31 15:12:43 +01:00
Dale Wijnand
43b42d6f4c
Reorganise the testsuite crate module hierarchy
* Collapse the nested cargotest::support module into the cargotest
  module (merge the mod.rs's)
* Rename the cargotest module to support
* Nest the top-level hamcrest module into support
2018-07-22 08:46:44 +01:00
Dale Wijnand
7fe2fbc8a3
Remove the argument from the project test support function
By rewriting the tests, with rerast (https://github.com/google/rerast),
to use the newly introduced "at" method.

First I added the following temporary function to cargotest::support:

    pub fn project_foo() -> ProjectBuilder {
        project("foo")
    }

Then I defined the following rewrite.rs:

    use cargotest::support::{ project, project_foo };

    fn rule1(a: &'static str) {
        replace!(project("foo") => project_foo());
        replace!(project(a) => project_foo().at(a));
    }

Then I ran rerast:

    cargo +nightly rerast --rules_file=rewrite.rs --force --targets tests --file tests/testsuite/main.rs

Finally I searched and replaced the references to project_foo with
argument-less project (a little awkardly on macOS with a git clean).

    find tests -type f -exec sed -i -e 's/project_foo/project/g' {} +
    git clean -d tests
2018-07-20 13:31:50 +01:00
Eh2406
84cc3d8b09 allow each source to recommend packages that are close to a dependency 2018-07-11 12:46:52 -04:00
Eh2406
8a717d32db add test for wrong_case in registry 2018-07-10 15:34:04 -04:00
Eh2406
ea957da75a add the Cows back in and add a test to keep them 2018-07-07 11:12:22 -04:00
Eh2406
d5e75506c4 reduce allocation of temp strings 2018-07-06 15:44:25 -04:00
Eh2406
75bb190664 default tests to stable and override where needed 2018-06-29 15:21:05 -04: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
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
Simon Smith
dd0b7a2cda Add target directory parameter --target-dir 2018-04-23 18:23:48 -04:00
Klaus Purer
51d19d01c3 chore(clippy): Fix test assertion and simplify code in crates-io 2018-04-04 23:09:59 +02: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
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
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
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
116ecaa635 Avoid intermediate vector 2018-03-16 18:09:44 +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
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
Alex Crichton
1e6828485e cargo fmt 2018-03-14 17:48:23 -07:00
Eh2406
d903259423 test that cashing works with constraints correctly 2018-03-13 11:16:10 -04:00
Eh2406
61e78c10f1 make sure cashing works whether there is an answer or not 2018-03-12 17:36:02 -04: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
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
Alex Crichton
2a063798eb Drop outdated hamcrest dependency
This hasn't been updated in awhile and in general we've been barely using it.
This drops the outdated dependency and vendors a small amount of the
functionality that it provided. I think eventually we'll want to transition away
from this method of assertions but I wanted to get this piece in to avoid too
much churn in one commit.
2018-03-01 11:03:54 -08:00
Eh2406
834846901d add a test for cargo/issues/4347 2018-02-28 23:40:45 -05:00
Eh2406
68a40ad42b Merge remote-tracking branch 'origin/master' into links 2018-02-21 15:41:48 -05:00
André Rocha
c2ff988c9f Reorganize integration tests as one crate with many modules. Issue #4867. 2018-02-21 13:33:51 -05:00