Commit graph

145 commits

Author SHA1 Message Date
Eric Huss cee088b0db Check if rerun-if-changed points to a directory. 2020-12-12 14:14:54 -08:00
Alex Crichton 4761ada30f Fix the unit dependency graph with dev-dependency links
This commit fixes #8966 by updating the unit generation logic to avoid
generating an erroneous circular dependency between the execution of two
build scripts. This has been present for Cargo in a long time since #5651
(an accidental regression), but the situation appears rare enough that
we didn't get to it until now!

Closes #8966
2020-12-11 09:59:33 -08:00
Arpad Borsos 2cc2ae8c96 Run rustdoc doctests relative to the workspace
By doing so, rustdoc will also emit workspace-relative filenames for
the doctests.

fixes #8097
2020-12-06 23:21:06 +01:00
Eric Huss 6f8c7d5a87 Normalize raw string indentation. 2020-09-26 17:59:58 -07:00
Camelid 82c834cec2 Update tests 2020-09-07 10:57:00 -07:00
Eric Huss 51e0c71c5f Allow package.exclude patterns to match directories. 2020-04-22 11:26:19 -07:00
Eric Huss 9ed56cad00 Add some more context to errors walking path sources. 2020-04-22 11:21:27 -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
Eric Huss 4ae79d2ffd Use fs helpers instead of File functions. 2020-04-17 07:56:16 -07:00
Eric Huss 4367ec4d11 Use Path methods instead of fs::metadata. 2020-04-16 22:00:22 -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
Alex Tokarev 590c803ff1 Print colored warnings when build script panics
Fixes #3672
2020-03-18 22:08:17 +03:00
Eric Huss 0a2f691381 Switch azure to macOS 10.15. 2020-02-19 16:46:29 -08:00
Eric Huss 83571aee56 Minor testsuite organization. 2019-11-24 18:42:45 -08:00
Eric Huss 4dbc63ef1e Update some tests that now support stable. 2019-11-07 11:16:18 -08:00
Eric Huss bd73e8dab5 Stabilize cache-messages 2019-09-30 14:04:10 -07:00
Dan Aloni 375a46f18b Merge remote-tracking branch 'origin/master' into custom-profile-pr-rfc 2019-09-18 08:56:13 +03: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
Aaron Hill 5bc05b40f0
Add tests 2019-09-12 13:38:10 -04:00
Dan Aloni f0896975be Merge remote-tracking branch 'origin/master' into custom-profile-pr-rfc 2019-09-08 21:43:41 +03:00
Eric Huss 1f14fa3172 Basic standard library support. 2019-09-03 13:53:59 -07:00
Robert Morrison 18c604f5bc
Added tests for #7217 2019-08-16 22:25:53 -04:00
Dan Aloni 23e613d552 Merge remote-tracking branch 'origin/master' into custom-profile-pr-rfc 2019-08-09 11:50:55 +03:00
Eric Huss 4a37adc104 Fix an old test. 2019-08-04 11:09:25 -07:00
Alex Crichton daa1bce283 Enable pipelined compilation by default
This commit enables pipelined compilation by default in Cargo now that
the requisite support has been stablized in rust-lang/rust#62766. This
involved minor updates in a number of locations here and there, but
nothing of meat has changed from the original implementation (just
tweaks to how rustc is called).
2019-07-31 14:56:24 -07:00
Dan Aloni 27da33c67d Merge remote-tracking branch 'origin/master' into custom-profile-pr-rfc 2019-07-28 09:24:31 +03:00
Eric Huss a4e9611453 Fix some formatting for some strings. 2019-07-13 16:00:47 -07:00
Dan Aloni 87183146d9 Merge remote-tracking branch 'origin/master' into custom-profile-pr-rfc 2019-06-20 16:18:42 +03: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
Dan Aloni e25f6a4255 tests: fix finished line for 'cargo test' 2019-06-07 21:47:45 +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
Zach Lute 782266aaee Changed RUST_LOG usage to CARGO_LOG to avoid confusion. 2019-05-08 10:53:02 -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 1a6e452407 Refactor routing output from rustc/rustdoc
This commit refactors slightly how we actually spawn rustc/rustdoc
processes and how their output is routed. Over time lots has changed
around this, but it turns out that we unconditionally capture all output
from the compiler/rustdoc today, no exceptions. As a result simplify the
various execution functions in the `Executor` trait as well as branches
for emitting json messages. Instead throw everything in the same bucket
and just always look for lines that start with `{` which indicate a
JSON message.

This also fixes a few issues where output printed in each thread is now
routed through the main coordinator thread to handle updating the
progress bar if necessary.
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 dcad83d583 Better error if PathSource::walk can't access something. 2019-04-11 18:28:45 -07:00
Alex Crichton 8df842f594 Purge mtime information from Fingerprint
This has proven to be a very unreliable piece of information to hash, so
let's not! Instead we track what files are supposed to be relative to,
and we check both mtimes when necessary.
2019-04-10 10:42:08 -07:00
Alex Crichton e9428cbadd Remove Freshness from DependencyQueue
Ever since the inception of Cargo and the advent of incremental
compilation at the crate level via Cargo, Cargo has tracked whether it
needs to recompile something at a unit level in its "dependency queue"
which manages when items are ready for execution. Over time we've fixed
lots and lots of bugs related to incremental compilation, and perhaps
one of the most impactful realizations was that the model Cargo started
with fundamentally doesn't handle interrupting Cargo halfway through and
resuming the build later.

The previous model relied upon implicitly propagating "dirtiness" based
on whether the one of the dependencies of a build was rebuilt or not.
This information is not available, however, if Cargo is interrupted and
resumed (or performs a subset of steps and then later performs more).
We've fixed this in a number of places historically but the purpose of
this commit is to put a nail in this coffin once and for all.

Implicit propagation of whether a unit is fresh or dirty is no longer
present at all. Instead Cargo should always know, irrespective of it's
in-memory state, whether a unit needs to be recompiled or not. This
commit actually turns up a few bugs in the test suite, so later commits
will be targeted at fixing this.

Note that this required a good deal of work on the `fingerprint` module
to fix some longstanding bugs (like #6780) and some serious hoops had to
be jumped through for others (like #6779). While these were fallout from
this change they weren't necessarily the primary motivation, but rather
to help make `fingerprints` a bit more straightforward in what's an
already confusing system!

Closes #6780
2019-04-10 10:42:08 -07:00
Alexander Regueiro f7c91ba622
Various cosmetic improvements. 2019-02-20 10:58:27 +00:00
Eh2406 4be99b2e8d Some CI setups are much slower then the equipment used by Cargo itself 2019-01-24 12:28:21 -05:00
Eric Huss 2a1adb3d6c Rename method. 2019-01-18 08:39:25 -08:00
Eric Huss 394ec96f79 Fix spurious Windows errors with switch_features_rerun. 2019-01-17 16:39:04 -08: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
bors 53e436d665 Auto merge of #6328 - ehuss:rename-cross-build-output, r=alexcrichton
Fix renaming directory project using build scripts with cross-compiling.

The rename-protection introduced in #4818 checks for paths with a prefix of `/…/target/debug`, but this does not work for paths used during cross-compiling.

This change checks for paths with the full `OUT_DIR` prefix, and the `build/PKG/root-output` file now includes that full `OUT_DIR` instead of `/…/target/debug`.

This also includes a few other changes:
- Support fixing KIND=PATH style paths.
- Support fixing paths in metadata (like `cargo:root=…` or `cargo:include=…` which are common).
- Adds a "version" value to the metadata hash to ensure that cargo doesn't get confused with the new `root-output` file format.

Fixes #6177
2018-11-18 08:12:27 +00:00
Eric Huss d1045c9cc2 Fix renaming directory project using build scripts with cross-compiling. 2018-11-17 19:10:29 -08:00
Eric Huss 83ff57a4ad Fix add_plugin_deps-related tests. 2018-11-17 16:33:24 -08:00
Ted Mielczarek 20920c0131 Prefix build script output with crate name when running in extra verbose mode. Fixes #6158.
cargo's extra verbose mode is useful for getting detailed information out of
builds in CI where it can be difficult to examine the build environment
after-the-fact. However, when multiple build scripts are running as part of a
build it's not always clear what output is from which build script. This patch
makes cargo prefix each line of build script output with the crate name and
version this case.
2018-10-18 09:45:22 -04:00
Alex Crichton e2637b6599 Review comments! 2018-09-18 11:33:18 -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
Dale Wijnand 41aa6fbab4
Update tests to new Updating msg format 2018-09-08 10:23:57 +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
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 85984a8700
Migrate from tests fom assert_that/execs to .run() 2018-08-28 15:08:12 +02:00
Ralf Jung 08843a0457 attempt to fix test suite race on mac 2018-08-21 18:14:45 +02: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
Dale Wijnand e0b9e43771
Collapse let bindings 2018-08-13 12:00:01 +01:00
Dale Wijnand 11922d099b
Resolve a identity_conversion lint warning 2018-08-13 11:11:50 +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
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 081e7930d2
Drop now unnecessary basic manifests 2018-07-24 16:33:55 +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 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
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
Eric Huss 00d325db0f 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-06-25 18:00:04 -07:00
Alex Crichton 1759b30cf7 Cop out on fixing a spurious test failure
This commit cops out trying to fix `rename_with_link_search_path` by simply
adding a loop on Windows to retry the operation that looks to need retrying.
2018-05-05 11:47:41 -07:00
Aleksey Kladov 739cc2078d FIx false positive warning
We warn if a feature was specified corresponding to a dependency which
is not optional. However, a dependency can be both optional and
required, and we shouldn't warn in that case.
2018-05-05 20:18:37 +03:00
bors 5986492773 Auto merge of #5480 - alexcrichton:fix-regr, r=matklad
Fix optional deps in multiple sections

This commit fixes an issue where an optional dependency was listed multiple
times in a manifest (multiple sections). This regression was introduced by #5415
and happened because in the resolver we didn't record a `Dependency` as it was
accidentally deduplicated too soon.

The fix here was to ensure that all `Dependency` annotations make their way into
`Resolve` now that we rely on the listed `Dependency` values for correctness.

Closes #5475
2018-05-04 21:07:15 +00:00
Alex Crichton 2f88a70407 Fix optional deps in multiple sections
This commit fixes an issue where an optional dependency was listed multiple
times in a manifest (multiple sections). This regression was introduced by #5415
and happened because in the resolver we didn't record a `Dependency` as it was
accidentally deduplicated too soon.

The fix here was to ensure that all `Dependency` annotations make their way into
`Resolve` now that we rely on the listed `Dependency` values for correctness.

Closes #5475
2018-05-04 14:06:59 -07:00
Aleksey Kladov 25cab498a5 Try to diagnose/fix spurious windows error with better rm -r 2018-05-04 18:02:57 +03:00
Aleksey Kladov d57f6b0563 Revert "Attmept to fix a spurious failure on AppVeyor"
This reverts commit db3328f8f7.

We get spurious errors for thouse tests even with debug info disabled,
so let's reenable it back.
2018-05-04 17:53:10 +03:00
Alex Crichton db3328f8f7 Attmept to fix a spurious failure on AppVeyor
I *think* the issue is that `link.exe` is generating debuginfo in the background
which keeps the file open and prevents us from deleting it, but hopefully by
disabling debug information we'll either be able to confirm or deny this
hypothesis.
2018-05-03 08:57:36 -07:00
Eric Huss 83b8c234a1 Fix "DEBUG" env var in build.rs for debug=0.
Fixes #5370
2018-04-30 10:17:43 -07:00
Henrik Laxhuber 3ebdc722c6
Moved RUSTC_LINKER test into its own fn 2018-04-24 08:18:33 +02:00
Henrik Laxhuber 4628011e79
Fixed RUSTC_LINKER test for Windows hosts 2018-04-23 18:28:38 +02:00
Henrik Laxhuber 1469523348
Fixed build script env var test 2018-04-23 17:45:17 +02:00
Henrik Laxhuber 1d36411cc4
Added tests for RUSTC_LINKER buils script env var
Added tests for the environment variable RUSTC_LINKER that is
passed to the build script.
Also slightly improved readability of the code responsible for
passing the env var.
2018-04-23 17:11:10 +02:00
memoryleak47 57a7e12679 fixed a few typos 2018-04-05 03:45:15 +02: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
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-script.rs (Browse further)