Commit graph

110 commits

Author SHA1 Message Date
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
Alex Crichton 92bf2c3604 Turn on Rust 2018 idiom warnings unconditionally
It may take us awhile to get used to them, so let's see how this goes!
2018-12-11 05:45:46 -08:00
Alex Crichton b8b7faee50 Run cargo fix --edition-idioms and fixup output
This gets Cargo passing the `--edition-idioms` lints and more down the
road of the 2018 edition!
2018-12-11 05:45:46 -08:00
Alex Crichton 9ebf0657e4 Remove unused imports 2018-12-08 08:21:33 -08:00
Alex Crichton fecb724643 Format with cargo fmt 2018-12-08 03:19:47 -08:00
Dale Wijnand 6d1d3a6840
Fix 2018 edition idioms 2018-12-06 20:26:07 +01:00
Eric Huss fa0787aaf7 Check for duplicate output filenames. 2018-11-12 12:07:22 -08:00
Alex Butler 49ab03e3b0
Expose manifest error chain 2018-10-12 20:54:40 +01:00
Eh2406 40d9de46d6 Merge remote-tracking branch 'origin/master' into proptest 2018-09-19 22:04:11 -04:00
Dale Wijnand 1d2e0ea107
Run the cross-compile disable check ASAP 2018-09-16 10:09:45 +01:00
Eh2406 d6258e9eb3 Merge remote-tracking branch 'origin/master' into proptest
# Conflicts:
#	tests/testsuite/resolve.rs
2018-08-30 14:32:13 -04:00
Dale Wijnand 85984a8700
Migrate from tests fom assert_that/execs to .run() 2018-08-28 15:08:12 +02:00
Eric Huss 2be857af59 Metabuild (RFC 2196) 2018-08-23 13:31:50 -07:00
Eh2406 17618869e0 cache the example url to solve performance problem 2018-08-21 16:21:53 -04:00
Eh2406 56a222cd30 a start on using proptest to fuzz the resolver 2018-08-21 14:10:14 -04:00
Matthias Krüger 8798bf0d28 fix a bunch of clippy warnings (invocation: cargo clippy --all-targets --all-features -- --cap-lints warn )
Special thanks to dwijnand for helping me with this! :)
2018-08-12 10:00:12 +02:00
Alex Crichton 152eca58d8 Fix the edition build scripts are compiled with
Previously build scripts were accidentally and unconditionally compiled with the
2015 edition, but they should instead use the edition of the `[package]` itself.

Closes #5860
2018-08-04 08:44:16 -07:00
Eh2406 7fc0dffed2 remove all of the (now) unnecessary temp file usage in tests 2018-07-26 15:10:48 -04: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
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
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
Eric Huss 2f7b52259b Config Profiles (RFC 2282 Part 2)
Notes:
- `-Z config-profile` CLI option is required to use.
- Config values no longer reject mixed base types (integer, string, boolean) in order to support the mixed types in profiles.
2018-05-30 17:53:41 -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 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
Aleksey Kladov 6b1dc52b86 Speedup no-op builds by caching rustc invocations 2018-04-14 13:39:59 +03:00
Aleksey Kladov 5baac6b3b8 Implement --out-dir option 2018-04-03 15:52:21 +03: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
Aleksey Kladov 81713956f3 Deny warnings in tests 2018-03-16 12:32:31 +03: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 cbd14ee8f0 Use conventions to specify the integration tests 2018-03-14 14:55:19 +03:00
Renamed from tests/testsuite/lib.rs (Browse further)