195 Commits

Author SHA1 Message Date
Ed Page
19f1d1561c fix: Switch from --nocapture to --no-capture
`--no-capture` was added in 1.88, with `--nocapture` being
soft-deprecated.
2025-09-05 10:33:00 -05:00
Eric Huss
5c19611910 Update tests now that 1.88 is stable 2025-06-27 08:19:34 -07:00
Ross Sullivan
30b6707135
chore: Moved remaining cargo_exe logic to testsuite 2025-06-25 23:18:08 +09:00
Ross Sullivan
92d9a94d02
chore: Migrated testsuite to testsuite::prelude 2025-06-25 22:37:24 +09:00
Ross Sullivan
47312c446d
chore: Moved tools and some cross compiling logic into testsuite 2025-06-24 23:51:39 +09:00
Weihang Lo
8a388b0392
test(test): ensure panic=abort not added to default example inclusion
`cargo test` will implicitly build examples as examples binaries
(without --test) by default, when no target selection flags provided.
We don't have test exercising this, so add one.
2025-05-29 20:45:47 -04:00
Eric Huss
bead46769c Stabilize doctest-xcompile
This stabilizes the doctest-xcompile feature by unconditionally enabling
it.
2025-05-14 08:52:27 -07:00
Weihang Lo
ee85adae45
Update doctest xcompile flags (#15455)
This updates the flags used for doctest xcompile to match the upstream
changes in https://github.com/rust-lang/rust/pull/137096 which renamed
and stabilized the flags.

This cannot be merged until after nightly is published tonight.
2025-04-26 13:35:28 +00:00
Eric Huss
f10630f2bf Update doctest xcompile flags
This updates the flags used for doctest xcompile to match the upstream
changes in https://github.com/rust-lang/rust/pull/137096 which renamed
and stabilized the flags.
2025-04-26 06:07:27 -07:00
Ed Page
f616aaf21a fix(resolver): Make features singular; we only track one 2025-04-24 20:47:03 -05:00
Eric Huss
bbce504bf3
Revert "Temporarily ignore cargo_test_doctest_xcompile_ignores" 2025-03-27 18:28:09 -07:00
Chris Denton
d82b596962
Don't canonicalize in cargo_exe 2025-03-26 23:47:08 +00:00
Eric Huss
98a273f770 Temporarily ignore cargo_test_doctest_xcompile_ignores
This was broken due to a change in
https://github.com/rust-lang/rust/pull/138535. There is an approved PR
in https://github.com/rust-lang/rust/pull/138877 to fix it, but it may
take a day or two for it to make its way to nightly. This should be
reverted after it hits nightly.
2025-03-25 08:02:22 -07:00
Ed Page
fde91dde66 fix(compile): Remove trailing newlines on errors 2025-03-11 11:41:18 -05:00
Ed Page
c2764576ac fix(compile): Be consistent in not using period in error
Whether a period was used was dependent on whether a `help:` block is
present.
That shouldn't make a difference and the rustc dev guide says not to use
periods unless multiple sentences are used.
2025-03-11 11:41:08 -05:00
Weihang Lo
58cfd96b59
fix: reset $CARGO if the running program is real cargo[.exe] (#15208)
Overwrite `$CARGO` when the current exe is detected to be a cargo
binary.

From
https://github.com/rust-lang/cargo/issues/15099#issuecomment-2666737150:
> opt-in behavior (set by cargo-the-bin):
>
> 1. `from_current_exe` if its `cargo[EXE_SUFFIX]`
> 2. `from_argv` if its `cargo[EXE_SUFFIX]`
> 3. `from_env`
> 4. `from_current_exe`
> 5. `from_argv`

r? @epage
2025-02-28 15:04:52 +00:00
Yihai Lin
fa7712da82 feat: Make no target found hint more clear. 2025-02-28 10:03:59 +08:00
Samuel Moelius
44970a825d Fix #15099
Overwrite `$CARGO` when the current exe is detected to be a cargo
binary.

See: https://github.com/rust-lang/cargo/issues/15099#issuecomment-2666737150
2025-02-21 15:33:20 -05:00
Eric Huss
be6598b7f0 Fix race condition in panic_abort_tests 2025-02-10 13:15:15 -08:00
Weihang Lo
e79dae5bec
Revert "Conditionally mark the test cfg as a well known cfg (#15007)"
This reverts commit 26ce02737ae4b74a008355d302ef283375032cf6, reversing
changes made to 730d9977f1d0b6967f473d93f4034c6580d33a35.
2025-02-01 14:14:05 -05:00
Urgau
2593b86ee1 Conditionally mark the test cfg as a well known cfg 2025-01-09 19:08:27 +01:00
Ed Page
f80fc018a6 test: Ensure we don't rely on unit return values
This will allow changing `Execs::run` return type
2024-11-18 20:52:53 -06:00
Weihang Lo
7347918e38
test: redact host target when comparing CARGO_ENV path
This was found when updating git submodule in rust-lang/rust

```
---- test::cargo_test_env stdout ----
running `/Users/weihanglo/dev/rust/build/aarch64-apple-darwin/stage2-tools/aarch64-apple-darwin/release/cargo test --lib -- --nocapture`
thread 'test::cargo_test_env' panicked at tests/testsuite/test.rs:3904:10:

test failed running `/Users/weihanglo/dev/rust/build/aarch64-apple-darwin/stage2-tools/aarch64-apple-darwin/release/cargo test --lib -- --nocapture`
error: expected to find:
/Users/weihanglo/dev/rust/build/aarch64-apple-darwin/stage2-tools/aarch64-apple-darwin/release/cargo

did not find in output:
[COMPILING] foo v0.5.0 ([ROOT]/foo)
[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
[RUNNING] unittests src/lib.rs (target/debug/deps/foo-[HASH])
/Users/weihanglo/dev/rust/build/[HOST_TARGET]/stage2-tools/[HOST_TARGET]/release/cargo
```
2024-11-09 13:08:55 -05:00
Weihang Lo
c03c5807e8
test: fix replacing .exe only once
On non-Windows platform the redacted string became something like below,
which was valid but didn't make sense:

```
[EXE]/[EXE]U[EXE]s[EXE]e[EXE]r[EXE]s[EXE]/[EXE]w[EXE]h[EXE]l[EXE]o[EXE]/[EXE]d[EXE]e[EXE]v[EXE]/[EXE]r[EXE]u[EXE]s[EXE]t[EXE]/[EXE]b[EXE]u[EXE]i[EXE]l[EXE]d[EXE]/[EXE]a[EXE]a[EXE]r[EXE]c[EXE]h[EXE]6[EXE]4[EXE]-[EXE]a[EXE]p[EXE]p[EXE]l[EXE]e[EXE]-[EXE]d[EXE]a[EXE]r[EXE]w[EXE]i[EXE]n[EXE]/[EXE]s[EXE]t[EXE]a[EXE]g[EXE]e[EXE]2[EXE]-[EXE]t[EXE]o[EXE]o[EXE]l[EXE]s[EXE]/[EXE]a[EXE]a[EXE]r[EXE]c[EXE]h[EXE]6[EXE]4[EXE]-[EXE]a[EXE]p[EXE]p[EXE]l[EXE]e[EXE]-[EXE]d[EXE]a[EXE]r[EXE]w[EXE]i[EXE]n[EXE]/[EXE]r[EXE]e[EXE]l[EXE]e[EXE]a[EXE]s[EXE]e[EXE]/[EXE]c[EXE]a[EXE]r[EXE]g[EXE]o[EXE]
```

Here we simply remove the extension and append `[EXE]` at the end.
2024-11-09 12:05:03 -05:00
Ed Page
af3cfd5abe fix(test): Un-deprecate contains assertions 2024-11-07 15:55:35 -06:00
Ed Page
a03adcf6e2 fix(test): Make redactions consistent with snapbox
I'm unsure how we should be replacing these use cases, so I'm exploring
keeping them but making them use snapbox under the hood.
Part of the intent of snapbox is that it provides you the building
blocks to make what you need.
2024-11-06 20:03:53 -06:00
Weihang Lo
dfa8f26ddc
test(test): unnecessay env_remove("RUST_BACKTRACE")
This is done for all tests in f3c7525a61d61b347ed9e2e278dd84cc8c943531
2024-09-30 14:23:47 -04:00
Weihang Lo
e965b41fa0
test(test): relax compiler panic assertions 2024-09-30 14:23:47 -04:00
Weihang Lo
498ae399bf
test: relax panic output assertion
rust-lang/rust#122565 adds a new line to thread panic output.
To make the current test suites works on stable, beta, and nightly,
this relaxes the assertion around that by globbing everything.
2024-09-26 16:00:54 -04:00
Ed Page
a6cf1be655 test: Switch from allow to expect deprecated
This caught a couple of lingering items.
2024-09-23 20:44:06 -05:00
Ed Page
d2ec764995 fix(resolve): Dont show locking workspace members
This is for `cargo generate-lockfile` and when syncing the lockfile with
the manifest.
We still show it for `cargo update` because of `cargo update
--workspace`.

We hacked around this previously by filtering out the `num_pkgs==1` case
for single packages but this didn't help with workspaces.
2024-08-22 16:57:06 -05:00
Shashi Sugrim
465701526b Fix issue ' cargo t --doc does not respect --color when a compilation error occurs #14403 ' 2024-08-19 17:23:25 -04:00
Ed Page
96a5897e91 test: Migrate another 'test' json test
Rather than blocking on assert-rs/snapbox#351, we can get away with
`--no-run` for what this test is covering.
2024-07-24 16:34:22 -05:00
Ed Page
cbb3222959 test: Migrate some json test tests to snapbox 2024-07-24 10:42:51 -05:00
Ed Page
3a615ca9c8 feat(test): Add CargoPathExt to prelude 2024-07-18 15:22:29 -05:00
Ed Page
5b9799c6f4 refactor: Migrate from extern crate to test-support prelude
We now include the prelude in so many places, this simplifies how we can
present how `cargo-test-support` works.

Yes, this included some `use` clean ups but its already painful enough
walking through every test file, I didn't want to do it twice.
2024-07-12 15:57:00 -05:00
eth3lbert
b3b814e713
test: migrate test to snapbox 2024-07-10 10:09:18 +08:00
Ed Page
dc5ac62cab fix(test): Deprecate non-snapbox assertions
While this is noisy and hides other deprecations, I figured deprecations would
make it easier for people to discover what tasks remain and allow us to
divide and conquer this work rather than doing a heroic PR.
In theory, this will be short lived and we'll go back to seeing
deprecations in our tests.
2024-06-10 10:20:52 -05:00
Tobias Bucher
a29742a396 Use u64 rather than usize as "default integer" in library template
`usize` was renamed from `uint` in order to convey that it's not the
"default integer type". Guide new users to use integers with specific
bit width instead of `usize`.
2024-05-22 16:11:00 +02:00
Ed Page
f1caef11c4 test: Move off of deprecated manifest fields 2024-04-18 14:11:31 -05:00
Ed Page
1876326b6b feat(resolve): Tell the user the style of resovle done
This is to help with #9930

Example changes:
```diff
-[LOCKING] 4 packages
+[LOCKING] 4 packages to latest version
-[LOCKING] 2 packages
+[LOCKING] 2 packages to latest Rust 1.60.0 compatible versions
-[LOCKING] 2 packages
+[LOCKING] 2 packages to earliest versions
```

Benefits
- The package count is of "added" packages and this makes that more
  logically clear
- This gives users transparency into what is happening, especially with
  - what rust-version is use
  - the transition to this feature in the new edition
  - whether the planned config was applied or not (as I don't want it to
    require an MSRV bump)
- Will make it easier in tests to show what changed
- Provides more motiviation to show this message in `cargo update` and
  `cargo install` (that will be explored in a follow up PR)

This does come at the cost of more verbose output but hopefully not too
verbose.  This is why I left off other factors, like avoid-dev-deps.
2024-04-13 20:39:59 -05:00
Ed Page
4ab2797f36 feat(lock): Print lockfile changes on all commands 2024-03-12 13:39:56 -05:00
bors
69726309bf Auto merge of #12783 - dvdhrm:pr/libname2, r=ehuss
cargo: prevent dashes in lib.name

The TOML parser of Cargo currently refuses `lib.name` entries that contain dashes. Unfortunately, it uses the package-name as default if no explicit `lib.name` entry is specified. This package-name, however, can contain dashes.

Cargo documentation states that the package name is converted first, yet this was never implemented by the code-base.

Fix this inconsistency and convert the package name to a suitable crate-name first.

This fixes #12780. It is an alternative to #12640.
2024-03-16 20:50:35 +00:00
Ed Page
14646e6af6 test: Make edition explicit on packages 2024-02-22 11:37:03 -06:00
Ed Page
831847e5f0 fix(rustc): Always pass --edition to rustc
On [Internals](https://internals.rust-lang.org/t/idea-rustc-cargo-should-warn-on-unspecified-edition/20309),
the idea came up for warning on unset Edition.
I am working on the cargo warning but if rustc ever wants to do so,
they'd be blocked on cargo ensuring `--edition` is always set.
Hence this change.
2024-02-28 15:35:41 -06:00
Weihang Lo
34215b1b4a
fix: doctest searches native libs in build script outputs
HACK: `rustdoc --test` not only compiles but executes doctests.
Ideally only execution phase should have search paths appended,
so the executions can find native libs just like other tests.
However, there is no way to separate these two phase, so this
hack is added for both phases.
2024-02-25 22:55:44 -05:00
Weihang Lo
0e8a67fde3
test(doctest): doctest doesn't set shared libs to search path
This new test demonstrate the current behavior.
2024-02-25 19:29:05 -05:00
Ed Page
e7e8d8748a fix(compiler): Clarify we're showing a profile name 2024-02-08 14:01:39 -06:00
Wim Looman
255914696a
Apply -Zpanic-abort-tests to doctests too 2024-02-02 19:45:15 +01:00
Wim Looman
4ebbda15e1
Ensure nonzero_exit_code test isn't affected by developers RUST_BACKTRACE setting 2024-02-02 16:04:21 +01:00