Commit graph

2212 commits

Author SHA1 Message Date
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
Eric Huss
c3b477d495 Support --cap-lints in rustdoc. 2018-07-21 20:17:03 -07:00
Eric Huss
f41ee8908a Fix flakey test on MacOS.
`do_not_package_if_src_was_modified` can fail if the test runs too quickly
due to mac's filesystem time resolution.
2018-07-21 17:27:34 -07:00
bors
b4a245e6f4 Auto merge of #5751 - RalfJung:default-run, r=alexcrichton
cargo run: on nightly, advertise the default-run feature
2018-07-21 23:03:13 +00:00
Dale Wijnand
f8c9928cc1
Rework some test projects to use the "foo" default
Generally that means either switching "foo" and "bar" around (reversing
the arrow), or it means push "foo" to "bar" (and sometimes "bar" to
"baz", etc..) to free up "foo".

For trivia that leaves 80/1222 outliers, therefore 93.4% of test
project use the default. :)
2018-07-21 19:40:45 +01:00
Dale Wijnand
6da2ada26d
Migrate trailing calls to project with an argument
.. in docs, commented code & tests targetting non-macos.
2018-07-20 15:25:51 +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
Ralf Jung
d1372315b3 cargo run: on nightly, advertise the default-run feature 2018-07-20 12:48:47 +02:00
Dale Wijnand
d7d513e95e
Add tests/ProjectBuilder::at 2018-07-19 13:55:39 +01:00
bors
506eea76ed Auto merge of #5723 - alexcrichton:cargo-fix, r=ehuss
Import `cargo fix` directly in to Cargo

This commit imports the `cargo fix` subcommand in rust-lang-nursery/rustfix
directly into Cargo as a subcommand. This should allow us to ease our
distribution story of `cargo fix` as we prepare for the upcoming 2018 edition
release.

It's been attempted here to make the code as idiomatic as possible for Cargo's
own codebase. Additionally all tests from cargo-fix were imported into Cargo's
test suite as well. After this lands and is published in nightly the `cargo-fix`
command in rust-lang-nursery/rustfix will likely be removed.

cc rust-lang/rust#52272
2018-07-17 16:28:32 +00:00
Alex Crichton
b02ba3771e Import cargo fix directly in to Cargo
This commit imports the `cargo fix` subcommand in rust-lang-nursery/rustfix
directly into Cargo as a subcommand. This should allow us to ease our
distribution story of `cargo fix` as we prepare for the upcoming 2018 edition
release.

It's been attempted here to make the code as idiomatic as possible for Cargo's
own codebase. Additionally all tests from cargo-fix were imported into Cargo's
test suite as well. After this lands and is published in nightly the `cargo-fix`
command in rust-lang-nursery/rustfix will likely be removed.

cc rust-lang/rust#52272
2018-07-16 21:58:58 -07:00
bors
558eee4fbc Auto merge of #5732 - Eh2406:sort_unstable, r=alexcrichton`,
most sorts can be unstable

Inspired by [this](94f7058a48/src/bin/cargo/main.rs (L112-L122)) witch was improved in #5691, I did a quick review of `sort`s in the code. Most can be unstable, some can use a `_key` form, and none had unnecessary allocation.
2018-07-16 21:45:15 +00:00
Eh2406
c74aa9490e most sorts can be unstable 2018-07-16 16:57:38 -04:00
bors
e325bff3c4 Auto merge of #5710 - RalfJung:default-run, r=alexcrichton
implement default-run option to set default binary for cargo run

The implementation is not pretty but as good as I could make it. The fact that all this logic in `cargo_run` is for diagnosis only and essentially just re-implements the filtering done elsewhere really threw me off.

Fixes #2200
2018-07-16 20:47:38 +00:00
Ralf Jung
04abd5ef2f fix code nits 2018-07-16 21:48:14 +02:00
Ralf Jung
579e0348d7 order of lits of binaries is not stable 2018-07-16 21:48:14 +02:00
Ralf Jung
c955c60e6b feature-gate default-run 2018-07-16 21:48:14 +02:00
Ralf Jung
5936f6ae9e implement default-run option to set default binary for cargo run 2018-07-16 21:48:14 +02:00
bors
fefbb68f89 Auto merge of #5691 - Eh2406:hyphen-underscore, r=alexcrichton
Make index lookup robust to _ vs -, but don't let the user get it wrong.

This does a brute force search thru combinations of hyphen and underscores to allow queries of crates to pass the wrong one.

This is a small first step of fixing #2775

Where is best to add test?
2018-07-16 19:35:38 +00:00
Eh2406
95b4640b32 only suggest lev_distance < 4 2018-07-16 15:28:53 -04:00
bors
06721dd6b6 Auto merge of #5543 - roblabla:doc-private-items, r=alexcrichton
Add document-private-items flag to cargo doc

Add a `--document-private-items` flag to `cargo doc`, that mimics the equivalent `cargo rustdoc -- --document-private-items`. This works by relaying the flag to the underlying rustdoc call.
2018-07-16 00:26:07 +00:00
roblabla
7757753b28 Verify that private items were actually documented 2018-07-15 20:22:22 +02:00
roblabla
4a11afc59f Add a test for document-private-items 2018-07-15 20:10:01 +02:00
bors
caf810b8f1 Auto merge of #5726 - ehuss:warn-virtual-keys, r=alexcrichton
Warn about unused virtual manifest keys.

Fixes #4243
2018-07-15 17:20:14 +00:00
Eh2406
c01a189980 recv_timeout was stable in 1.12 2018-07-14 22:50:00 -04:00
Eric Huss
688a4fa6b3 Warn about unused virtual manifest keys.
Fixes #4243
2018-07-14 09:20:15 -07:00
Eh2406
98e1bdb762 oops... 2018-07-13 18:05:24 -04:00
bors
738c42d4dc Auto merge of #5715 - euclio:third-party-help, r=alexcrichton
help: display external subcommand help

When invoking `cargo help <subcommand>`, if the subcommand isn't found, but it *is* an external subcommand, call that subcommand with `--help`.

A test should probably be written for this, but I'm not sure how best to mock an external subcommand.
2018-07-13 22:02:09 +00:00
Andy Russell
9e41e383ac
help: display external subcommand help 2018-07-13 15:09:00 -04:00
Alex Crichton
f9d4927b26 Partially revert dep changes in #5651
Some logic which was tweaked around the dependencies of build script targets was
tweaked slightly in a way that causes cargo to stack overflow by accientally
adding a dependency loop. This commit implements one of the strategies discussed
in #5711 to fix this situation.

The problem here is that when calculating the deps of a build script we need the
build scripts of *other* packages, but the exact profile is somewhat difficult
to guess at the moment we're generating our build script unit. To solve this the
dependencies towards other build scripts' executions is added in a different
pass after all other units have been assembled. At this point we should know for
sure that all build script executions are in the dependency graph, and we just
need to add a few more edges.

Closes #5708
2018-07-13 10:54:22 -07:00
Eh2406
3f5036ae4d update test to get ci passing 2018-07-11 23:26:01 -04: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
3fafca1742 add test for wrong_case in cargo.toml 2018-07-09 18:02:46 -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
bors
2a39e6c537 Auto merge of #5680 - mikeyhew:fix-shell-quoting, r=alexcrichton
Fix the shell_quoting test

r? @alexcrichton

add-on to #5666
- Added `mod shell_quoting;` to testsuite/main.rs, so it actually runs
- fixed bugs in the test
2018-07-06 14:21:24 +00:00
Michael Hewson
2e17235d9b add MSYSTEM=1 to shell_quoting test
- this should make it use unix escaping on windows
2018-07-06 09:25:55 -04:00
bors
4a8495ca29 Auto merge of #5651 - ehuss:panic-rustdoc, r=matklad
Fix doctests linking too many libs.

Fixes #5650.  cc #5435

As part of my recent work on profiles, I introduced some situations where a
library can be compiled multiple times with different settings.  Doctests were
greedily grabbing all dependencies for a package, regardless of which target
is was for.  This can cause doctests to fail if it links multiple copies of
the same library.

One way to trigger this is `cargo test --release` if you have dependencies, a
build script, and `panic="abort"`.  There are other (more obscure) ways to
trigger it with profile overrides.
2018-07-05 20:06:19 +00:00
Alex Crichton
d1ef031a62 Fix cargo install using a workspace target dir
Closes #5662
2018-07-05 12:06:26 -07:00
Michael Hewson
d1cb78acc6 get the new test working
- Added `mod shell_quoting` to testsuite/main.rs
- fixed up errors in the test, now that the test suite knows about it
2018-07-04 11:04:10 -04:00
bors
592b253634 Auto merge of #5666 - mikeyhew:fix-shell-quoting, r=alexcrichton
[needs test] always shell-escape command arguments after failure

cc @joshtriplett
fixes #5665

Removes the `debug_string` method, in favour of always using the
`fmt::Display` impl. `debug_string` didn’t escape the command
arguments, so that’s why we ended up with unescaped arguments after
compilation failed.

Don't merge this yet, because I still want to add a regression test. I don't think there's any tests on shell quoting yet, so I'll probably add a new test file including tests for the "Running <command>" output too. I still have to figure out how to write tests, and don't have the energy to do that tonight 😴

I just wanted to say, by the way, I was pleasantly surprised with how clean the code is in this repo, especially compared to rustc. It made it really easy to find the relevant part of the code and implement these changes.
2018-07-03 22:18:05 +00:00
Michael Hewson
727684da74 added a test that feature=foo will be quoted
The doesn’t doesn’t seem to run when I run `cargo test` though
2018-07-03 14:19:48 -04:00
Aleksey Kladov
ddb9cedf32 Show lockfile parsing errors without --verbose
It is possible to get invalid lockfile after an automatic merge, so it
make sense to print a little bit more details by defaults than just
"failed to parse a lockfile".
2018-07-01 10:29:49 +03:00
Eric Huss
b248625cd9 cbfct: Take 3
Third attempt to fix race condition in changing_bin_features_caches_targets.
Previous fix for linux re-broke Windows
(https://ci.appveyor.com/project/rust-lang-libs/cargo/build/1.0.5004)
2018-06-30 10:59:38 -07:00
bors
94f7058a48 Auto merge of #5652 - Eh2406:masquerade_as_nightly_cargo, r=alexcrichton
skip test if not nightly; fix for #5648

closes #5648
The alternative was to use `set_var` to emulate `masquerade_as_nightly_cargo` but we worried that it would not get unset correctly. Although I think each test is its own process, so it should work.
2018-06-29 20:29:18 +00:00
bors
75c0d7ed98 Auto merge of #5669 - alexcrichton:less-build, r=matklad
Fix avoiding a rebuild when moving around a workspace

There's a case where Cargo will recompile a project even if the fingerprint
looks like it's fresh, when some output files are missing. This was intended to
cover the case where an output file was deleted manually or otherwise messed
with. The check here was a bit too eager, however. It checked not only the
actual output destination of the compiler but *also* the location that we hard
link the output file up to.

Due to recent changes in #5460 we don't always create the hard links for path
dependencies in the top-level dir, and this meant that if the library were
compiled and then tested later on the test may recompile the original library by
accident.

The fix in this commit is to cease looking for the hardlink if it exists or not.
This way we only check for the presence of the output file itself and only
recompile if that file is missing. The reason for this is that we
unconditionally relink files into place whether it's fresh or not, so we'll
always recreate the hard link anyway if it's missing.

cc rust-lang/rust#51717
2018-06-29 19:24:00 +00:00
Eh2406
75bb190664 default tests to stable and override where needed 2018-06-29 15:21:05 -04:00
Alex Crichton
4be5a44861 Fix avoiding a rebuild when moving around a workspace
There's a case where Cargo will recompile a project even if the fingerprint
looks like it's fresh, when some output files are missing. This was intended to
cover the case where an output file was deleted manually or otherwise messed
with. The check here was a bit too eager, however. It checked not only the
actual output destination of the compiler but *also* the location that we hard
link the output file up to.

Due to recent changes in #5460 we don't always create the hard links for path
dependencies in the top-level dir, and this meant that if the library were
compiled and then tested later on the test may recompile the original library by
accident.

The fix in this commit is to cease looking for the hardlink if it exists or not.
This way we only check for the presence of the output file itself and only
recompile if that file is missing. The reason for this is that we
unconditionally relink files into place whether it's fresh or not, so we'll
always recreate the hard link anyway if it's missing.

cc rust-lang/rust#51717
2018-06-29 12:17:41 -07:00
Ximin Luo
0774e97da3 Support cross-compile install 2018-06-28 18:57:24 -07:00