910 Commits

Author SHA1 Message Date
Ed Page
fd8a91d185 fix(test): Un-redact Packaged files
This is a partial revert of ##14121
(e11d1722bb6e1e58c91adb1964993c74b45f4293)

Our focus for redacting (auto or with globs) includes
- run-specific information (timing, hashes, platform-specific wording)
- rustc-specific information

(We tend to use globs for rustc-specific information because there might
be some very specific times we need to care about some of the details)

However, "Packaged files" does not fit into any of that and, for now, we
are erring on the side of redacting less, rather than more, with the
move to snapbox.
As we see how it works out and what the underlying requirements are, we
can revisit this.
2024-06-21 11:05:41 -04:00
bors
922960916d Auto merge of #14121 - dieterplex:redact-file-num, r=weihanglo
test: Auto-redact file number

This is from <https://github.com/rust-lang/cargo/pull/14096#discussion_r1648889843>.

Although the number of files in `cargo package` is important,
we have `validate_crate_contents` and `validate_upload_with_contents`
that verify the exact contents.
Redacting `Packaged` status should be fine.
2024-06-21 13:14:27 +00:00
bors
99361c46e0 Auto merge of #14092 - Alexendoo:rustfix-separate-suggestions, r=weihanglo
Add `CodeFix::apply_solution` and impl `Clone`

### What does this PR try to resolve?

In Clippy we have a good few lints that produce mutually exclusive suggestions e.g.

```
error: octal-looking escape in a literal
  --> tests/ui/octal_escapes.rs:6:19
   |
LL |     let _bad2 = b"\033[0m";
   |                   ^^^^
   |
help: if an octal escape is intended, use a hex escape instead
   |
LL |     let _bad2 = b"\x1b[0m";
   |                   ~~~~
help: if a null escape is intended, disambiguate using
   |
LL |     let _bad2 = b"\x0033[0m";
   |                   ~~~~~~
```

For these we have to disable rustfix tests since the suggestions are overlapping, this PR adds a method to `rustfix` that `ui_test` could use in order to produce multiple `.fixed` files, one for each alternative suggestion

### Additional information

It does not work for for multiple suggestions coming from a single subdiagnostic ([`Diag::span_suggestions`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_errors/diagnostic/struct.Diag.html#method.span_suggestions)) e.g.

```
help: consider importing one of these items
  |
1 + use std::collections::HashMap;
  |
1 + use ahash::HashMap;
```

Solving this would be blocked on https://github.com/rust-lang/rust/issues/53934, on the Clippy side we only have one use of `span_suggestions` however so it's still very useful without this

The test cases use Clippy lints that I generated by setting the `parse_and_replace` test to use `clippy-driver` because of familiarity, if there's a rustc case that does multiple suggestions it would be good to go with that
2024-06-19 20:32:26 +00:00
Alex Macleod
5a15397611 Add CodeFix::apply_solution and impl Clone 2024-06-19 19:06:36 +00:00
d1t2
e11d1722bb
test: Auto-redact file number 2024-06-19 20:00:56 +08:00
Weihang Lo
6a684edcb6
test: fix the [FINISHED] escape 2024-06-18 13:58:56 -04:00
Weihang Lo
153856fe14
test: prefer raw string for regex reduction 2024-06-18 13:58:13 -04:00
Weihang Lo
f4985827d7
chore: bump cargo-test-{support,macro} due to public API changes 2024-06-17 11:37:21 -04:00
Weihang Lo
80980d984a
chore(bump-check): cargo-test-{support,macro} on crates.io 2024-06-17 10:09:46 -04:00
Lawrence Chou
fde1321381
Remove Execs::run_expect_error to avoid #14076 2024-06-16 09:13:24 +08:00
Ed Page
b07e87656f chore: Bump version for internal crates 2024-06-13 13:38:32 -05:00
renovate[bot]
a018e3a946
chore(deps): update msrv (1 version) to v1.79 2024-06-13 17:27:19 +00:00
Scott Schafer
190ef86d06
test: Auto-redact file hash 2024-06-12 13:27:08 -06:00
Scott Schafer
875a25fba7
test: Auto-redact exit status 2024-06-12 13:27:08 -06:00
Scott Schafer
02459b707f
test: Auto-redact bench timing results 2024-06-12 13:27:08 -06:00
Scott Schafer
6a7b15a61e
test: Auto-redact host target and alt target 2024-06-12 13:27:08 -06:00
Scott Schafer
d7de93777d
test: Only compile regex replacements once 2024-06-12 13:26:54 -06:00
Scott Schafer
6914c2958f
test: Merge common redactions 2024-06-12 09:28:24 -06:00
bors
4dcbca118a Auto merge of #13926 - tweag:overlay, r=epage
Add local registry overlays

This PR adds (private to cargo internals) support for local registry overlays, in which you can locally pretend to add packages to remote registries; the local packages will have the same source ids as the remote registry that you're overlaying.

There are two ways to set up these overlays: programmatically using `GlobalContext::local_overlays` and through the `__CARGO_TEST_PACKAGE_CONFUSION_VULNERABILITY_DO_NOT_USE_THIS` environment variable. You can't set up these overlays with `.cargo/config`.

The motivation for this is [packaging workspaces](https://github.com/rust-lang/cargo/issues/10948). When we're packing a workspace, we'd like to be able to pretend (for lockfile generation and verification) that some workspace packages are already published even though they aren't.
2024-06-11 16:27:02 +00:00
Weihang Lo
c5a6a6cfa4
test: auto-redact elapsed time from libtest output 2024-06-10 20:54:32 -04:00
Joe Neeman
ba9dd1ea2e Adds tests for source overlays. 2024-06-10 18:32:22 -05:00
Joe Neeman
04c963a993 Add workspace support for source overlays
Adds workspace configuration options (not user-exposed) for overlaying
sources.
2024-06-10 18:32:22 -05: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
Ed Page
ff2ddebc71 feat(test): Allow snapshotting of Execs 2024-06-10 10:20:52 -05:00
Ed Page
0761937bc7 feat(test): Auto-redact registry source hashes 2024-06-10 10:20:52 -05:00
Ed Page
8b7de1ea81 feat(test): Auto-redact crate sizes from cargo-package 2024-06-10 10:20:52 -05:00
Ed Page
15e3412b2f fix(test): Ensure panics show test code, not lib 2024-06-10 10:20:52 -05:00
Ed Page
d028cfaba3 chore(test): Bump cargo-test-support to 0.2.2 2024-06-10 10:20:52 -05:00
bors
d8f9130c62 Auto merge of #14038 - epage:schemas, r=weihanglo
chore: Bump cargo-util-schemas to 0.5

See #13902
2024-06-10 14:57:18 +00:00
Ed Page
786ebe9d14 chore: Bump cargo-util-schemas to 0.5
See #13902
2024-06-10 09:53:58 -05:00
hi-rustin
b8b84ceffd
chore(deps): update rust crate pulldown-cmark to 0.11.0
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2024-06-10 21:47:13 +08:00
bors
54d9c3306b Auto merge of #13902 - heisen-li:plugin, r=weihanglo
fix(toml): remove `lib.plugin` key support and make it warning

### What does this PR try to resolve?

Remove `lib.plugin` key, making it an "unused key" warning.

Remove some of the tests, which should look useless (I hope I'm understanding this

- [x] Remove key, and related tests.
- [x] Adjust the documentation about the plugin.
- [ ] Some of the comments and function names have not yet finished being modified.

part of #13629

Closes #13246
2024-06-09 18:07:55 +00:00
bors
fb123c668b Auto merge of #13979 - tweag:issue-12425, r=epage
Add `cargo update --breaking`

Related to #12425.

There are two kinds of manifest mutations here. In `upgrade_manifests` we have to mutate `cargo::core::manifest::Manifest` so that `resolve_ws` does what it needs to do, and outputs a correct lock file. Then, in `write_manifest_upgrades` we mutate `cargo::util::toml_mut::manifest::Manifest`, because that is how we can preserve the existing formatting in the manifest files on disk.

Some of the code here is copied from `cargo-edit`.

# Comparison with `cargo upgrade`

Running on the Cargo source itself gives the following:

```
❯ cargo upgrade --dry-run --incompatible allow --compatible ignore
    Updating 'https://github.com/rust-lang/crates.io-index' index
    Checking benchsuite's dependencies
    Checking capture's dependencies
    Checking cargo's dependencies
name               old req compatible latest  new req note
====               ======= ========== ======  ======= ====
anstream           0.6.13  0.6.14     0.6.14  0.6.13  compatible
anstyle            1.0.6   1.0.7      1.0.7   1.0.6   compatible
anyhow             1.0.82  1.0.86     1.0.86  1.0.82  compatible
itertools          0.12.1  0.12.1     0.13.0  0.13.0
libc               0.2.154 0.2.155    0.2.155 0.2.154 compatible
opener             0.7.0   0.7.1      0.7.1   0.7.0   compatible
openssl            0.10.57 0.10.64    0.10.64 0.10.57 compatible
openssl-sys        =0.9.92 0.9.92     0.9.102 =0.9.92 pinned
pulldown-cmark     0.10.3  0.10.3     0.11.0  0.11.0
security-framework 2.10.0  2.11.0     2.11.0  2.10.0  compatible
semver             1.0.22  1.0.23     1.0.23  1.0.22  compatible
serde              1.0.199 1.0.203    1.0.203 1.0.199 compatible
serde-untagged     0.1.5   0.1.6      0.1.6   0.1.5   compatible
serde_json         1.0.116 1.0.117    1.0.117 1.0.116 compatible
tar                0.4.40  0.4.41     0.4.41  0.4.40  compatible
thiserror          1.0.59  1.0.61     1.0.61  1.0.59  compatible
toml               0.8.12  0.8.14     0.8.14  0.8.12  compatible
toml_edit          0.22.12 0.22.14    0.22.14 0.22.12 compatible
unicode-width      0.1.12  0.1.13     0.1.13  0.1.12  compatible
    Checking cargo-credential's dependencies
    Checking cargo-credential-1password's dependencies
    Checking cargo-credential-libsecret's dependencies
    Checking cargo-credential-macos-keychain's dependencies
    Checking cargo-credential-wincred's dependencies
    Checking cargo-platform's dependencies
    Checking cargo-test-macro's dependencies
    Checking cargo-test-support's dependencies
    Checking cargo-util's dependencies
    Checking cargo-util-schemas's dependencies
    Checking crates-io's dependencies
    Checking home's dependencies
    Checking mdman's dependencies
    Checking resolver-tests's dependencies
    Checking rustfix's dependencies
    Checking semver-check's dependencies
    Checking xtask-build-man's dependencies
    Checking xtask-bump-check's dependencies
    Checking xtask-stale-label's dependencies
note: Re-run with `--pinned` to upgrade pinned version requirements
note: Re-run with `--verbose` to show all dependencies
  local: cargo
  unchanged: annotate-snippets, base64, bytesize, cargo-credential, cargo-credential-libsecret, cargo-credential-macos-keychain, cargo-credential-wincred, cargo-platform, cargo-test-macro, cargo-test-support, cargo-util, cargo-util-schemas, cargo_metadata, clap, color-print, core-foundation, crates-io, criterion, curl, curl-sys, filetime, flate2, git2, git2-curl, gix, glob, handlebars, hex, hmac, home, http-auth, humantime, ignore, im-rc, indexmap, jobserver, lazycell, libgit2-sys, libloading, memchr, miow, os_info, pasetors, pathdiff, percent-encoding, pkg-config, proptest, rand, regex, rusqlite, rustfix, same-file, serde-value, serde_ignored, sha1, sha2, shell-escape, similar, snapbox, supports-hyperlinks, supports-unicode, tempfile, time, tracing, tracing-chrome, tracing-subscriber, unicase, unicode-xid, url, varisat, walkdir, windows-sys
warning: aborting upgrade due to dry run

❯ target/debug/cargo update --breaking --dry-run -Zunstable-options
    Updating crates.io index
   Upgrading itertools ^0.12.1 -> ^0.13.0
   Upgrading pulldown-cmark ^0.10.3 -> ^0.11.0
    Updating crates.io index
     Locking 3 packages to latest compatible versions
    Updating itertools v0.12.1 -> v0.13.0
    Updating pulldown-cmark v0.10.3 -> v0.11.0
    Updating pulldown-cmark-escape v0.10.0 -> v0.11.0
warning: not updating any files due to dry run
```

In both cases we see an upgrade of `itertools` to `^0.13.0` and `pulldown-cmark` to `^0.11.0`.

The diff to the manifest (when it isn't a dry run) is as follows:

```
--- a/Cargo.toml
+++ b/Cargo.toml
`@@` -57,7 +57,7 `@@` humantime = "2.1.0"
 ignore = "0.4.22"
 im-rc = "15.1.0"
 indexmap = "2.2.6"
-itertools = "0.12.1"
+itertools = "0.13.0"
 jobserver = "0.1.31"
 lazycell = "1.3.0"
 libc = "0.2.154"
`@@` -74,7 +74,7 `@@` pathdiff = "0.2.1"
 percent-encoding = "2.3.1"
 pkg-config = "0.3.30"
 proptest = "1.4.0"
-pulldown-cmark = { version = "0.10.3", default-features = false, features = ["html"] }
+pulldown-cmark = { version = "0.11.0", default-features = false, features = ["html"] }
 rand = "0.8.5"
 regex = "1.10.4"
 rusqlite = { version = "0.31.0", features = ["bundled"] }
```

# TODO

- [x] In the case of `--incompatible`, we also need to let `update_lockfile` use `upgrades` in order to only update the incompatible dependencies.
- [x] Testing all the different cases of package sources, version requirements, pinned versions, renamed dependencies, inherited workspace dependencies, multiple versions of the same dependency, selecting a subset `--package`, etc.
- [x] Passing tests.
- [x] Implement suggestions from reviews.
- [x] The preservation of formatting in manifest files should be improved.
- [x] Compare with `cargo upgrade`.
2024-06-07 17:11:18 +00:00
Tor Hovland
031b410181 feat: Implement cargo update --breaking. 2024-06-07 09:13:28 +02:00
Scott Schafer
7d7b7c2c8b
feat: Add an xtask to generate lint documentation 2024-06-06 23:03:53 -06:00
bors
d503f744bc Auto merge of #13977 - linyihai:doc-resolver-tests, r=Eh2406
doc: Add README for resolver-tests

### What does this PR try to resolve?

This collect the comments from `@Eh2406` about the resolver-tests and add a README to it.

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

### Additional information

Maybe Fixed https://github.com/rust-lang/cargo/issues/13319
See  https://github.com/rust-lang/cargo/pull/11938#issuecomment-1868426431
2024-06-03 15:14:46 +00:00
bors
4b681c7338 Auto merge of #13980 - epage:compare, r=hi-rustin
refactor: Transition direct assertions from cargo-test-support to snapbox

### What does this PR try to resolve?

Cargo has a bespoke testing framework for functional tests
- Extra stuff for us to maintain
- Don't leverage benefits from contributions related to other projects
- Less incentive to be thoroughly documented

UI tests are written using snapbox.  The latest release of snapbox (#13963) was geared at supporting cargo's needs in the hope that we can consolidate on testing frameworks.

Besides having a single set of semantics, benefits we'd gain include
- Updating of test snapshots
- Fancier redacting of test output (e.g. #13973)

This is the first incremental step in this direction.  This replaces direct assertions with snapbox assertions.  This still leaves all of the CLI output assertions. These will be done incrementally.

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

### Additional information
2024-06-02 14:48:01 +00:00
renovate[bot]
a2e32f2493
chore(deps): update alpine docker tag to v3.20 2024-06-01 00:52:26 +00:00
Lin Yihai
861429b113 doc: Add README for resolver-tests 2024-05-30 17:02:34 +08:00
Ed Page
995746b937 refactor: Port from matches_contains to assert_e2e 2024-05-29 14:08:10 -05:00
Ed Page
eee1053384 refactor: Port from matches_unordered to assert_e2e 2024-05-29 14:08:10 -05:00
Ed Page
3054936cab refactor: Port from assert_matches_exact to assert_e2e
This leaves off `validate_crate_contents` as that would be an effort on
its own
2024-05-29 14:08:10 -05:00
Ed Page
fe5c2d393a refactor(test): Pull out end-to-end literal redactions 2024-05-29 14:08:10 -05:00
Ed Page
ea36ed09f3 refactor(test): Share redactions between ui and e2e 2024-05-29 14:08:10 -05:00
Ed Page
94119af2a5 docs(test): Clarify role of assert_ui 2024-05-29 14:08:10 -05:00
Ed Page
f22c43b87d fix(test)!: Hide API that isnt used by Cargo 2024-05-29 14:08:10 -05:00
Ed Page
5ea1c8fea9 feat(test): Auto-redact elapsed time 2024-05-27 21:27:25 -05:00
Ed Page
9af864ee55 refactor: Resolve deprecations 2024-05-27 21:27:03 -05:00
Ed Page
eafc743c0d chore: Update to snapbox 0.6
We needed to tweak the redactions because snapbox no longer normalizes
slashes on redactions unless the data type is a `PathBuf`.
2024-05-27 21:26:20 -05:00
Ed Page
0bd034cd06 refactor(test): Split up calls by type 2024-05-27 21:24:43 -05:00