Commit Graph

130 Commits

Author SHA1 Message Date
Eric Huss 888100352a Move ProcessBuilder to cargo-util. 2021-03-20 15:19:03 -07:00
Eric Huss e58c544f37 Some minor code cleanup. 2021-02-28 19:03:06 -08:00
bors 9a7fe2c23b Auto merge of #9195 - guswynn:test_name, r=ehuss
Make it more clear which module is being tested when running cargo test

I recently asked in zulip if this is a good idea, as I find it hard to find the module thats being tested from the complex path with the hash.

Output of `cargo test`:
```
2021-02-21 13:29:33 I > ~/repos/cargo/target/debug/cargo test
    Finished test [unoptimized + debuginfo] target(s) in 0.42s
     Running unittests (target/debug/deps/test_tests-759130ea61f71571)

running 1 test
test tests::unit_test ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in
0.00s

     Running tests2/lib.rs (target/debug/deps/integration_tests-6b7f9fcd1721f083)

running 2 tests
test tests2_lib ... ok
test second_test::tests2_second ... ok

test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in
0.00s

     Running tests/lib.rs (target/debug/deps/lib-d2be6d29597c2790)

running 2 tests
test second_test::tests_i_am_run_twice ... ok
test tests_lib ... ok

test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in
0.00s
...
```
2021-02-24 03:59:28 +00:00
Arpad Borsos b4c4028f76
Run rustdoc doctests relative to the workspace
By doing so, rustdoc will also emit workspace-relative filenames for the doctests.

This was first landed in #8954 but later backed out in #8996 because it changed the CWD of rustdoc test invocations.

The second try relies on the new `--test-run-directory` rustdoc option which was added in https://github.com/rust-lang/rust/pull/81264 to explicitly control the rustdoc test cwd.

fixes #8993
2021-02-22 20:33:31 +01:00
Gus Wynn 70d54bedcd Make it more clear which module is being tested when running cargo test 2021-02-21 13:35:25 -08:00
Eric Huss d8673d93d2 Fix env/cfg set for `cargo test` and `cargo run`. 2021-02-01 19:20:54 -08:00
Alex Crichton 6f49ce636f Revert "Run rustdoc doctests relative to the workspace"
This reverts commit 2cc2ae8c96.
2020-12-18 08:06:43 -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
bors 089cbb80b7 Auto merge of #8359 - ehuss:doctest-xcompile-linker, r=alexcrichton
Support linker with -Zdoctest-xcompile.

This adds support for `-Clinker` with `-Zdoctest-xcompile`.

I'm not entirely sure how `-Zdoctest-xcompile` was supposed to work without setting the linker. I tested this with std on arm-unknown-linux-gnueabihf with qemu. It seems to work (although it was quite slow).

Closes #7529.
2020-06-15 14:38:34 +00:00
Eric Huss b4476d74f3 Support linker with -Zdoctest-xcompile. 2020-06-13 21:19:22 -07:00
Eric Huss 1bf67a0402 Fix doctests not running with --target=HOST. 2020-06-13 20:56:29 -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
Tom Dohrmann ecffdcc2b0 add clarifying comment 2020-04-16 11:35:38 +02:00
Tom Dohrmann 86d857ec58 Revert "remove host & target attributes"
This reverts commit 5a051ebe08.
2020-04-15 12:51:37 +02:00
Tom Dohrmann b365b0fa06 Revert "fix running doctest for host target"
This reverts commit 060c5e13e1.
2020-04-15 12:51:22 +02:00
Tom Dohrmann 060c5e13e1 fix running doctest for host target 2020-04-14 16:41:18 +02:00
Tom Dohrmann 5a051ebe08 remove host & target attributes 2020-04-12 17:49:05 +02:00
Tom Dohrmann f9f62ff2b9 fix target 2020-04-11 11:33:58 +02:00
Eric Huss e4918c45ba Remove Config from CompileOptions. 2020-03-19 15:34:12 -07:00
Eric Huss 1c779ac5d4 Switch build-std to use --extern 2019-12-12 08:18:15 -08:00
Eric Huss fba07ba1fc Some minor clippy fixes. 2019-10-04 14:21:28 -07:00
Dario Gonzalez a2209fc590 added tests 2019-09-18 11:57:46 -07:00
Dario Gonzalez a5235b7bba moved cross-compiling doctests behind the doctest-xcompile feature flag 2019-09-18 11:44:01 -07:00
Dario Gonzalez 8c93de6a82 Added ability to crosscompile doctests 2019-09-18 11:43:24 -07:00
Eric Huss 1f14fa3172 Basic standard library support. 2019-09-03 13:53:59 -07:00
Alex Crichton f16efff150 Run `cargo fmt` 2019-04-10 10:42:07 -07:00
bors d74d879d63 Auto merge of #6358 - collin5:b4325, r=ehuss
Add --quiet option for `cargo test`

Fixes #4325
2019-03-11 17:00:13 +00:00
Collins Abitekaniza 805acffed9 forward --quiet flag only if harness=true 2019-03-11 03:01:56 +03:00
Dale Wijnand e0e6222910
Make cargo_test require only str slices for args 2019-03-02 11:09:05 +00:00
Alexander Regueiro f7c91ba622
Various cosmetic improvements. 2019-02-20 10:58:27 +00:00
Dale Wijnand 092c88c4a9
Replace util::without_prefix with Path::strip_prefix 2019-02-03 14:31:19 +01:00
Eric Huss 9a7fadf6bd Fix metabuild compile errors with --message-format=json.
If an error occurs while compiling a metabuild target with
`--message-format=json`, it would panic because it was unable to serialize
`Target`. This change makes it so that it places a fake "metabuild.rs" string in
the `src_path` in this situation.

I'm very unhappy with this solution, but I'm unable to think of something
better. Changing `src_path` to an `Option` (or something) would break existing
tools. I tried implementing something that resets the `src_path` to the correct
path in the target dir after the workspace is configured, but it felt very
brittle – you have to fix up after all dependencies are downloaded, and there's
not a good way to ensure that happens correctly.

This adds a `with_json_contains_unordered` to help with tests.
2018-12-17 19:55:16 -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
Dale Wijnand 04ddd4d0fc
Upgrade to Rust 2018 2018-12-06 20:18:35 +01:00
Eh2406 dae87a2624 PackageId is copy, clippy thinks we dont need &PackageId or PackageId.clone() 2018-11-27 17:43:23 -05:00
Zach Lute 3492a3905c Replace 'project' with 'package' in many strings and comments. 2018-09-20 23:47:09 -07:00
Eric Huss 3a1cad6f28 --all-targets fixes
- Fix: `cargo test --all-targets` was running lib tests three times.
- `--all-targets` help strings were wrong or misleading.
- Minor cleanup to add `Proposal` type to maybe make the code more readable.
2018-09-16 20:33:05 -07:00
Eric Huss ecc87b1795 New metabuild strategy using custom src_path enum.
- Use new enum `TargertSourcePath` for Target::src_path to make it explicit that metabuild has a special path.
- `cargo metadata` now skips the metabuild Target.
- JSON artifacts include the true path to the metabuild source file. This may not be the best solution, but it's unclear what it should be, and I would prefer to avoid breaking the output. Alternatively it could just not emit anything? I'm not completely familiar with the use case of these artifact messages.
- Place the file in `target/.metabuild/metabuild-pkgname-HASH.rs` instead of in the debug/release directory.  Its contents do not depend on the profile.
- Fix bug in write_if_changed.
- More tests.
2018-08-23 23:01:30 -07:00
Dale Wijnand d4ee795357
Wire target edition to rustc/rustdoc 2018-07-27 15:51:55 +01:00
Wim Looman a432619806 Apply dependency renamings when running rustdoc
Fixes #5792
2018-07-25 18:58:28 +02:00
Eric Huss 812fba62ff Doctest cleanup.
- Consolidate logic for determining doctest dependencies.
- Use a struct for the doctest info in `Compilation`.
2018-06-26 19:29:08 -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
Aleksey Kladov f5f23c2136 Associated Rustc with a build config
We want to create `rustc` only when we already have workspace, so that
we could use the `target` dir to store cached info about the compiler.
2018-04-14 11:49:13 +03:00
Dirkjan Ochtman a340ba0b33 Move compiler driver code from ops into core 2018-04-12 01:08:01 +02:00
Alex Crichton 1e6828485e cargo fmt 2018-03-14 17:48:23 -07:00
Eric Huss c61efd8c39 Fix test error hint in a workspace.
This adds "-p NAME" to the hint on how to re-run a test when it fails if it is
inside a workspace.

Fixes #5053
2018-02-25 16:51:48 -08:00
Zack M. Davis 16bb93688a clean up an unused pair of parentheses
While this might seem like too trivial of a stylistic nitpick to deserve
its own commit, this is needed to unblock rust-lang/rust#46980 (which makes
the unused-parens lint look at function arguments).
2018-01-06 09:58:05 -08:00
Alex Crichton 37cffbe0a3 Start migration to the `failure` crate
This commit is the initial steps to migrate Cargo's error handling from the
`error-chain` crate to the `failure` crate. This is intended to be a low-cost
(in terms of diff) transition where possible so it's note "purely idiomatic
`failure` crate" just yet.

The `error-chain` dependency is dropped in this commit and Cargo now canonically
uses the `Error` type from the `failure` crate. The main last remnant of
`error-chain` is a custom local extension trait to use `chain_err` instead of
`with_context`. I'll try to follow up with a commit that renames this later but
I wanted to make sure everything worked first! (and `chain_err` is used
practically everywhere).

Some minor tweaks happened in the tests as I touched up a few error messages
here and there but overall the UI of Cargo should be exactly the same before and
after this commit.
2017-12-18 17:48:36 -08:00
Anthony Ramine 0d4970b180 Pass RUSTDOCFLAGS to rustdoc spawned through cargo test (fixes #4738) 2017-12-01 16:21:52 +01:00
Lukas Lueg b8c8e307e6 Report hint if single failure with --no-fail-fast
If a single unit-test fails, report a rerun-hint for it,
even with --no-fail-fast.

Fixes reporting a doctest-hint if doctest succeeds while
unittest fail with --no-fail-fast.

Fixes #4534
2017-10-06 18:14:23 +02:00