82 Commits

Author SHA1 Message Date
Weihang Lo
633e5f0048
test: glob support for target selection 2020-10-05 01:24:39 +08:00
mchernyavsky
d649c66191 Add a term option to configure the progress bar 2020-09-16 22:32:31 +03:00
Eric Huss
9138d65e4c Create a dedicated module for help tests. 2020-08-03 12:17:58 -07:00
eonil
c5e13da69c Check workspace member existence as dir. 2020-07-22 14:03:13 +09:00
Matthias Krüger
6eefe3c236 fix clippy warnings 2020-06-04 00:55:45 +02:00
Eric Huss
e0f9643b0f Add support for rustdoc root URL mappings. 2020-05-26 10:44:57 -07:00
Alex Crichton
3fd28143de Support multiple --target flags on the CLI
This commit refactors the internals of Cargo to no longer have a
singular `--target` flag (and singular `requested_target` kind throught)
but to instead have a list. The semantics of multiple `--target` flags
is to build the selected targets for each of the input `--target` flag
inputs.

For now this is gated behind `-Zmultitarget` as an unstable features,
since I'm not entirely sure this is the interface we want. In general
it'd be great if we had a way to simply specify `Unit` structures of
what to build on the CLI, but we're in general very far away from that,
so I figured that this is probably sufficient at least for testing for
now.

cc #8156
2020-04-28 15:16:47 -07:00
bors
7d720ef051 Auto merge of #8062 - ehuss:tree, r=alexcrichton
Add `cargo tree` command.

This migrates [cargo-tree](https://github.com/sfackler/cargo-tree/) into Cargo as a built-in command. This is based on a recent master (4108d216ec), and should be mostly similar in functionality. There are a variety changes:

* `--all-targets` renamed to `--no-filter-targets` to avoid confusion with the `--all-targets` flag used in other Cargo commands with a different meaning.
* `--all`/`-a` renamed to `--no-dedupe` to avoid confusion with the `-all` flag which means "all workspace crates" in other Cargo commands.
* `--duplicate` renamed to `--duplicates` (with alias), just a personal preference.
* Added support for multiple roots (workspace support).
* Added the `--graph-features` flag for including features in the graph (to "explain" why a feature is enabled).
* Added `{f}` to format string to show features.
* Handles new feature resolver.
* Handles cyclical dev dependencies.
* Added a test suite.
* Dropped the dependency on petgraph, in favor of a simpler custom graph.

Closes #7286.
2020-04-09 19:53:41 +00:00
Eric Huss
54ace8af65 Merge -Zpackage-features2 and -Zpackage-features. 2020-04-08 14:06:09 -07:00
Eric Huss
c17bfcbdb2 Implement -Zpackage-features2 2020-04-04 18:04:03 -07:00
Alex Crichton
bac300bda0 Add support for -Cembed-bitcode=no
This commit is the Cargo half of support necessary for
rust-lang/rust#70458. Today the compiler emits embedded bytecode in
rlibs by default, but compresses it. This is both extraneous disk space
and wasted build time for almost all builds, so the PR in question there
is changing rustc to have a `-Cembed-bitcode` flag which, when enabled,
places the bitcode in the object file rather than an auxiliary file (no
extra compression), but also enables `-Cembed-bitcode=no` to disable
bitcode emission entirely.

This Cargo support changes Cargo to pass `-Cembed-bitcode=no` for almost
all compilations. Cargo will keep `lto = true` and such working by not
passing this flag (and thus allowing bitcode to get embedded), but by
default `cargo build` and `cargo build --release` will no longer have
any bitcode in rlibs which should result in speedier builds!

Most of the changes here were around the test suite and various
assertions about the `rustc` command lines we spit out. One test was
hard-disabled until we can get `-Cembed-bitcode=no` into nightly, and
then we can make it a nightly-only test. The test will then be stable
again once `-Cembed-bitcode=no` hits stable.

Note that this is intended to land before the upstream `-Cembed-bitcode`
change. The thinking is that we'll land everything in rust-lang/rust all
at once so there's no build time regressions for anyone. If we were to
land the `-Cembed-bitcode` PR first then there would be a build time
regression until we land Cargo changes because rustc would be emitting
uncompressed bitcode by default and Cargo wouldn't be turning it off.
2020-04-01 14:31:06 -07:00
Eric Huss
96a393719b Add cargo tree command. 2020-03-31 15:14:47 -07:00
Eric Huss
aa80a984c0 Add unit-graph JSON output. 2020-03-15 15:16:36 -07:00
Jane Lusby
b0351e4d87 Close the front door for clippy but open the back 2020-03-12 19:27:48 -07:00
Eric Huss
15ac82b677 Warn on Windows about reserved target names. 2020-03-02 16:04:25 -08:00
Eric Huss
7caa1612cf Add new feature resolver. 2020-02-20 12:04:28 -08:00
Eric Huss
0d44a8267b Rework internal errors. 2020-02-17 19:03:57 -08:00
Takayuki Nakata
5e152863f4 Load credentials and add tests for yank and owner commands 2020-01-09 22:22:32 +09:00
Takayuki Nakata
a28d9a1e2a Add test for cargo pkgid 2019-12-29 20:42:50 +09:00
Eric Huss
e7eda2f91f Implement config-include. 2019-12-19 09:44:02 -08:00
Eric Huss
91015d52ce Add --config CLI option. 2019-12-19 09:44:02 -08:00
Eric Huss
381251aa1f Config refactoring. 2019-12-19 09:44:01 -08:00
Takayuki Nakata
ba74297c20 Add a test for cargo locate-project 2019-12-10 09:18:12 +09:00
Eric Huss
83571aee56 Minor testsuite organization. 2019-11-24 18:42:45 -08:00
Igor Makarov
2a49ac94d0 suppress clippy lint inefficient_to_string - according to reviewers' preference 2019-11-12 10:57:13 +02:00
Igor Makarov
e8a8f76432 suppress clippy lint block_in_if_condition_stmt in the testsuite because fixing it upsets rustfmt 2019-11-12 10:56:07 +02:00
Dan Aloni
fb75361226 Merge remote-tracking branch 'origin/master' into custom-profile-pr-rfc 2019-09-21 08:10:31 +03:00
Eric Huss
8fadd2b9ce Fix -Ztimings with doc tests. 2019-09-20 14:56:52 -07:00
Dan Aloni
375a46f18b Merge remote-tracking branch 'origin/master' into custom-profile-pr-rfc 2019-09-18 08:56:13 +03:00
Alex Crichton
9115b2c326 Extract support directory to its own crate
Extract out all our test support code to its own standalone crate so it
can be shared between multiple test suites if necessary.
2019-09-16 11:47:09 -07:00
Dan Aloni
593641dc93 testsuite: introduce profile_custom
This suite of tests verifies various cases around the 'inherits'
keyword, and also verifies the relationship between profile overrides
and custom profiles.
2019-09-12 17:05:15 +03:00
Eric Huss
1f14fa3172 Basic standard library support. 2019-09-03 13:53:59 -07:00
Alex Crichton
45699e9f21 Add support for customizing JSON diagnostics from Cargo
Cargo has of #7143 enabled pipelined compilation by default which
affects how the compiler is invoked, especially with respect to JSON
messages. This, in some testing, has proven to cause quite a few issues
with rustbuild's current integration with Cargo. This commit is aimed at
adding features to Cargo to solve this issue.

This commit adds the ability to customize the stream of JSON messages
coming from Cargo. The new feature for Cargo is that it now also mirrors
rustc in how you can configure the JSON stream. Multiple
`--message-format` arguments are now supported and the value specified
is a comma-separated list of directives. In addition to the existing
`human`, `short`, and `json` directives these new directives have been
added:

* `json-render-diagnostics` - instructs Cargo to render rustc
  diagnostics and only print out JSON messages for artifacts and Cargo
  things.

* `json-diagnostic-short` - indicates that the `rendered` field of rustc
  diagnostics should use the "short" rendering.

* `json-diagnostic-rendered-ansi` - indicates that the `rendered` field of rustc
  diagnostics should embed ansi color codes.

The first option here, `json-render-diagnostics`, will be used by
rustbuild unconditionally. Additionally `json-diagnostic-short` will be
conditionally used based on the input to rustbuild itself.

This should be enough for external tools to customize how Cargo is
invoked and how all kinds of JSON diagnostics get printed, and it's
thought that we can relatively easily tweak this as necessary to extend
it and such.
2019-08-05 12:49:51 -07:00
Eric Huss
1c6d8bb415 Force clippy to run. 2019-07-20 13:20:11 -07:00
Jethro Beekman
0e0d968825 Update #[test] attribute on all tests in the testsuite
sed -i 's/^#\[test\]/#[cargo_test]/' $(rg -l '^#\[test\]')

Manual fixes:
* proc_macro::proc_macro_doctest
2019-06-07 12:41:26 -07:00
Jethro Beekman
a598309cb6 Don't rely on a thread local to uniquely create test roots 2019-06-07 12:41:25 -07:00
bors
0e38712d4d Auto merge of #6869 - alexcrichton:vendor, r=ehuss
Import the cargo-vendor subcommand into Cargo

This commit imports the external [alexcrichton/cargo-vendor
repository][repo] into Cargo itself. This means it will no longer be
necessary to install the `cargo-vendor` subcommand in order to vendor
dependencies. Additionally it'll always support the latest feature set
of Cargo as it'll be built into Cargo!

All tests were imported as part of this commit, but not all features
were imported. Some flags have been left out that were added later in
the lifetime of `cargo vendor` which seem like they're more questionable
to stabilize. I'm hoping that they can have separate PRs adding their
implementation here, and we can make a decision of their stabilization
at a later date.

The current man page for `cargo vendor -h` will look like:

    cargo-vendor
    Vendor all dependencies for a project locally

    USAGE:
	cargo vendor [OPTIONS] [--] [path]

    OPTIONS:
	-q, --quiet                    No output printed to stdout
	    --manifest-path <PATH>     Path to Cargo.toml
	    --no-delete                Don't delete older crates in the vendor directory
	-s, --sync <TOML>...           Additional `Cargo.toml` to sync and vendor
	    --respect-source-config    Respect `[source]` config in `.cargo/config`
	-v, --verbose                  Use verbose output (-vv very verbose/build.rs output)
	    --color <WHEN>             Coloring: auto, always, never
	    --frozen                   Require Cargo.lock and cache are up to date
	    --locked                   Require Cargo.lock is up to date
	-Z <FLAG>...                   Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details
	-h, --help                     Prints help information

    ARGS:
	<path>    Where to vendor crates (`vendor` by default)

    This cargo subcommand will vendor all crates.io and git dependencies for a
    project into the specified directory at `<path>`. After this command completes
    the vendor directory specified by `<path>` will contain all remote sources from
    dependencies specified. Additionally manifest beyond the default one can be
    specified with the `-s` option.

    The `cargo vendor` command will also print out the configuration necessary
    to use the vendored sources, which when needed is then encoded into
    `.cargo/config`.

Since this change is not importing 100% of the functionality of the
existing `cargo vendor` this change does run a risk of being a breaking
change for any folks using such functionality. Executing `cargo vendor`
will favor the built-in command rather than an external subcommand,
causing unimplemented features to become errors about flag usage.

[repo]: https://github.com/alexcrichton/cargo-vendor
2019-06-03 17:03:44 +00:00
Alex Crichton
3842d8e6f2 Import the cargo-vendor subcommand into Cargo
This commit imports the external [alexcrichton/cargo-vendor
repository][repo] into Cargo itself. This means it will no longer be
necessary to install the `cargo-vendor` subcommand in order to vendor
dependencies. Additionally it'll always support the latest feature set
of Cargo as it'll be built into Cargo!

All tests were imported as part of this commit, but not all features
were imported. Some flags have been left out that were added later in
the lifetime of `cargo vendor` which seem like they're more questionable
to stabilize. I'm hoping that they can have separate PRs adding their
implementation here, and we can make a decision of their stabilization
at a later date.

The current man page for `cargo vendor -h` will look like:

    cargo-vendor
    Vendor all dependencies for a project locally

    USAGE:
	cargo vendor [OPTIONS] [--] [path]

    OPTIONS:
	-q, --quiet                    No output printed to stdout
	    --manifest-path <PATH>     Path to Cargo.toml
	    --no-delete                Don't delete older crates in the vendor directory
	-s, --sync <TOML>...           Additional `Cargo.toml` to sync and vendor
	    --respect-source-config    Respect `[source]` config in `.cargo/config`
	-v, --verbose                  Use verbose output (-vv very verbose/build.rs output)
	    --color <WHEN>             Coloring: auto, always, never
	    --frozen                   Require Cargo.lock and cache are up to date
	    --locked                   Require Cargo.lock is up to date
	-Z <FLAG>...                   Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details
	-h, --help                     Prints help information

    ARGS:
	<path>    Where to vendor crates (`vendor` by default)

    This cargo subcommand will vendor all crates.io and git dependencies for a
    project into the specified directory at `<path>`. After this command completes
    the vendor directory specified by `<path>` will contain all remote sources from
    dependencies specified. Additionally manifest beyond the default one can be
    specified with the `-s` option.

    The `cargo vendor` command will also print out the configuration necessary
    to use the vendored sources, which when needed is then encoded into
    `.cargo/config`.

Since this change is not importing 100% of the functionality of the
existing `cargo vendor` this change does run a risk of being a breaking
change for any folks using such functionality. Executing `cargo vendor`
will favor the built-in command rather than an external subcommand,
causing unimplemented features to become errors about flag usage.

[repo]: https://github.com/alexcrichton/cargo-vendor
2019-05-21 07:02:17 -07:00
Eric Huss
dcd4999d42 Add message caching. 2019-05-20 15:22:32 -07:00
Eric Huss
80b9d329ba Move offline tests to a dedicated file. 2019-04-28 19:45:01 -07:00
Aaron Hill
87f1a4b217
Implement the 'frontend' of public-private dependencies
This is part of https://github.com/rust-lang/rust/issues/44663

This implements the 'frontend' portion of RFC 1977. Once PRs
https://github.com/rust-lang/rust/pull/59335 and
https://github.com/rust-lang/crates.io/pull/1685 are merged,
it will be possible to test the full public-private dependency feature:
marking a dependency a public, seeing exported_private_dependencies
warnings from rustc, and seeing pub-dep-reachability errors from Cargo.

Everything in this commit should be fully backwards-compatible - users
who don't enable the 'public-dependency' cargo feature won't notice any
changes.

Note that this commit does *not* implement the remaining two features of
the RFC:

* Choosing smallest versions when 'cargo publish' is run
* Turning exported_private_dependencies warnings into hard errors when
'cargo publish' is run

The former is a major change to Cargo's behavior, and should be done
in a separate PR with some kind of rollout plan.

The latter is described by the RFC as being enabled at 'some point in
the future'. This can be done via a follow-up PR.
2019-04-25 22:42:18 -04:00
Eric Huss
ebb5764ad8 Move publish-lockfile tests to a dedicated file. 2019-04-16 08:54:24 -07:00
Eric Huss
f818762b66 Ignore Clippy redundant_closure 2019-04-15 13:49:04 -07:00
Eric Huss
e023a6672b Add install-upgrade. 2019-04-02 08:40:34 -07:00
Eric Huss
a91a12b4af Cleanup: Remove redundant clones. 2019-03-26 18:51:13 -07:00
Eric Huss
ef0b47769b Cleanup: Remove unnecessary borrows. 2019-03-26 18:09:56 -07:00
Damian
56b6a80f57 --example with no argument now lists all available examples 2019-01-01 11:03:55 +01:00
Eric Huss
70f84bf3b0 Rewrite login and registry cleanups. 2018-12-20 04:34:35 -08:00
Dale Wijnand
ec197891e8
Remove trailing cfg_attr feature = "cargo-clippy" usage 2018-12-13 15:21:31 +00:00
Dale Wijnand
0e031b5a96
Allow testsuite warnings in dev
This makes the deny(warnings) in the testsuite conditional on a new
"deny-warnings" feature, that is then enabled in CI.

Ideally I could use the (reasonably well established) CI env var (like
we do for proptests), but I don't know how to get the attribute to be
defined in terms of an env var.
2018-12-13 01:03:08 +00:00