Commit graph

5838 commits

Author SHA1 Message Date
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
bors a3ba4ee28a Auto merge of #13438 - Urgau:check-cfg-msrv-annoyance, r=ehuss
Silently ignore `cargo::rustc-check-cfg` to avoid MSRV annoyance when stabilizing `-Zcheck-cfg`

This PR, removes the warning when trying to use `cargo::rustc-check-cfg` on stable or nightly (without the nightly-only `-Zcheck-cfg` flag) to avoid MSRV annoyance when stabilizing `-Zcheck-cfg`.

See this [Zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/check-cfg.20backwards.20compatible.20warnings) for more information and context.

cc `@ehuss`
2024-02-28 15:14:12 +00:00
bors 8964c8ccff Auto merge of #13340 - linyihai:Z-public, r=epage
feat: Add "-Zpublic-dependency" for public-dependency feature.

### What does this PR try to resolve?
Part of https://github.com/rust-lang/cargo/issues/13308, include:
- Switching the cargo-features to a -Z
- Warning if public is used without -Z and setting it to false

These had not done yet:
- We should also warn if the data type changes but that is less likely to happen and could possibly be skipped
- Ensuring the published version of the package does not have public

### How should we test and review this PR?
All test case should be pass.

### Additional information

r? `@epage`
2024-02-27 19:22:46 +00:00
Lin Yihai 01de3e0fe7 feat: Add "-Zpublic-dependency" for public-dependency feature 2024-02-27 05:10:17 +08:00
Eric Huss 39863e7f54 Stabilize global cache data tracking. 2024-02-26 11:37:54 -08: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
Urgau da5900740e Silently ignore cargo::rustc-check-cfg to avoid MSRV annoyance 2024-02-24 19:52:52 +01:00
Weihang Lo 81b3b5ad4f
test: relax help text assertion
When running test in rust-lang/rust via `./x test src/tool/cargo`,
there is no rustup integrated.
2024-02-24 11:50:41 -05:00
Weihang Lo 75dbb86591
doc: link to GlobalContext item 2024-02-23 16:03:23 -05:00
Ed Page b14a70fe09 test(cli): Verify terminal styling
This uses a new feature from snapbox that let's us render terminal
styling in SVG files.  This let's us see / visualize ANSI escape codes,
including in github's UI (will render images, including side-by-side
images for diffs).
2024-02-21 20:20:41 -06:00
bors b425030678 Auto merge of #13480 - Cerber-Ursi:workspace-error-shows-path, r=epage
Error messages when collecting workspace members now mention the workspace root location

Fixes https://github.com/rust-lang/cargo/issues/13394

### What does this PR try to resolve?

This is a small tweak in error messages for workspaces, with intention to make it easier for users who accidentally created some unwanted workspace and then was surprised by the error coming seemingly out of nowhere. The exact inspiration for the change was [this comment](https://users.rust-lang.org/t/cargo-using-wrong-directory/107126/9?u=cerber-ursi) in discussion on URLO.

### How should we test and review this PR?

This is a simple change in error messages, so the existing test suite should probably be enough. Requests for changing the text further are welcome, of course.
2024-02-22 19:49:12 +00:00
Cerber-Ursi 51c8e0eb51 slightly reworded message to show the main parts first
Co-authored-by: Ed Page <eopage@gmail.com>
2024-02-23 02:27:01 +07:00
bors e08a81333c Auto merge of #13281 - LuuuXXX:issue-10729, r=epage
fix(add): Improve error when adding registry packages while vendored

### **What does this PR try to resolve?**

When a vendored directory is established, cargo add no longer adds new packages. Instead, it tries to translate a package name into a package that already exists in the vendored directory.
[More details](https://github.com/rust-lang/cargo/issues/10729#issue-1260548746)

Since `@epage` has done most of the work, here I do the rest of the finishing work.

Improves the error from #10729

### **How should we test and review this PR?**

The implementation procedure is as follows:
https://github.com/rust-lang/cargo/issues/10729#issuecomment-1191633351

Test steps:
1. Try to get an arbitrary crate and execute `cargo vendor` command.
2. Configure the vendor directory in .cargo/config.toml.
3. Add `alter-registry` to the config.toml file.
```
[registries]
alter-registry= { index = "XXX" }
```
4. run the same `cargo add` command.
```
cargo add another-crate --registry alter-registry
```
2024-02-22 17:28:17 +00:00
Cerber Ursi 07eb70811f add workspace root path to error messages on members collecting 2024-02-22 22:56:26 +07:00
LuuuX a31184b9eb Added QueryKind::Normalized, and used it in cargo-add 2024-02-22 13:36:28 +08:00
LuuuX 7dc7b1bc99 Add two tests to make sure fixup 2024-02-22 12:34:40 +08:00
bors cafbc12bd9 Auto merge of #13467 - ehuss:global-tracker-old-cargo, r=weihanglo
Add global_cache_tracker stability tests.

This adds some tests to ensure that the database used in the global cache tracker stays compatible across versions. These tests work by using rustup to run both the current cargo and the stable cargo, and verifying that when switching versions, everything works as expected.

These tests will be ignored on developer environments if they don't have rustup, or don't have the stable toolchain installed. It does assume that "stable" is at least 1.76. It is required for the tests to run in CI, but will be disabled in rust-lang/rust since it does not have rustup.

I'm not expecting too much trouble with these tests, but if they become too fiddly or broken, they can always be changed or removed.

The support code for running "cargo +stable" is very basic right now. If we expand to add similar tests in the future, then I think we could consider adding support functions (such as [`tc_process`](64ccff290f/tests/testsuite/old_cargos.rs (L21-L36))) to make it easier or more reliable.
2024-02-21 21:32:07 +00:00
bors 3d47dd412e Auto merge of #13197 - weihanglo:target-triple-rustdocflags, r=epage
feat: support `target.<triple>.rustdocflags` officially
2024-02-21 01:24:44 +00:00
Eric Huss 27f84f6b68 Fix unused imports on Windows. 2024-02-20 16:28:37 -08:00
Eric Huss a82794ec4a Fix path issues for running rustup wrapper on Windows.
Cargo likes to modify PATH, which circumvents the ability to choose the
correct "cargo" executable to run on Windows (because Windows uses PATH
for both binary and shared library searching).
2024-02-20 16:27:04 -08:00
Weihang Lo 6131e991af
test: target.triple.rustdocflags works for doctest 2024-02-20 19:15:53 -05:00
Weihang Lo 652a8413d7
feat: support target.triple.rustdocflags officially
`CARGO_TARGET_<TRIPLE>_RUSTDOCFLAGS` was accidentally accepted somehow,
so support both config and env officially,
given that removing env support would be a breaking change.
2024-02-20 19:15:42 -05:00
Weihang Lo 44c69d83d6
test: demonstrate target.triple.rustdocflags doesnt work 2024-02-20 19:02:08 -05:00
Eric Huss 9f71231391 Add global_cache_tracker stability tests.
This adds some tests to ensure that the database used in the global
cache tracker stays compatible across versions. These tests work by
using rustup to run both the current cargo and the stable cargo, and
verifying that when switching versions, everything works as expected.
2024-02-20 12:43:07 -08:00
bors 64ccff290f Auto merge of #13465 - epage:delete, r=weihanglo
test: Remove empty snapshots

Inspired by #13461
2024-02-20 20:12:08 +00:00
Ed Page ac453f1c37 test: Remove empty snapshots for UI tests 2024-02-20 13:29:09 -06:00
Ed Page 2e878a4c38 test: Remove empty snapshots for help 2024-02-20 13:05:16 -06:00
Scott Schafer 305efa63cc
chore: Rename Config to GlobalContext 2024-02-20 11:55:15 -07:00
bors e7ff7a6618 Auto merge of #12861 - weihanglo:msrv-aware-lockfile, r=ehuss
feat: respect `rust-version` when generating lockfile
2024-02-19 19:05:03 +00:00
Ed Page 9f31f8c675 chore: Update snapbox 2024-02-16 10:27:48 -06:00
Weihang Lo 9ae485df28
test(lockfile): v4 isn't the default for rust-version 1.77 2024-02-16 10:06:32 -05:00
Weihang Lo fb95ac4887
feat: respect rust-version when generating lockfile
Respect `package.rust-version` when generating lockfile, so that
a package with an old MSRV will never get an incompatible lockfile,
even when using the latest Cargo.

Users are still able to edit the `version` field in the lockfile
manually, if they intend to switch to a specific lockfile version.
2024-02-16 10:06:00 -05:00
Weihang Lo 92b82d6134
test: demonstrate old lockfile compat matrix 2024-02-16 10:05:59 -05:00
Ed Page bdc4e8ded0 fix(add): Remove inconsistent period
Don't see this in other status messages, so removing it
2024-02-12 11:06:04 -06:00
bors 30addeaa90 Auto merge of #13434 - epage:add-features, r=weihanglo
fix(add): Ensure users know a feature is being created

Inspired by #13430 and #13411
2024-02-15 18:29:11 +00:00
Eric Huss 52d2303dd0 Update future-incompat output test for latest nightly. 2024-02-15 09:36:40 -08:00
Eric Huss d3c2a7723f Update target data layout for LLVM update. 2024-02-15 08:47:26 -08:00
bors 10a7f20ba0 Auto merge of #13435 - ehuss:fix-old-cargos, r=epage
Fix old_cargos tests

Some of these tests have bitrotted a bit since they aren't enabled by default. The issues are:

* Change to `config` to `config.toml` shouldn't have been made to this test since old cargos can't read config.toml.
* Cargo's own `Carog.toml` now using dotted keys breaks parsing on some old versions, ignore them.
* `cargo pkgid` is now emitting a different format.
* #13085 changed how packages are published in the testsuite to correctly include the `[features]` table in the generated `Cargo.toml`. This exposed an oversight in the `old_cargos::new_features` test wasn't actually testing things correctly. It now correctly illustrates the errors received in older versions. I have a vague memory of this, but I don't remember why it was done this way.
* #10907 changed the default config to use `[registries]` instead of `[source]` to implement source replacement of crates.io. Older versions can't handle that.

Some of these tests probably should just be deleted, since I don't think they are really bringing much value. Or at least they should have some floor that they won't test under. However, I'm not quite ready to do that.
2024-02-12 19:11:12 +00:00
Eric Huss 01d8a2d815 Fix old_cargos tests 2024-02-12 10:41:34 -08:00
Ed Page dbdebc378a fix(add): Ensure users know a feature is being created
Inspired by #13430 and #13411
2024-02-12 11:05:32 -06:00
Arlo Siemsen dbd7c989a7 Fix confusing error messages for sparse index replaced source 2024-02-12 10:59:05 -06:00
Ed Page e7e8d8748a fix(compiler): Clarify we're showing a profile name 2024-02-08 14:01:39 -06:00
bors 571edcb733 Auto merge of #13411 - linyihai:hint-for-cargo-new, r=epage
feat: Add hint for adding members to workspace

### What does this PR try to resolve?

Fixes https://github.com/rust-lang/cargo/issues/13403

### How should we test and review this PR?
Reviewd commit by commit

### Additional information
2024-02-08 11:35:56 +00:00
bors ccc84ccec4 Auto merge of #13415 - oli-obk:relax_test_for_rustc_changes, r=weihanglo
Relax a test to permit warnings to be emitted, too.

This change is necessary to allow rustc to actually start emitting the warning about the unused `mut`

See the test failure in https://github.com/rust-lang/rust/pull/120550#issuecomment-1931802095 for where this happens.
2024-02-07 15:37:49 +00:00
Oli Scherer e60678fae0 Relax a test to permit warnings to be emitted, too.
This change is necessary to allow rustc to actually start emitting the warning about the unused `mut`
2024-02-07 15:16:40 +00:00
bors 9a6bafd956 Auto merge of #13416 - weihanglo:disable-lldb, r=epage
test: disable lldb test as it requires privileges to run on macOS

Resolves #13413
2024-02-07 14:53:24 +00:00
Weihang Lo cd1f08899e
test: disable lldb test as it requires privileges to run on macOS 2024-02-07 09:45:25 -05:00
bors 993418efd7 Auto merge of #13410 - epage:note, r=weihanglo
fix: Switch more notes/warnings to lowercase

See https://doc.crates.io/contrib/implementation/console.html#style

By fixing existing cases, we make it more likely people will copy a case they should.

I left out multi-sentence cases because I was unsure how to handle those
2024-02-07 03:07:12 +00:00