1125 Commits

Author SHA1 Message Date
Ed Page
090064cc14 feat(test): Add cargo_test to test-support prelude 2024-07-12 15:56:22 -05:00
Ed Page
7fcd580b3b fix(test): Redact elapsed time in the minutes time frame
This came up in #14231
```
---- expected: tests/testsuite/lto.rs:611:27
++++ actual:   stderr
   1    1 | [FRESH] registry-shared v0.0.1
   2    2 | [FRESH] registry v0.0.1
   3    3 | [COMPILING] bar v0.0.0 ([ROOT]/foo/bar)
   4    4 | [RUNNING] `rustc --crate-name bar [..]-C lto [..]--test [..]`
   5    5 | [RUNNING] `rustc --crate-name b [..]-C lto [..]--test [..]`
   6      - [FINISHED] `release` profile [optimized] target(s) in [ELAPSED]s
   7    6 | [RUNNING] `[ROOT]/foo/target/release/deps/bar-[HASH][EXE]`
   8    7 | [RUNNING] `[ROOT]/foo/target/release/deps/b-[HASH][EXE]`
   9    8 | [DOCTEST] bar
  10    9 | [RUNNING] `rustdoc --edition=2015 --crate-type cdylib --crate-type rlib --crate-name bar --test [..]-C lto [..]
       10 + [FINISHED] `release` profile [optimized] target(s) in 1m 00s

Update with SNAPSHOTS=overwrite
```
2024-07-10 16:42:21 -05:00
Ed Page
5ed63926d3 test(test): Verify elapsed redaction 2024-07-10 16:40:47 -05:00
Ed Page
a10b3ca8b2 refactor(test): Split out 'pure' redactions for testing 2024-07-10 16:37:12 -05:00
Ed Page
c8113d3a1c refactor(test): Move compare tests into a mod 2024-07-10 16:33:14 -05:00
tianyeyouyou
87084c176b remove duplicate words 2024-07-10 20:51:45 +08:00
bors
753ae28c06 Auto merge of #14161 - choznerol:issue-14039-snapshot-port-freshness, r=weihanglo
test: Auto-redact `... after last build at ...`; Migrate `freshness` to Snapbox
2024-07-03 21:53:31 +00:00
Lawrence Chou
bbc18d7009
Auto-redact dirty reason like 1719325877.527949100s, 61549498ns after last build at 1719325877.466399602s
7dcf764cbc/src/cargo/core/compiler/fingerprint/dirty_reason.rs (L131)
2024-07-03 23:48:14 +08:00
bors
a0b280398c Auto merge of #14171 - heisen-li:dir_doc, r=weihanglo
test:migrate `doc/directory/docscrape` to snapbox

### What does this PR try to resolve?

Complete the following file migration:
```
 tests/testsuite/directory.rs
 tests/testsuite/doc.rs
 tests/testsuite/docscrape.rs
```

part of #14039
2024-07-03 03:09:49 +00:00
heisen-li
78983534df add opening redact 2024-07-03 09:59:13 +08:00
bors
9441b91186 Auto merge of #14159 - dieterplex:migrate-git-snapbox, r=weihanglo
test: Migrate git to snapbox

Part of #14039.

There is a case need to modify regex for file size redaction.
2024-06-28 13:05:10 +00:00
d1t2
ed027736e7
test: Allow redact file size w/o fraction
`cargo clean` shows file size without fraction in summary when the size
is lower than 1024. And we need to avoid matching things like `%2B%23..`
found in other test cases, the trailing `\s` is added to regex.
2024-06-27 16:58:52 +08:00
eth3lbert
03a0b5c999
Auto-redact not found 2024-06-27 12:55:34 +08:00
eth3lbert
cfabfe5467
test: Auto-redact target dir hashes 2024-06-23 11:10:15 +08:00
eth3lbert
91569f84b0
test: Add auto-redaction for not found error 2024-06-22 05:13:58 +08:00
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