Commit graph

6240 commits

Author SHA1 Message Date
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
Weihang Lo c63286fdc0
test: use canonical bin path to surpress warnings 2024-06-14 14:52:51 -04:00
Weihang Lo f188e4bc9d
test: migrate build to snapbox 2024-06-14 14:52:50 -04: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 fa619a9d16, reversing
changes made to 1f6857dcfb.

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
Ed Page 21c0928638 fix(fix): Ensure optional dep is available for dep-features 2024-06-05 16:00:39 -05:00
Ed Page 078383bd0f fix(fix): Dont remove features when making implicit features explicit 2024-06-05 15:27:00 -05:00
Ed Page fbe1cd1ab7 test(fix): Show the dep-feature behavior 2024-06-05 15:09:29 -05:00
Ed Page fa14a13618 test(fix): Simplify existing-table test
We already have a test that covers each dep type; we don't need to cover
that here.
2024-06-05 15:08:22 -05:00
Ed Page 1b51d170fe tests(fix): Clarify role of dependencies 2024-06-05 12:03:24 -05:00
Ed Page c009b3208d tests(fix): Snapshot fixes 2024-06-05 11:59:50 -05:00
heisen-li 5d8022c9e8 Use clap's conflict support and keep some command tests 2024-06-05 15:36:06 +08:00
bors 34a6a87d8a Auto merge of #13886 - jneem:vendoring-warning, r=arlosi
Silence the warning about forgetting the vendoring
2024-06-04 15:31:01 +00:00
heisen-li 193319c66c fix(toml): Convert warnings that license and readme files do not exist into errors 2024-06-04 12:32:18 +08:00
Ed Page 150461cdec fix(vendor): Ensure sort happens for vendor 2024-06-03 10:34:41 -05:00
Ed Page d5938ccfe2 test(vendor): Ensure order is consistent 2024-06-03 10:34:00 -05:00
Ed Page 81b1bb1580 test(package): Ensure order is consistent 2024-06-03 09:10:05 -05:00
Ed Page c00c5cd1cf fix(add): Avoid escaping double-quotes by using string literals
Fixes #14002
2024-06-03 11:22:00 -05:00
Ed Page 5c3b534101 test(add): Show quoting behavior for --target 2024-06-03 10:39:53 -05:00
bors 4219b66f63 Auto merge of #13687 - linyihai:git-features-env, r=weihanglo
Allows the default git/gitoxide configuration to be obtained from the ENV and config

### What does this PR try to resolve?
The default git/gitoxide feautures config can be obtained througt `-Zgit` and `-Zgitoxide`.
However, it cannot be obtained from environment variables or configurations.
It's not very ergonomic.

### How should we test and review this PR?
The previous commit explained the staus quo, the next commit addressed the problem.

### Additional information
Inspired by https://github.com/rust-lang/cargo/issues/11813#issuecomment-1817517629
See also https://github.com/rust-lang/cargo/issues/13285#issuecomment-2016875459

### Change of usage

1. Mirror Zgit/Zgitoxide when they parsed as string

Specify the feature you like
```
CARGO_UNSABLE_GIT='shallow-deps' cargo fetch
cargo fetch --config "unstable.git='shallow-deps'"
cargo fetch -Zgit="shallow-deps"
```

2. Specify partial fields when parsed as table

```
CARGO_UNSTABLE_GITOXIDE_FETCH=true cargo fetch

```

The rest fields will use Rust default value. That said, checkout and internal_use_git2 will be false.

Besides, you can pass true to the whole feature to specify the pre-defined features.

```
CARGO_UNSTABLE_GITOXIDE=true cargo fetch

```
2024-06-03 13:27:22 +00:00
Lin Yihai ee87c915d3 feat: Support parse string as git/gitoxide features from ENV and Config
- pass true to enable all pre-definded git/gitoxide features
- support parse git/gitoxide as table in Config, if the field is tagged with #[serde(default)], then it can be skipped
2024-06-03 10:42:43 +08: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
Lin Yihai b176adbfe1 test: Added test cases about getting git/gitxide from Env and unstable table 2024-06-02 13:17:13 +08:00
bors 721cd55bf6 Auto merge of #14000 - linyihai:fix-env-prefix, r=weihanglo
Fix: Skip deserialization of unrelated fields with overlapping name

### What does this PR try to resolve?

Split from https://github.com/rust-lang/cargo/pull/13687#discussion_r1622694446

This fixes the overlap of environment variable names:

> For example, when env_key is UNSTABLE_GITOXIDE_FETCH
and field_key is UNSTABLE_GIT, the field shouldn't be
added because `unstable.gitoxide.fetch` doesn't
belong to `unstable.git` struct.

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

Updates of test cases `struct_with_overlapping_inner_struct_and_defaults` can be used to compare changes before and after changes

### Additional information
r? weihanglo and very appreciate your more optimized code
2024-06-01 13:24:23 +00:00
Lin Yihai d347704b1a Fix: Skip deserialization of unrelated fields with overlapping name 2024-06-01 13:25:49 +08:00
Ed Page 4ce2b61f2a Revert "fix(context): Configure Shell before emitting messages"
This reverts commit f525e1f383.

This removes color control from warnings for unstable features.
For some reason this removed color support from `cargo -Zhelp` in the
tests but I can't reproduce it locally.

The most important thing was getting the config fix in.
There are two follow ups
- Can we have the config working *and* color?
- Why did this fail for this field and not the others we already had
  tests for?

I ran out my immediate time box for looking into these.

Fixes #13991
2024-05-31 14:56:18 -05:00
Ed Page c0a79574ef test(config): Show current git-fetch-with-cli behavior 2024-05-31 14:56:12 -05:00
bors d04355a8c4 Auto merge of #13987 - epage:new, r=ehuss
fix(new): Dont say were adding to a workspace when a regular package is in root

Fixes #13985
2024-05-31 16:39:32 +00:00
heisen-li 09a8ece8ee fix:Using --release/debug and --profile together becomes an error 2024-05-31 15:02:09 +08:00
Weihang Lo 0978162ebe
fix: adjust custom err from cert-check due to libgit2 1.8 change
libgit2 disallows overriding errors from certificate check since v1.8.0,
so we store the error additionally and unwrap it later.

See 9a9f220119
2024-05-31 00:39:30 -04:00
Ed Page 26c1678ad2 fix(new): Dont say were adding to a workspace when a regular package is in root
Fixes #13985
2024-05-30 13:27:12 -05: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
bors 2c8d176e60 Auto merge of #13974 - weihanglo:precise-yank, r=arlosi
feat: stabilize `cargo update --precise <yanked>`

### What does this PR try to resolve?

Stabilize `cargo update --precise <yanked>`.

The cargo team has discussed the stabilization in the meeting today.
The interface of this is quite small and not as controversial as `--precise <pre-release>`,
since there is no version requirement operators involved.
We'd like to move forward and stabilize this part.

Note that `--precise <yanked>` allows using yanked version only for the specified package,
We leave the cascading allowing yanked versions (e.g. <https://github.com/rust-lang/cargo/issues/4225#issuecomment-1930353693>) as a future extension.

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

Check if any adjustment needed for warnings and CLI help text.

### Additional information

cc <https://github.com/rust-lang/cargo/issues/4225>.
2024-05-29 18:43:12 +00:00
bors 431db31d0d Auto merge of #13958 - Urgau:check-cfg-config-fingerprint, r=epage
Include `lints.rust.unexpected_cfgs.check-cfg` in the fingerprint

### What does this PR try to resolve?

When changing the `--check-cfg` args in the `lints.rust.unexpected_cfgs.check-cfg` lint config, the build should be restarted as the arguments we pass to the compiler change, and they can change the diagnostics output by generating new or removing some `unexpected_cfgs` warning(s).

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

Look at the before and after test (separate commit).

### Additional information

Similar to https://github.com/rust-lang/cargo/pull/13012 which did that for the declared features.
Contrary to that PR, I didn't add a new `DirtyReason` variant, since even the `[lints]` table didn't get one.

r? `@epage`
2024-05-28 18:17:31 +00:00
Urgau dfb69e6076 Include lints.rust.unexpected_cfgs.check-cfg into the fingerprint 2024-05-28 20:02:47 +02:00
Weihang Lo a076f7921b
feat: stabilize cargo update --precise <yanked> 2024-05-28 13:13:56 -04:00
bors 11d0002ea0 Auto merge of #13963 - epage:snapbox, r=weihanglo
chore: Update to snapbox 0.6

### What does this PR try to resolve?

This unblocks regex redactions which will help with `Finished in 3.45s` messages as well as maybe switching away from `compare.rs` generally.

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

### Additional information
2024-05-28 03:48:38 +00: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 4a6f25c112 refactor: Resolve snapbox deprecations 2024-05-27 10:28:13 -05:00
surechen 1c8da38a5c Fix test error in https://github.com/rust-lang/rust/pull/125533
As lint dropping_copy_types will give suggsetion in this
situation.(Changed in https://github.com/rust-lang/rust/pull/125433)
2024-05-25 23:49:13 +08:00
Urgau 3ca2120180 Add test for check-cfg config fingerprint not changing 2024-05-24 20:46:24 +02:00
bors a8d72c675e Auto merge of #13956 - linyihai:missing-fields, r=weihanglo
Improve error description when deserializing partial field struct

### What does this PR try to resolve?

Fixes #13688

### How should we test and review this PR?
one commit add test, one commit fixed and update the test.

### Additional information
2024-05-24 03:34:17 +00:00
Lin Yihai e05d930e16 fix: Add more context when 'missing feild' 2024-05-24 11:29:46 +08:00
Lin Yihai 48742e009c test: Add 'missing field' test 2024-05-23 15:27:52 +08: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
Urgau 8fdac923e8 Make git::use_the_cli test truly locale independent 2024-05-19 19:39:34 +02:00
bors 0f685f6198 Auto merge of #13930 - ehuss:squelch-git-output, r=weihanglo
Fix warning output in build_with_symlink_to_path_dependency_with_build_script_in_git

The test `build_with_symlink_to_path_dependency_with_build_script_in_git` was emitting a large warning block (in my case, about init.defaultBranch) because it was running `git` without filtering its output. It's not clear to me why this test was shelling out to `git` instead of using the built-in test support functions. From what I can tell, this should be exactly equivalent, and silences the warning output.
2024-05-19 01:23:50 +00:00
bors 198ba31be3 Auto merge of #13572 - linyihai:multi-dep-same-name, r=ehuss
Fix:  Make path dependencies with the same name stays locked

### What does this PR try to resolve?
Fixes: https://github.com/rust-lang/cargo/issues/13405

This is a workround based on https://github.com/rust-lang/cargo/issues/13405#issuecomment-1930496807

### How should we test and review this PR?
first commit will pass, second commit fixed it and update test.

### Additional information
2024-05-18 22:12:27 +00:00
Eric Huss 473e770cdd Temporarily fix standard_lib tests on linux. 2024-05-18 14:00:06 -07:00
Eric Huss 2e9dcdbdf5 Fix warning output in build_with_symlink_to_path_dependency_with_build_script_in_git 2024-05-18 13:19:53 -07:00
Lin Yihai ab927171ce fix: Make path dependencies with the same name stays locked 2024-05-18 12:45:11 -07:00
Lin Yihai 5c1b6313fa test: Add a test about patched re-export 2024-05-18 12:43:48 -07:00