114 Commits

Author SHA1 Message Date
Ed Page
81411ec545 feat: Stabilize Edition 2024 2024-11-25 09:27:09 -06:00
Ed Page
55350fc670 test: Switch from 'exec_with_output' to 'run'
This is a follow up to #14846 which changed `run` to return the
`RawOutput`.

Reasons I didn't "update" some code to the new `run` return value
- We were actually using `ProcessBuilder::exec_with_output` and I didn't
  want to disentangle what it would take to switch to `Execs`
- We did processing on the `Result` and I didn't want to check how that
  could be updated
2024-11-21 13:48:27 -06:00
Ed Page
af3cfd5abe fix(test): Un-deprecate contains assertions 2024-11-07 15:55:35 -06:00
Ed Page
a6cf1be655 test: Switch from allow to expect deprecated
This caught a couple of lingering items.
2024-09-23 20:44:06 -05:00
Ed Page
d2ec764995 fix(resolve): Dont show locking workspace members
This is for `cargo generate-lockfile` and when syncing the lockfile with
the manifest.
We still show it for `cargo update` because of `cargo update
--workspace`.

We hacked around this previously by filtering out the `num_pkgs==1` case
for single packages but this didn't help with workspaces.
2024-08-22 16:57:06 -05:00
Esteban Küber
830db6f061 Change tests to support rustc wording changes
Between rust-lang/rust#126810 and rust-lang/rust#126810 the output of rustc for resolution errors is going to change in such a way that some existing cargo tests will fail. Change them to support both the current and future output, so that those PRs can land in `rustc`.
2024-08-01 18:10:56 +00:00
Ed Page
3a615ca9c8 feat(test): Add CargoPathExt to prelude 2024-07-18 15:22:29 -05:00
eth3lbert
68185614e2
fix(test): Restore does_not_contain for check
This is partial revert of #14185
(27062476a86e864479ef6bde1828c624b643de4b)

Although the changes made in that commit are valid, for the same reason
mentioned in the comment https://github.com/rust-lang/cargo/pull/14181#discussion_r1667089718,
"People are unlikely to see these comments when updating snapshots".
Therefore, it would be better to revert these parts.
2024-07-06 06:28:41 +08:00
eth3lbert
27062476a8
test: migrate check to snapbox 2024-07-05 06:52:04 +08:00
Esteban Küber
af3f95d3a3 Change tests to support rustc wording changes
Between https://github.com/rust-lang/rust/pull/126810 and https://github.com/rust-lang/rust/pull/126810
the output of `rustc` for resolution errors is going to change in such a
way that some existing cargo tests will fail. Change them to support
both the current and future output, so that those PRs can land in
`rustc`.
2024-06-25 01:16:48 +00: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
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
heisen-li
5d8022c9e8 Use clap's conflict support and keep some command tests 2024-06-05 15:36:06 +08:00
heisen-li
09a8ece8ee fix:Using --release/debug and --profile together becomes an error 2024-05-31 15:02:09 +08: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
2f4d3df54d fix(toml): Error on use of [project] on 2024 Edition 2024-04-15 13:32:17 -05:00
Ed Page
c9325c9bd9 refactor(toml): Move project tests next to each other 2024-04-15 13:32:17 -05:00
Ed Page
77f96f5c61 fix(toml): Simplify [project] warning 2024-04-15 13:32:17 -05:00
Ed Page
1876326b6b feat(resolve): Tell the user the style of resovle done
This is to help with #9930

Example changes:
```diff
-[LOCKING] 4 packages
+[LOCKING] 4 packages to latest version
-[LOCKING] 2 packages
+[LOCKING] 2 packages to latest Rust 1.60.0 compatible versions
-[LOCKING] 2 packages
+[LOCKING] 2 packages to earliest versions
```

Benefits
- The package count is of "added" packages and this makes that more
  logically clear
- This gives users transparency into what is happening, especially with
  - what rust-version is use
  - the transition to this feature in the new edition
  - whether the planned config was applied or not (as I don't want it to
    require an MSRV bump)
- Will make it easier in tests to show what changed
- Provides more motiviation to show this message in `cargo update` and
  `cargo install` (that will be explored in a follow up PR)

This does come at the cost of more verbose output but hopefully not too
verbose.  This is why I left off other factors, like avoid-dev-deps.
2024-04-13 20:39:59 -05:00
Jacob Pratt
def06ee243
Remove unnecessary test 2024-03-24 20:02:10 -04:00
Ed Page
4ab2797f36 feat(lock): Print lockfile changes on all commands 2024-03-12 13:39:56 -05:00
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
Ed Page
e7e8d8748a fix(compiler): Clarify we're showing a profile name 2024-02-08 14:01:39 -06:00
Weihang Lo
637b5d1eae
fix(--package): accept ? if it's a valid pkgid spec
Previously if a value from `--package` flag contains `?`, Cargo
considered it as a glob pattern. However, staring from 12933 the
Package Id Spec has been extended to accept `?` for git sources.
This PR adjust accordingly to accept `?` from `--package` flag
when it is a valid Package Id Spec.
2024-01-18 00:45:35 -05:00
Weihang Lo
a37d122949
test: show pkgid spec + query doesnt work with --package 2024-01-18 00:37:52 -05:00
Adrian
b7b5a093a1
Fix cargo errors counter 2023-11-29 18:47:14 +02:00
Eric Huss
2eac6f5c0c Fix clippy-wrapper test race condition. 2023-11-18 17:23:29 -08:00
Ed Page
bfb5d1db0e fix(toml): Default package.publish based on presence of package.version
Before the default was hardcoded to `true`.  The problem was that means
that to remove the `package.version` boilerplate, you had to add
`package.publish = false` boilerplate.

To make the errors easier to understand in this situation, I err on the
side of encouraging people to put `publish = true` in their manifests.

By making this change, we also unblock "cargo script" /
`Cargo.toml` unifying the handling of `package.publish`.
2023-10-11 13:17:03 -05:00
Ed Page
1923b5b862 feat(toml): Allow versionless packages
This defaults the version to `0.0.0` for most of cargo.

It is an error to lack a version and have a package publishable.
That means you have to add `publish = false`.
2023-10-11 13:13:44 -05:00
Ed Page
5c9a126911 test(toml): Verify existing version-less behavior 2023-10-06 12:21:07 -05:00
David Tolnay
ece5269e97
Stabilize --keep-going 2023-08-26 13:14:39 -07:00
hi-rustin
08169fd015 Add rustc_shim_for_cargo_fix and wrapped_clippy_driver to reuse code
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-04-14 11:23:41 +08:00
Adrián Ortiz
db457d950f Fixing issue https://github.com/rust-lang/cargo/issues/10834:
- Adding display of which target failed to compile
- Consistent messages for warnings/errors.
- Fixing assertions on related tests.
2023-03-07 06:45:26 +01:00
Scott Schafer
a32af2fff1 fix(toml): Provide a way to show unused manifest keys for workspace inheritance 2023-03-01 13:43:57 -06:00
Scott Schafer
6131222ba2 feat: stabilize auto fix note 2023-01-10 13:52:29 -06:00
Scott Schafer
33c32088fa fix: Make auto-fix note work with clippy 2022-12-15 10:54:35 -06:00
Scott Schafer
8ff8eaa496 add a note that some warnings can be auto-fixed 2022-10-27 19:07:59 -05:00
Scott Schafer
8625d7274a fix(cargo): Add a warning on [project] table being used in a manifest 2022-09-26 10:32:48 -06:00
Scott Schafer
cabee4f511 fix(cargo): Add a warning on package and project in the same Cargo.toml 2022-09-26 10:32:07 -06:00
Scott Schafer
ab18bd40d5 refactor(testsuite): Replace [project] with [package] 2022-09-26 09:51:16 -06:00
Eric Huss
8a487abedd Make the empty rustc-wrapper test more explicit. 2022-07-24 13:10:35 -07:00
Scott Schafer
c239e407e7 add a reason to masquerade_as_nightly_cargo so it is searchable 2022-07-15 21:32:23 -05:00
Loïc BRANSTETT
2d0ca84b0e Move check cfg tests to their own module 2022-05-06 22:42:28 +02:00
Loïc BRANSTETT
6a9f094c8c Convert the testsuite to use the new -Zcheck-cfg flag and syntax 2022-05-06 22:40:08 +02:00
bors
403c6bd257 Auto merge of #10486 - Urgau:check-cfg-well-known, r=weihanglo
Add support for rustc --check-cfg well known names and values

This pull-request add support for `rustc` `--check-cfg` well known names and values.

### What does this PR try to resolve?

This pull-request add support for `rustc` `--check-cfg` well known names and values:

- `-Z check-cfg-well-known-names`: `--check-cfg names()` well known names
- `-Z check-cfg-well-known-values`: `--check-cfg values()` well known values

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

#### Testing

`cargo check -Z check-cfg-well-known-names` and
`cargo check -Z check-cfg-well-known-values`

#### Review

This PR contains one commit that split `features_args` into `check_cfg_args`, add the well known support in it, adds call to that new function and add documentation and test for those new flags.

### Additional information

This was implemented as two new additional flags because it's most likely that these flags will not be stabilize at the same time and also because some of these flags may become the default.

RFC: https://github.com/rust-lang/rfcs/pull/3013
`-Z check-cfg-features`: https://github.com/rust-lang/cargo/pull/10408
`cargo doc` support: https://github.com/rust-lang/cargo/pull/10428
2022-04-12 14:36:40 +00:00
David Tolnay
4e45f58852
Unstable --keep-going flag 2022-03-21 18:36:40 -07:00
Loïc BRANSTETT
02cd9442c7 Add support for rustc --check-cfg well known names and values 2022-03-18 22:14:39 +01:00
Loïc BRANSTETT
a864c81549 Disable -Z check-cfg-features tests on windows due to weird normalization issues
See https://github.com/rust-lang/cargo/runs/5290789288?check_suite_focus=true
Where the expected is: --check-cfg 'values(feature, "f_a", "f_b")'
But we got: --check-cfg "values(feature, /"f_a/", /"f_b/")"
2022-02-22 18:33:03 +01:00
Loïc BRANSTETT
03fbb2eda8 Add -Z check-cfg-features to enable compile-time checking of features 2022-02-22 16:47:52 +01:00