6183 Commits

Author SHA1 Message Date
Lawrence Chou
fde1321381
Remove Execs::run_expect_error to avoid #14076 2024-06-16 09:13:24 +08:00
Lawrence Chou
afe9d17258
Reproduce #14076
The `with_stderr_contains()` (as well as the new `with_stderr_data()` too, see #14060) has no effect when using with `run_expect_error()`.
2024-06-16 09:13:09 +08:00
bors
ea16f96033 Auto merge of #14060 - choznerol:issue-14039-snapshot-port-help, r=weihanglo
test: migrate help to snapbox
2024-06-15 21:25:49 +00:00
d1t2
bd451d0ac0 test: Migrate tests/testsuite/co*.rs to snapbox
Part of #14039
2024-06-15 17:45:21 +00:00
Lawrence Chou
8db30bc4bd
Use snapshot generated by SNAPSHOTS=overwrite cargo test 2024-06-15 22:43:11 +08:00
Lawrence Chou
e5e9f2f7c5
Remove [..] and mention #14076 caveat 2024-06-15 15:32:18 +08:00
Lawrence Chou
eef057ea0f
Dedup with cargo_search::help::case (https://github.com/rust-lang/cargo/pull/14060#discussion_r1638479136) 2024-06-15 15:02:37 +08:00
Lawrence Chou
3fd3879bc8
Dedup with cargo::z_help::case (https://github.com/rust-lang/cargo/pull/14060#discussion_r1638481972)
# Conflicts:
#	tests/testsuite/help.rs
2024-06-15 15:02:34 +08:00
Lawrence Chou
3a95c7846d
Revert "Tmp commit prior to SNAPSHOTS=overwrite cargo t --test testsuite help::"
This reverts commit cbaa4a89e60507366401ac0076d652f5eafc4998.
2024-06-15 15:02:14 +08:00
Lawrence Chou
715cba9189
Tmp commit prior to SNAPSHOTS=overwrite cargo t --test testsuite help::
# Conflicts:
#	tests/testsuite/help.rs
2024-06-15 15:02:13 +08:00
bors
a1f47ec3f7 Auto merge of #14074 - tweag:verification-order, r=epage
Change verification order during packaging.

Once we support packaging workspaces with dependencies, dependency packages need to be built before anything is verified. In addition to a little refactoring, this commit reorders the console messages so that package metadata (archive size, etc.) is reported before verification results.

As [suggested](ecba15ca99 (r1640182916)) on #13947  this, splits out the first commit (which has a lot of test output churn) as a separate PR.
2024-06-15 01:10:07 +00:00
Joe Neeman
c0287bec8d Change verification order during packaging.
Once we support packaging workspaces with dependencies, dependency
packages need to be built before anything is verified. In addition to a
little refactoring, this commit reorders the console messages so that
package metadata (archive size, etc.) is reported before verification
results.

Co-Authored-By: Tor Hovland <55164+torhovland@users.noreply.github.com>
2024-06-14 15:15:03 -05:00
Ed Page
7d9e9e12f0 test: Redact conditional compile-fail warning
I got a CI failure because the following line showed up:
```
[WARNING] build failed, waiting for other jobs to finish...
```
I'm assumin this is a race condition in the test for whether the
successful target completed before the error or not.

Before snapbox, we used a `contains` check which didn't have this
problem.  I'm replacing this with a `...` multi-line (0+) glob.
2024-06-13 15:28:06 -05:00
bors
0d7c7b82ef Auto merge of #14048 - Muscraft:move-to-snapbox, r=epage
Migrate a few test files to snapbox

This migrates the following files to `snapbox`
- `artifact_dep`
  - Has a few `does_not_contain`
- `artifact_dir`
- `bad_config`
- `bad_manifest_path`
  - Does not use `str!` for all tests
- `bench`

Note: This also adds auto-redactions for:
- `[HOST_TARGET]`
- `[ALT_TARGET]`
  - Only added if cross-compilation is allowed for the target
- `[AVG_ELAPSED]`
  - For `bench` output
- `[JITTER]`
  - For `bench` output

Part of #14039
2024-06-13 19:31:50 +00:00
Weihang Lo
4f002a5f46
Revert "Auto merge of #13630 - Kobzol:msvc-disable-release-strip, r=weihanglo"
This reverts commit fa619a9d16ca0d4dc58431808c08b7c1fee72bfa, reversing
changes made to 1f6857dcfbe84ce3e8edd26f861ee8bae0c5da2b.

See also <https://github.com/rust-lang/rust/pull/115120>
2024-06-13 12:21:13 -04:00
Lawrence Chou
7c28d80d37
test: migrate help to snapbox 2024-06-13 23:37:23 +08:00
bors
5f0294b15a Auto merge of #14051 - henry40408:issue-14039-shell-quoting, r=weihanglo
test: migrate features_are_quoted to snapbox

### What does this PR try to resolve?

Part of https://github.com/rust-lang/cargo/issues/14039.

Migrate `tests/testsuite/shell_quoting.rs` to snapbox.

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

N/A

### Additional information

N/A
2024-06-13 13:35:11 +00:00
Heng-Yi Wu
3a19de7638
refactor: apply suggestions from code review
Co-authored-by: Weihang Lo <weihanglo@users.noreply.github.com>
2024-06-13 20:09:35 +08:00
bors
00ea165442 Auto merge of #14054 - Muscraft:add-assert-redactions, r=epage
Add assert redactions

This was split out from #14048 so that the test changes in that PR do not block the redactions.

This adds auto-redactions for:
- A new `[HASH]` for `/<file>-<16 char hash>`
- `[HOST_TARGET]`
- `[ALT_TARGET]`
  - Only added if cross-compilation is allowed for the target
- `[AVG_ELAPSED]`
  - For `bench` output
- `[JITTER]`
  - For `bench` output

This also moves all common redactions to a function that `assert_e2e` and `assert_ui` call to reduce the amount of duplicate code and makes it so we only compile regex redactions once.
2024-06-12 19:57:23 +00:00
Scott Schafer
d0804f833c
test: Resolve bench deprecations 2024-06-12 13:31:55 -06:00
Scott Schafer
90e23a233b
test: Resolve bad_manifest_path deprecations 2024-06-12 13:31:55 -06:00
Scott Schafer
eff4b74da3
test: Resolve bad_config deprecations 2024-06-12 13:31:55 -06:00
Scott Schafer
6d6c9ac65b
test: Resolve artifact_dir deprecations 2024-06-12 13:31:55 -06:00
Scott Schafer
b08fb91f23
test: Resolve artifact_dep deprecations 2024-06-12 13:31:55 -06:00
Scott Schafer
6a7b15a61e
test: Auto-redact host target and alt target 2024-06-12 13:27:08 -06:00
bors
c13a39472a Auto merge of #14044 - heisen-li:build_script_env, r=epage
test: migrate build_script_env to snapbox

### What does this PR try to resolve?

part of https://github.com/rust-lang/cargo/issues/14039.
2024-06-12 16:44:49 +00:00
bors
30e5580d95 Auto merge of #14047 - epage:breaking, r=weihanglo
docs: Iterate on --breaking docs

This is a follow up to #13979 to try to clarify things in prep for users testing this.
2024-06-12 14:59:42 +00:00
Heng-Yi Wu
dd5905932c
test: migrate features_are_quoted to snapbox 2024-06-12 22:40:14 +08:00
heisen-li
2d10bd5a9f test: migrate build_script_env to snapbox 2024-06-12 11:12:18 +08:00
Ed Page
6bd7623ea7 docs: Iterate on --breaking docs
This is a follow up to #13979 to try to clarify things in prep for users
testing this.
2024-06-11 16:04:36 -05: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
a4384575f1
test: migrate binary_name to snapbox 2024-06-10 21:55:48 -04:00
Joe Neeman
ba9dd1ea2e Adds tests for source overlays. 2024-06-10 18:32:22 -05:00
bors
a9ee3e82b5 Auto merge of #14031 - epage:snap, r=weihanglo
tests: Migrate alt_registry to snapbox

### What does this PR try to resolve?

The overall goal is to enable the use of snapshot testing on as many cargo tests as possible to reduce the burden when having to touch a lot of tests.  Towards that aim, this PR
- Adds snapshot testing to `cargo_test_support::Execs`
- Migrates `alt_registry` tests over as an example (and to vet it)

I've taken the approach of deprecating all other output assertions on `Execs` with `#[allow(deprecated)]` in every test file.  This let's us easily identity what files haven't been migrated, what in a file needs migration, and helps prevent a file from regressing.  This should make it easier to do a gradual migration that (as many people as they want) can chip in.  It comes at the cost of losing visibility into deprecated items we use.  Hopefully we won't be in this intermediate state for too long.

To reduce manual touch ups of snapshots, I've added some regex redactions.  My main concern with the `FILE_SIZE` redaction was when we test for specific sizes.  That shouldn't be a problem because we don't use `Execs::with_stderr` to test those but we capture the output and have a custom asserter for it.

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

Yes, this puts us in an intermediate state which isn't ideal but much better than one person trying to do all of this in a single branch / PR.

The main risk is that we'll hit a snag with snapbox being able to support our needs.  We got away with a lot because everything was custom, down to the diffing algorithm.  This is why I at least started with `alt_registry` to get a feel for what problems we might have.  There will likely be some we uncover.  I'm fairly confident that we can resolve them in some way,

### Additional information

This is a continuation of the work done in #13980.
2024-06-10 17:11:50 +00:00
Ed Page
e589ed7f59 test: Resolve alt_registry deprecations 2024-06-10 10:20:52 -05:00
Ed Page
7f90d9acdb test: Resolve advanced_env deprecations 2024-06-10 10:20:52 -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
Weihang Lo
0ead10eebf
fix: proc-macro example from dep no longer affects feature resolution
Previously when checking if a dependency is a proc-macro,
the v2 feature resolve resolver v2 looks for `proc-macro = true`
for every target of the dependency.
However, it's impossible to depend on a non-lib target as a proc-macro.

This fix switches to only check if `proc-macro = true` for `[lib]`
target for a dependency.
2024-06-09 16:01:50 -04:00
Weihang Lo
2b0df94104
test: show proc macro example from dep affecting feature unificaiton 2024-06-09 16:01:50 -04: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
580dbc602b Auto merge of #13971 - heisen-li:ignore_release, r=weihanglo
fix: using `--release/debug` and `--profile` together becomes an error

### What does this PR try to resolve?

part of #13629

issue https://github.com/rust-lang/cargo/issues/13629#release-is-ignored-when-paired-with-profile
2024-06-09 13:51:16 +00:00
bors
ab85225804 Auto merge of #13921 - heisen-li:licence_readme_warning, r=weihanglo
fix(toml): Convert warnings that `licence` and `readme` files do not exist into errors

### What does this PR try to resolve?

In this PR:
- Changed the warning to a hard error and modified the associated test function;
- Removed what should have been a redundant test function:`publish::publish_with_missing_readme`;
- Since `cargo publish` is preceded by the execution of `cargo package`, the error message in the test `function bad_license_file` needs to be modified.

issue: https://github.com/rust-lang/cargo/issues/13629#license-file-and-readme-pointing-to-a-non-existent-file.

### Additional information

It seems that this is not enough, the current situation is that `cargo package` warns if `package.readme` is an empty string or the wrong file location, but if I cancel `package.readme`, no warning is generated.

I'm wondering if I should judge `package.readme&licence` when executing `cargo package` and return an error if it doesn't exist?

As this has not been done before, your advice is sought.
2024-06-09 13:02:50 +00:00
bors
3e89630c35 Auto merge of #14028 - epage:unused, r=ehuss
test(lints): Ensure unused optional dep fires for shadowed dep

This is a way to have an unused optional dependency before 2024 edition.
In prior editions, it is currently a hard error.
I'm tempted to switch that hard error to this lint in prior editions but at minimum, we need to make sure we don't make changes that cause this to revert back to a hard error on 2024+
2024-06-07 19:43:37 +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
Ed Page
a47d41eca4 test(lints): Ensure unused optional dep fires for shadowed dep
This is a way to have an unused optional dependency before 2024
edition.
In prior editions, it is currently a hard error.
I'm tempted to switch that hard error to this lint in prior editions
but at minimum, we need to make sure we don't make changes that cause
this to revert back to a hard error on 2024+
2024-06-07 10:20:54 -05:00
Tor Hovland
031b410181 feat: Implement cargo update --breaking. 2024-06-07 09:13:28 +02:00
Tor Hovland
c694ff0b44 test: For the upcoming cargo update --breaking feature. 2024-06-07 09:12:05 +02:00
valadaptive
0aac303956 Add tests for out-dir option deprecation
Ensure that the old options still work and provide the proper
deprecation warning.
2024-06-07 03:01:40 -04:00
valadaptive
4b309bc47a Rename out-dir to artifact-dir
Per discussion in https://github.com/rust-lang/cargo/issues/6790. The
--out-dir CLI option and out-dir config option are often confused with
the OUT_DIR environment variable, when the two serve very different
purposes (the former tells Cargo where to copy build artifacts to,
whereas the OUT_DIR environment variable is set *by* Cargo to tell
build scripts where to place their generated intermediate artifacts).
Renaming the option to something less confusing is a prerequisite to
stabilizing it.
2024-06-07 03:01:26 -04:00
heisen-li
5d8022c9e8 Use clap's conflict support and keep some command tests 2024-06-05 15:36:06 +08:00