Commit graph

315 commits

Author SHA1 Message Date
bors 5847787fef Auto merge of #8274 - Eh2406:8249-repro, r=alexcrichton
reset lockfile information between resolutions

#8249 pointed out that some kind of lockfile data was leaking between calls to the resolver. @ehuss made a reproducing test case. This PR resets the `LockedMap` data structure when calling `register_previous_locks`.

lets see if CI likes it.
fix #8249
2020-06-01 16:01:10 +00:00
Eric Huss e2d1d2456c Fix several issues with close_output test. 2020-05-26 11:35:48 -07:00
Daniel Wagner-Hall 556c236f9a Bump to semver 0.10 for VersionReq::is_exact
This stops using `to_string` as a proxy for this now-provided precise API.

This reverts commit b71927224f and bupms the
dependency version in Cargo.toml.
2020-05-25 11:11:45 +01:00
Eh2406 61e592788c remove all residual state from previous lock files 2020-05-24 17:31:31 -04:00
Eh2406 46b50bbb67 minimize test 2020-05-24 17:31:30 -04:00
Eric Huss 771b2bca76 Repro 2020-05-24 17:31:30 -04:00
ReggaeMuffin 50a537bf93
Add CARGO_BIN_NAME and CARGO_CRATE_NAME to rustc/rustdoc env
CARGO_BIN_NAME is added for binary compilation units, CARGO_CRATE_NAME is added for binary and library units. 

The `crate_env_vars` test was updated to test for this. The test is currently only checking behavior for the binary compile unit.
2020-05-23 16:23:49 +01:00
Eric Huss 0a5960bcfb Gracefully handle errors during a build. 2020-05-16 09:43:03 -07:00
Eric Huss b19d6ac2a7 Update tests and comments for testing windows-gnu. 2020-04-21 11:00:37 -07:00
Mateusz Mikuła 9f742466f1 Update tests for windows-gnu 2020-04-21 17:25:25 +02:00
bors 1638705700 Auto merge of #8123 - ehuss:fix-windows-pdb-dash, r=alexcrichton
Fix pdb uplift when executable has dashes.

Windows `.pdb` files were not being uplifted for executables with dashes in their name. `rustc` calls the linker with the crate name (with underscores), which creates a pdb with underscores. Cargo renames the executable (`foo_bar.exe` to `foo-bar.exe`), and it was expecting the pdb to have the same form, but it doesn't.

Note: There shouldn't be any effect for using a debugger. Because the pdb path is embedded in the executable, the debugger was already looking in the `deps/` folder.  Uplifting is only useful if you want to copy the exe/pdb pair to some other machine.  In that case, it looks in the same directory as the `exe` for the pdb file.

Fixes #8117
2020-04-17 15:39:25 +00:00
Eric Huss 4ae79d2ffd Use fs helpers instead of File functions. 2020-04-17 07:56:16 -07:00
Eric Huss 3acd15eb47 Fix pdb uplift when executable has dashes. 2020-04-16 18:02:47 -07:00
bors 239f2bfd0c Auto merge of #8069 - ehuss:build-finished, r=alexcrichton
Add "build-finished" JSON message.

This adds a JSON message when a build is finished.  This is useful for tools to know when to stop parsing JSON, which is particularly useful for commands like `cargo test` or `cargo run` where additional output may follow.

Closes #7978
2020-04-09 19:34:39 +00:00
Matt Stavola fcff51b3e0
Add test for bad renaming 2020-04-08 23:46:30 -07:00
Rocco 79c8ae8299
Compatibility for rust-lang/rust#69926 2020-04-07 15:23:43 +02:00
Eric Huss c889bbfba8 Add "build-finished" JSON message. 2020-04-04 18:56:50 -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
Jane Lusby b0351e4d87 Close the front door for clippy but open the back 2020-03-12 19:27:48 -07:00
Eric Huss 95008f91e5 Try to better handle restricted crate names. 2020-03-02 16:04:24 -08:00
Alex Tokarev a6239da8b2 Filter out cfgs which should not be used during build
Fixes #7933: Filter invalid CARGO_CFG_ in build scripts
2020-02-27 11:53:53 +03:00
Matthias Krüger a6a395c690 fix some clippy warnings 2020-01-17 12:20:11 +01:00
Takayuki Nakata 4b70f14903 Load credentials only when needed
Credentials are always loaded, even if these are not used. If
access to confidential files such as credentials is not given,
`cargo build` fails despite not using credentials.

Fixes #7624.
2020-01-07 23:40:58 +09:00
Eric Huss 829ddf0dc8 Fix config env vars that are prefix of another with underscore. 2019-12-23 18:13:50 -08:00
Takayuki Nakata 4956d3e778 Add and move tests for jobs of cargo build
A test when argument is negative is added. In addition,
`default_cargo_config_jobs` and `good_cargo_config_jobs` is moved from
`testsuite/bad_config.rs` to `testsuite/build.rs` because these tests
are not for `bad config`.
2019-12-11 18:01:01 +09:00
Eric Huss 83571aee56 Minor testsuite organization. 2019-11-24 18:42:45 -08:00
Aleksey Kladov f0f73f04d1 Add value OUT_DIR to build-script-executed JSON message
The target audience here is IDE authors, who can use this feature to
better support crates which generate code to OUT_DIR
2019-11-22 21:48:04 +03:00
bors b03182a8ff Auto merge of #7450 - ehuss:stabilize-cache-messages, r=alexcrichton
Stabilize cache-messages

This stabilizes the -Zcache-messages feature, making it always enabled.

## What is stabilized?

This feature is intended to redisplay previous warnings on a "fresh" build instead of displaying no output.

Users have occasionally indicated frustration when they know there are warnings, but no output is displayed when the build is fresh. This also improves the interaction between `cargo check` and `cargo clippy-preview`. This also simplifies the code, and opens more possibilities for `rustc` to send side-channel messages to Cargo.

Cargo will now use JSON output from `rustc` and `rustdoc` 100% of the time (`rustdoc --test` does not use JSON). Previously Cargo would only use JSON for pipelined crates.

Cargo will save the JSON output into a file named `output` in the `.fingerprint` directory. This file is only created when the compiler outputs a diagnostic message.

If a crate is being recompiled, and Cargo considers it to be "fresh", it will replay the output file to the console.

## Notable changes in this PR

- Fixed a bug where replays were erroneously including pipeline rmeta artifact json messages.
- clippy-preview is now included in the metadata hash, to force its artifacts to be separate from `cargo check`.
- clippy-preview is no longer force-enabled, under the assumption that caching and fingerprinting is accurate, and the cached messages will be replayed.
- clippy-preview's arguments are included in the fingerprint now that it is not force-enabled.
- Rustdoc colors and short messages were fixed when pipelining was stabilized, so updated tests.

Closes #6986
Closes #6848
Closes #6664
Closes #2458

## Concerns

The only notable issue with this is that switching between short and long human messages only replays the format from the first invocation.  That is, if you do `cargo build` and it generates warnings, then running again with `--message-format=short` will still show the full length human messages. I'm personally fine with that behavior, even though it is not ideal. I think this feature overall improves the situation (where before *no* output was displayed). Being able to re-render between short/long is a very difficult problem, and unlikely to be fixable in the foreseeable future.

There was some concern expressed about being able to disable this. I think that would only be necessary if a severe bug is discovered. I do not feel that this change is risky enough to warrant a configurable option. If it does cause a problem, it can be quickly reverted with a one-line change to set `OutputOptions::cache_cell` to `None`. Since pipelining has been using JSON output for a while now without complaints, I feel pretty confident in it.
2019-10-15 13:48:13 +00:00
Alex Crichton a92fd48fb4 Improve error message for cyclic dependencies
First reported in rust-lang/rust#65014 it looks like our error message
on cyclic dependencies may be confusing at times. It looks like this is
an issue because there are multiple paths through a graph for a
dependency, so using the generic `path_to_top` function isn't producing
the most useful path for this purpose.

We're already walking the graph though, so this commit adds an extra
parameter which collects the list of packages we've visited so far to
produce a hopefully always-accurate error message showing the chain of
dependencies end-to-end for what depends on what.
2019-10-07 16:50:42 -07:00
snf e7c5579d3e removing hash from output files when using MSVC 2019-10-02 02:07:09 -03:00
Eric Huss bd73e8dab5 Stabilize cache-messages 2019-09-30 14:04:10 -07:00
Alex Crichton 61fb34b0c0 Allow a number of tests to run on stable
These tests all relied on support which has now ridden to stable at this
point, so let's let them run on stable!
2019-09-26 11:31:57 -07:00
Jonas Schievink 26229cd8ad Uncapitalize "Could not compile" error message
"could not compile ..." matches other Cargo and rustc errors and
warnings better.
2019-09-17 00:50:49 +02:00
Alex Crichton ebd10526f3 Run rustfmt 2019-09-16 12:00:12 -07: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
k-nasa 7176df01d6 Change --all to --workspace 2019-09-03 17:14:34 -07:00
Nikhil Benesch b03eeda998
Fix dSYM uplifting when symlink is broken
We were sporadically but persistently seeing errors like

    failed to link or copy `.../target/debugs/deps/bin-264030cd6c8a02be.dSYM` to `.../target/debug/bin.dSYM`

    Caused by:
      the source path is not an existing regular file

while running `cargo build`. Once the error occurs once, `cargo build`
will fail forever with the same error until `target/debug/bin.dSYM` is
manually unlinked.

After some investigation, I've determined that this situation arises
when the target of `bin.dSYM` goes missing. For example, if bin.dSYM is
pointing at `deps/bin-86908f0fa7f1440e.dSYM`, and
`deps/bin-86908f0fa7f1440e.dSYM` does not exist, then this error will
occur. I'm still not clear on why the underlying dSYM bundle
sporadically goes missing--perhaps it's the result of pressing Ctrl-C at
the wrong moment?--but Cargo should at least be able to handle this
situation better.

It turns out that Cargo was getting confused by the broken symlink. When
it goes to install the new `target/debug/bin.dSYM` link, it will remove
the existing `target/debug/bin.dSYM` file, if it exists. Unfortunately,
Cargo was checking whether the *target* of that symlink existed (e.g.,
`deps/bin-86908f0fa7f1440e.dSYM`, which in the buggy case would not
exist), rather than the symlink itself, deciding that there was no
existing symlink to remove, and crashing with EEXIST when trying to
install the new symlink.

This commit adjusts the existence check to evaluate whether the symlink
itself exists, rather than its target.

Note that while the symptoms are the same as #4671, the root cause is
unrelated.
2019-08-19 17:01:40 -04:00
Eric Huss b41c209af3 Bump toml 0.5.3 2019-08-13 14:56:22 -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
Thom Wiggers 55e5623368
Don't run symlink tests based on symlink_supported 2019-07-30 09:31:35 +02:00
Thom Wiggers 673bb69cf5
Ignore tests that need Administrator privileges on Windows.
This patch allows you to run them when wanted with ``--ignored`` on Windows.
2019-07-30 09:31:35 +02:00
Eric Huss a4e9611453 Fix some formatting for some strings. 2019-07-13 16:00:47 -07:00
Nicolas Mattia 8d1ef5a936 Fix misleading comment in testsuite 2019-07-03 16:11:23 +02:00
Geoffry Song 15e08029f1 Add a test for build pipelining with a complex build graph. 2019-06-24 14:29:01 -07:00
Eric Huss 7d7fe6797a Stabilize default-run 2019-06-21 11:36:53 -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
Eric Huss 6b07c8da63 cargo fmt 2019-05-20 12:40:20 -07:00
vlad20012 e1d433d30f Add doctest field into metadata
Some tools can support rust doctests (e.g. highlighting
or launching). So it should be possible to find out if
doctests are enabled for a target or not. This commit
adds `doctest` field to `cargo metadata` output.
2019-05-17 18:39:23 +03:00
bors 2e09266f66 Auto merge of #6883 - alexcrichton:pipelining-v2, r=ehuss
Implement the Cargo half of pipelined compilation (take 2)

This commit starts to lay the groundwork for #6660 where Cargo will
invoke rustc in a "pipelined" fashion. The goal here is to execute one
command to produce both an `*.rmeta` file as well as an `*.rlib` file
for candidate compilations. In that case if another rlib depends on that
compilation, then it can start as soon as the `*.rmeta` is ready and not
have to wait for the `*.rlib` compilation.

Initially attempted in #6864 with a pretty invasive refactoring this
iteration is much more lightweight and fits much more cleanly into
Cargo's backend. The approach taken here is to update the
`DependencyQueue` structure to carry a piece of data on each dependency
edge. This edge information represents the artifact that one node
requires from another, and then we a node has no outgoing edges it's
ready to build.

A dependency on a metadata file is modeled as just that, a dependency on
just the metadata and not the full build itself. Most of cargo's backend
doesn't really need to know about this edge information so it's
basically just calculated as we insert nodes into the `DependencyQueue`.
Once that's all in place it's just a few pieces here and there to
identify compilations that *can* be pipelined and then they're wired up
to depend on the rmeta file instead of the rlib file.

Closes #6660
2019-05-10 14:36:30 +00:00
Alex Crichton 6b28a0c050 Fix fingerprint handling in pipelining mode
This commit fixes an issue when pipelining mode is used in handling
recompilations. Previously a sequence of compilations could look like:

* Crate A starts to build
* Crate A produces metadata
* Crate B, which depends on A, starts
* Crate B finishes
* Crate A finishes

In this case the mtime for B is before that of A, which fooled Cargo
into thinking that B needed to be recompiled. In this case, however, B
doesn't actually need to be recompiled because it only depends on the
metadata of A, not the final artifacts.

This unfortunately resulted in some duplication in a few places, but not
really much moreso than already exists between fingerprinting and compilation.
2019-05-08 11:28:07 -07:00
Zach Lute 782266aaee Changed RUST_LOG usage to CARGO_LOG to avoid confusion. 2019-05-08 10:53:02 -07:00
Alex Crichton 8f032b3bd4 Handle "invalid JSON" from the compiler
Just opportunistically consider lines which start with `{` as valid
JSON, otherwise forward everything else to normal stdout/stderr.
2019-05-08 08:51:40 -07:00
Alex Crichton 95e240448d Switch to -Zemit-artifact-notifications
This is the renamed version of `-Zemit-directives`.
2019-05-08 08:43:09 -07:00
Alex Crichton 4617f78dbc Parse rmeta directives coming from rustc
This commit updates Cargo to process JSON directives emitted by rustc
when we're pipelining compilation. In this mode Cargo will attempt to
start subsequent compilations of crates as soon as possible, fully
completing the features of pipelined compilations in Cargo!
2019-05-08 08:10:26 -07:00
Alex Crichton 127fdfeb89 Implement the Cargo half of pipelined compilation
This commit starts to lay the groundwork for #6660 where Cargo will
invoke rustc in a "pipelined" fashion. The goal here is to execute one
command to produce both an `*.rmeta` file as well as an `*.rlib` file
for candidate compilations. In that case if another rlib depends on that
compilation, then it can start as soon as the `*.rmeta` is ready and not
have to wait for the `*.rlib` compilation.

Initially attempted in #6864 with a pretty invasive refactoring this
iteration is much more lightweight and fits much more cleanly into
Cargo's backend. The approach taken here is to update the
`DependencyQueue` structure to carry a piece of data on each dependency
edge. This edge information represents the artifact that one node
requires from another, and then we a node has no outgoing edges it's
ready to build.

A dependency on a metadata file is modeled as just that, a dependency on
just the metadata and not the full build itself. Most of cargo's backend
doesn't really need to know about this edge information so it's
basically just calculated as we insert nodes into the `DependencyQueue`.
Once that's all in place it's just a few pieces here and there to
identify compilations that *can* be pipelined and then they're wired up
to depend on the rmeta file instead of the rlib file.
2019-05-08 08:10:26 -07:00
Eric Huss f95f55af39 Symlink dSYM on macOS example binaries. 2019-04-29 14:17:28 -07:00
Eric Huss 80b9d329ba Move offline tests to a dedicated file. 2019-04-28 19:45:01 -07:00
Eric Huss 2378a9be3d Resolve: Be less strict while offline. 2019-04-02 13:27:42 -07:00
Eric Huss 50277e88fe Testsuite: remove some unnecessary is_nightly checks. 2019-03-26 13:56:14 -07:00
bors 131823ad4b Auto merge of #6614 - claudijd:https_all_the_things, r=ehuss
HTTPS all the things

Noticed that we still have a bunch of HTTP links, which could present mild MiTM risks that we can totally remove.

One short coming of this was:

cargo/src/etc/_cargo:13 "http://zsh.sourceforge.net/Doc/Release/Completion-System.html#Completion-Functions" of which does not have an HTTPS equivalent yet.
2019-02-27 22:21:16 +00:00
bors 4536bc9148 Auto merge of #6683 - dwijnand:cargo-test-quicker-by-not-building-untested-examples-when-filtered, r=ehuss
Cargo test quicker by not building untested examples when filtered

Alternative to #6677
Fixes #6675
r? @ehuss
2019-02-25 20:43:45 +00:00
Jonathan Claudius 46b2b78754
Merge branch 'master' into https_all_the_things 2019-02-22 14:21:53 -05:00
Eric Huss 2b6fd6f0ff Incremental profile cleanup. 2019-02-20 09:12:27 -08:00
Dale Wijnand 7d53e48592
Move build tests to build 2019-02-20 12:39:14 +00:00
Alexander Regueiro f7c91ba622
Various cosmetic improvements. 2019-02-20 10:58:27 +00:00
Dale Wijnand 8c268600d8
Test cases proving RUSTC_WRAPPER can be a relative path 2019-02-14 19:16:08 +00:00
Dale Wijnand 37df042ba8
Test cleanup: remove unnecessary with_status(0) 2019-02-04 18:52:33 +01:00
Jonathan Claudius 0c3851c017
HTTPS all the things 2019-01-30 15:34:37 -05:00
nasa db09895f3c $cargo fmt --all 2019-01-27 22:39:49 +09:00
Alik Aslanyan bfea4d57e6 Fix typo 2019-01-15 02:03:20 +04:00
bors 34320d212d Auto merge of #6492 - mikerite:print-env-vars-4, r=alexcrichton
Display environment variables for rustc commands

This picks up on the work done in PR #5683.

The extra output is only displayed with `-vv`.

The Windows output has the form `set FOO=foo && BAR=bar rustc ...` instead of
the form that suggested in #5683 to make escaping easier and since it's
simpler.
2019-01-03 19:12:38 +00:00
Eric Huss f58d107e7c testsuite: Require failing commands to check output. 2018-12-28 17:59:36 -08:00
Michael Wright e557f66024 Fix Windows rustc env var display
Remove the space at the end of the set commands.
2018-12-28 11:09:19 +02:00
Michael Wright 81390379df Display environment variables for rustc commands
This picks up on the work done in PR #5683.

The extra output is only displayed with `-vv`.

The Windows output has the form `set FOO=foo && BAR=bar rustc ...` instead of
the form that suggested in #5683 to make escaping easier and since it's
simpler.
2018-12-27 16:32:34 +02:00
Alex Crichton fecb724643 Format with cargo fmt 2018-12-08 03:19:47 -08:00
Dale Wijnand 04ddd4d0fc
Upgrade to Rust 2018 2018-12-06 20:18:35 +01:00
Dale Wijnand 282f238d93
Include executable in JSON output. 2018-11-30 22:12:30 +00:00
bors 51d541fced Auto merge of #6309 - ehuss:bench-build-profile, r=alexcrichton
Use "test" profile for `cargo build` benchmarks.

When using `cargo build` (without `--release`), build benchmarks using the "test" profile. This was causing some confusion where the benchmark is placed in the `target/debug` directory, and also causing some duplicates that may not be expected. It also makes it easier to debug benchmarks (previously you had to edit the `[profile.bench]` profile).

Closes #5575, closes #6301, closes #4240, closes #4929.
2018-11-14 15:06:17 +00:00
Eric Huss 739c272f05 Use "test" profile for cargo build benchmarks. 2018-11-12 13:10:54 -08:00
Eric Huss fa0787aaf7 Check for duplicate output filenames. 2018-11-12 12:07:22 -08:00
Eric Huss 3f0c788aed Show error on JSON parse error and nonzero exit. 2018-11-08 21:07:28 -08:00
Eric Huss b15dc1ac82 Don't treat rustc exit on signal as internal error.
If rustc exits with a signal, previously all you saw was:
```
   Compiling foo ...
error: Could not compile `foo`.

To learn more, run the command again with --verbose.
```

Now it shows the complete error by default:
```
   Compiling foo ...
error: Could not compile `foo`.

Caused by:
  process didn't exit successfully: `rustc ...` (signal: 6, SIGABRT: process abort signal)
```
2018-11-06 11:13:04 -08:00
bors 5fc8ac71e8 Auto merge of #6096 - mathstuf:export-repository-info, r=alexcrichton
build: export repository information

The repository string is made available via the `CARGO_PKG_REPOSITORY`
environment variable similar to other metadata.
2018-10-12 17:32:25 +00:00
Dale Wijnand 8735e8b57d
Detail dep name in invalid version error 2018-10-06 11:15:41 +01:00
Ben Boeckel 07f872a640 build: export repository information
The repository string is made available via the `CARGO_PKG_REPOSITORY`
environment variable similar to other metadata.
2018-09-25 16:33:32 -04:00
Alex Crichton e2637b6599 Review comments! 2018-09-18 11:33:18 -07:00
Guillaume Gomez 2fc6b3e338 revert b1d6a7e changes 2018-09-14 23:19:00 +02:00
bors a5d8294948 Auto merge of #6021 - zachlute:validate-package-name, r=alexcrichton
Validate that the package name contains no invalid characters.

Fixes #2388.

Invalid characters are currently defined as alphanumeric, _, and -. This matches the rustc restrictions but is not as restrictive as `cargo new` or crates.io.

Mostly this is just so there will be better error messages in the case where characters in the package name aren't valid path characters.
2018-09-13 19:14:15 +00:00
Zach Lute dc2d0c0fb1 Validate that the package name contains no invalid characters.
Invalid characters are currently defined as alphanumeric, _, and -. This matches the rustc restrictions but is not as restrictive as `cargo new` or crates.io.

Mostly this is just so there will be better error messages in the case where characters in the package name aren't valid path characters.
2018-09-12 19:39:16 -07:00
kennytm 4779dbfe85
Update the testsuite to include the explicit '--color' flags. 2018-09-12 11:59:08 +08:00
Zach Lute b020d3789a Resolve merge conflicts with test string changes. 2018-09-09 16:48:57 -07:00
bors 5984312202 Auto merge of #5990 - dwijnand:no-crates.io-index-url, r=alexcrichton
Don't print crates.io-index URL when Updating

Following the lead from PackageId's Display, only display the registry's
URL if it's not the default registry (aka crates.io).

Before:

    $ cargo install lazy_static
        Updating registry `https://github.com/rust-lang/crates.io-index`

After:

    $ dcargo install lazy_static
        Updating crates.io index

Fixes #4208
2018-09-09 21:06:13 +00:00
Dale Wijnand d0679c7f8e
Specify crates.io is the default registry & print index 2018-09-08 09:25:41 +01:00
Zach Lute 89f43938fe Print file paths instead of file:// URLs.
This change ensures cargo will output file paths in the expected format
(C:\foo\... on Windows, /foo/... elsewhere). Previously it would output
file:// URLs instead.

To support this change, additional changes were made to the test suite
string processing such that [ROOT] is now replaced with the appropriate
file path root for the platform.

The CWD template was also updated to use [CWD] like other replacement
templates and to do the replacement on the expected value rather than
the actual value to avoid replacing things we don't expect with CWD.
2018-09-07 19:42:59 -07:00
Alex Crichton 3d0290398a Stabilize edition key and add cargo new --edition
This commit stabilizes the `edition` key in `Cargo.toml`, both in the
`[package]` section and inside subtargets. Additionally the `cargo new` and
`cargo init` subcommands have been enhanced with a `--edition` flag to allow
explicitly specifying the edition to be generated.

This commit does not yet change the default edition that's generated.

Closes #5980
2018-09-06 11:28:10 -07:00
Matthias Krüger 2cd9cce6e3 clippy: resolve all warnings about useless format!() 2018-09-03 11:38:29 +02:00
Dale Wijnand d5fc8dc3a7
Introduce the CWD macro in test output asserting
Avoids dealing with things like CWD changing.
2018-08-30 11:05:29 +02:00
Dale Wijnand 570fe8927d
Remove hamcrest existing_file() 2018-08-29 10:26:12 +02:00
Dale Wijnand 6fd1b54c65
Remove hamcrest existing_dir() 2018-08-29 07:53:01 +02:00
Dale Wijnand 66262110a2
Replace .exec_with_output() usage with .run() 2018-08-29 00:45:18 +02:00
Dale Wijnand 21d9c4ae89
Replace some bare ProcessBuilder usage with Execs 2018-08-28 23:05:39 +02:00
Dale Wijnand 85984a8700
Migrate from tests fom assert_that/execs to .run() 2018-08-28 15:08:12 +02:00
Dale Wijnand b5ee3635ef
Wrap ProcessBuilder in Execs & make .cargo return that 2018-08-28 09:24:37 +01:00
Dale Wijnand 0152f26405
Move .env/.masquerade_as_nightly_cargo to collapse some more p.cargo calls 2018-08-18 21:34:09 +01:00
Dale Wijnand 511d4bc503
Collapse multiline ProcessBuilder::arg calls in tests
.. by calling this a bunch of times:

    fastmod --multiline '\.cargo\("([^"]+)"\).[ ]+\.arg\("([^"]+)"\)' '.cargo("${1} ${2}")' tests/testsuite/
2018-08-18 15:12:54 +01:00
Dale Wijnand af4f1392f7
Collapse ProcessBuilder::arg calls in tests
.. with mutliple calls of:

    fastmod --accept-all '\.cargo\("([^"]+)"\)\.arg\("([^"]+)"\)' '.cargo("${1} ${2}")' tests/testsuite/

until no changes are left.
2018-08-18 15:05:45 +01:00
bors ae97799980 Auto merge of #5876 - matthiaskrgr:clippy_2, r=alexcrichton
fix a bunch of clippy warnings

 (invocation: cargo clippy --all-targets --all-features -- --cap-lints warn )
2018-08-12 22:42:53 +00: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
Dale Wijnand 28a84e02e5
Add support for rustc's --error-format short
Running a local build of this branch on some broken code shows this kind of output:

    18:42:29 $ dcargo check --message-format=short --tests
        Checking bufstream v0.1.3
        Checking cargo v0.30.0 (file:///d/cargo)
    tests/testsuite/config.rs:298:9: error[E0308]: mismatched types
    tests/testsuite/config.rs:307:9: error[E0308]: mismatched types
    tests/testsuite/config.rs:363:9: error[E0308]: mismatched types
    tests/testsuite/config.rs:367:9: error[E0308]: mismatched types
    tests/testsuite/config.rs:371:9: error[E0308]: mismatched types
    tests/testsuite/config.rs:375:9: error[E0308]: mismatched types
    tests/testsuite/config.rs:382:9: error[E0308]: mismatched types
    tests/testsuite/config.rs:386:9: error[E0308]: mismatched types
    tests/testsuite/config.rs:400:9: error[E0308]: mismatched types
    tests/testsuite/config.rs:428:9: error[E0308]: mismatched types
    tests/testsuite/config.rs:479:9: error[E0308]: mismatched types
    tests/testsuite/config.rs:491:9: error[E0308]: mismatched types
    tests/testsuite/config.rs:496:9: error[E0308]: mismatched types
    tests/testsuite/config.rs:501:9: error[E0308]: mismatched types
    tests/testsuite/config.rs:506:9: error[E0308]: mismatched types
    tests/testsuite/config.rs:512:9: error[E0308]: mismatched types
    tests/testsuite/config.rs:582:9: error[E0308]: mismatched types
    tests/testsuite/config.rs:660:9: error[E0308]: mismatched types
    tests/testsuite/config.rs:666:9: error[E0308]: mismatched types
    tests/testsuite/config.rs:672:9: error[E0308]: mismatched types
    tests/testsuite/config.rs:678:9: error[E0308]: mismatched types
    error: aborting due to 21 previous errors
    error: Could not compile `cargo`.
    warning: build failed, waiting for other jobs to finish...
    error: build failed
2018-08-10 08:22:39 +01:00
Eric Huss 771fec3cff Change target filters in workspaces.
This changes it so that filters like `--bin`, `--test`, `--example`,
`--bench`, `--lib` will work in a workspace.  Today, these filters
require that they match *every* package in a workspace which makes
them not very useful.  This change makes it so that they only must
match at least one package.
2018-08-07 13:05:22 -07:00
Dale Wijnand b1d6a7e11d
Drop niche Execs::with_no_expected_status
.. by gating the nightly-only tests.
2018-08-03 07:54:07 +01:00
Dale Wijnand 60828dba83
Fix tests that have no stable expected exit code 2018-08-03 07:45:21 +01:00
Dale Wijnand 16aeb0cd4f
Default test support's Execs to exit code 0 2018-08-03 07:44:42 +01:00
Dale Wijnand 05400b8018
Drop the [/] test output macro 2018-08-02 10:18:48 +01:00
Arseniy Pendryak 5dcc4f1794 Add edition field into target object in metadata as well 2018-08-01 02:24:49 +03:00
Dale Wijnand 67c52ffe58
Add tests for per-target edition
Test:
* enabling edition feature & setting at target level (happy path)
* overriding the package-level edition with per-target edition
* feature gating of per-target edition
* per-target edition usage for rustdoc
2018-07-31 14:49:33 +01:00
Eh2406 7fc0dffed2 remove all of the (now) unnecessary temp file usage in tests 2018-07-26 15:10:48 -04:00
Dale Wijnand ca7d9ee292
Declare one-line files on one line, in test projects 2018-07-25 09:58:50 +01:00
Dale Wijnand ab19c48358
Dedup a bunch more manifest 2018-07-25 00:43:30 +01:00
Dale Wijnand 5659b78b76
Replace const BASIC_MANIFEST with basic_manifest("foo", "0.0.1") 2018-07-24 23:35:50 +01:00
Dale Wijnand 081e7930d2
Drop now unnecessary basic manifests 2018-07-24 16:33:55 +01:00
Dale Wijnand d2c815be22
Add an opt-out to the auto-generated Cargo.toml 2018-07-24 13:19:47 +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 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 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
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
Eric Huss ad3bab1fc4 Fix random errors in test compiler_json_error_format. 2018-06-23 15:51:22 -07:00
debris 66aa9bff66 extracted duplicated chunk of code into fn emit_build_output, removed redundant line from compiler_json_error_format test 2018-06-04 10:03:13 +02:00
debris f101d88ebd fixed #5602, expose cached build script output in json output 2018-06-03 17:09:44 +02:00
Eduard-Mihai Burtescu 62faec8511
Remove -Zno-trans test. 2018-05-15 10:14:03 +03: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
Simon Smith 0b530c3086 Add target directory parameter: address suggestions 2018-04-24 02:52:41 -04:00
Simon Smith dd0b7a2cda Add target directory parameter --target-dir 2018-04-23 18:23:48 -04:00
Aleksey Kladov 14067b952e Remove some is_nightly checks from tests 2018-04-22 18:08:31 +03: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
Eric Huss e7896a2f68 Fix with_*_does_not_contain to support [..] and macro matching. 2018-04-18 22:13:30 -07: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
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
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
Ximin Luo 0bc1155753 Split tests, apparently cargo clean does not work well on windows 2018-03-19 18:20:54 +01:00
Aleksey Kladov e5971b935c Slightly improve ergonomics of writing Cargo tests 2018-03-17 00:08:23 +03: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
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
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
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 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
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
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 31ea0d93f7 Fix some trivially fixable tests 2018-03-08 23:31:56 +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
Ximin Luo d46db71b3f Work around #5134 for now 2018-03-07 14:46:43 +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
Ximin Luo 9c5eecd419 Merge remote-tracking branch 'upstream/master' into pr4988 2018-03-03 12:56:08 +01:00
Timothy Bess 05b896ac90 Issue #5087
* targeted error message for virtual manifests
* assert correct error message
2018-02-28 16:43:08 -05:00
Timothy Bess 68a681ff03 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-02-27 21:37:40 -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
Renamed from tests/build.rs (Browse further)