93 Commits

Author SHA1 Message Date
Ed Page
ded3f004a4 fix(resolve): Generalize term describing updates
`latest` was easy.  `latest compatible` was ok.  But how do I talk about
"latest compatible with your MSRV".  That gets messy.
2024-08-30 09:26:56 -05:00
Ed Page
353cd87cea fix(resolve): With latest message, differentiate actionable updates
Instead of always listing the absolute latest version as a warning
color, we now differentiate
- compatible updates are always actionable
- incompatible, direct deps are always actionable

These get reported and made yellow while non-actionable messages are
unstyled.

This is not intended as *the* solution for #13908 though it makes
improvements in that direction.
This is prep work for improved MSRV reporting where we will
differentiate this further by only considering MSRV-compatible updates as actionable
(or rustc-compatible when not using MSRV-aware reslver).

I just used a broad stroke to say "compatible" in the message means "semver
compatible" and use `^`
- We could focus on "compatible with dependent version reqs" which is
  what will be most actionable but seeing if we can get away without
  having to track all in-coming version reqs.
- We could be more nuanced in language but the more verbose we are, the
  more we take away from higher priority messages
2024-08-27 13:40:03 -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
Ed Page
5b9799c6f4 refactor: Migrate from extern crate to test-support prelude
We now include the prelude in so many places, this simplifies how we can
present how `cargo-test-support` works.

Yes, this included some `use` clean ups but its already painful enough
walking through every test file, I didn't want to do it twice.
2024-07-12 15:57:00 -05:00
eth3lbert
7aeed67bfb
test: migrate workspaces to snapbox 2024-06-22 06:26:56 +08: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
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
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
Cerber-Ursi
51c8e0eb51 slightly reworded message to show the main parts first
Co-authored-by: Ed Page <eopage@gmail.com>
2024-02-23 02:27:01 +07:00
Cerber Ursi
07eb70811f add workspace root path to error messages on members collecting 2024-02-22 22:56:26 +07:00
Ed Page
e7e8d8748a fix(compiler): Clarify we're showing a profile name 2024-02-08 14:01:39 -06:00
Lin Yihai
9be95dfb1c feat: Add hint for adding members to workspace 2024-02-06 13:30:56 +08:00
Ed Page
7513b412fe fix(new): Print a note, rather than a comment, for more information
Fixes #12210
2024-01-29 15:38:04 -06:00
Ed Page
db54c040ae fix(new): Print a 'Creating', rather than 'Created' status
This has bothered me about `cargo new` and `cargo init` for a while that
the output is read backwards, for example:
```diff
--- i/tests/testsuite/cargo_init/path_contains_separator/stderr.log
+++ w/tests/testsuite/cargo_init/path_contains_separator/stderr.log
@@ -1,3 +1,3 @@
+    Creating binary (application) package
 warning: the path `[ROOT]/case/test:ing/.` contains invalid PATH characters (usually `:`, `;`, or `"`)
 It is recommended to use a different name to avoid problems.
-     Created binary (application) package
```
2024-01-29 15:29:10 -06:00
Scott Schafer
0d62ae2fc3
feat: Add rustc style errors for manifest parsing 2023-12-15 13:30:10 -07:00
Ed Page
62eab55ed2 refactor(toml): Make it more obvious to update package-dependent fields
Inspired by my having forgotten to add `[lints]` to the if sequence.
Previously, we added a comment to suggest this but the further the code
is, the harder it is to track.

I considered a custom `Deserialize` impl, possibly through a new type,
that would error.
This would be the more "pure" solution.
Unfortunately, this would also have worse errors because the errors
would be reported to the `Deserializer` at the document-level, rather
than directly on the individual fields.
Well, we don't do on individual fields now but it is something we will
soon be exploring.
2024-01-08 15:34:38 -06:00
Ed Page
66ce16c72b fix(toml)!: Disallow [lints] in virtual workspaces
This was missed with the initial `[lints]` implementation.

While this is a breaking change, this is aligned with ones we've done in
the past.  A lot of times, we warn first.  My hope is that isn't needed
this time because
- It only exists virtual workspaces so they aren't published
- It is a nop to have this which is likely to be caught
- This is so new that the number of people using it, and likely running
  into this case, is quite low.
2023-12-11 14:10:01 -06:00
David Calavera
1a8bfdf0cf Update workspace manifest with new members.
When a user runs `cargo new` or `cargo init` within a workspace, Cargo will automatically add the new package to the members list in the workspace if necessary. The heuristic to add the new package is as follows:

- If there is no `members` list in the workspace yet, a new `members` list is created.
- If there is an `exclude` statement, Cargo checks if the new package should be excluded. If it doesn't match the `exclude` list, the package is added to the `members` list.
- If there is a glob expression in the `members` list that matches the new package, the package is not added to the `members` list.
- If the existent `members` list is sorted, Cargo tries to preserve the ordering when it adds the new package.

This change doesn't try to format the resulting `members` list in any way, leaving the formatting decissions to the user.

Signed-off-by: David Calavera <david.calavera@gmail.com>
2023-10-28 07:42:23 -07:00
Ed Page
5cac7aa8c6 fix(toml): Remove redundant error messages 2023-08-24 16:19:48 -05:00
Scott Schafer
45c9c8e905 chore: update workspaces tests to use check 2023-02-20 12:22:29 -06:00
Ed Page
6007f05a85 chore: Update to toml v0.6, toml_edit v0.18
`toml` replaces `toml_edit::easy`, using `toml_edit` as its parser.
2023-01-19 15:26:28 -06:00
Scott Schafer
ab18bd40d5 refactor(testsuite): Replace [project] with [package] 2022-09-26 09:51:16 -06:00
bors
6fc517b1c3 Auto merge of #10784 - tedinski:fix-10783, r=epage
Allow '.' in workspace.default-members in non-virtual workspaces.
2022-07-16 02:32:05 +00:00
Scott Schafer
6070b0aab4 Add a test to check for regressions in selecting the correct workspace when there are nested workspaces 2022-07-13 21:10:22 -05:00
Ted Kaminski
380be40922 Allow '.' in workspace.default-members in non-virtual workspaces. 2022-07-13 21:19:31 +00:00
Scott Schafer
cab6d30c1d fix typos found by the typos-cli crate 2022-05-10 16:47:28 -05:00
Ed Page
320c279f43 Port cargo from toml-rs to toml_edit
Benefits:
- A TOML 1.0 compliant parser
- Unblock future work
  - Have `cargo init` add the current crate to the workspace, rather
    than error
  - #5586: Upstream `cargo-add`
2022-01-13 09:27:27 -06:00
Weihang Lo
9c0d865389 fix: more error context for missing dep of workspace member 2021-04-17 14:24:29 +08:00
Weihang Lo
832fff8dd1
fix: more context when failed to load workspace member 2021-04-17 13:56:39 +08:00
Jade
de45c6f97a Delete uses of the USER env var from tests 2021-03-22 13:39:18 -07:00
Eric Huss
fdb8ea1e03 Add some extra help to cargo new and invalid package names. 2021-01-24 13:21:25 -08:00
Eduardo Broto
fb02ade261 Rework tests to avoid using -vv
Environment variables are represented differently in differents OSes in
the output.

Add tests checking if the variable is set instead.
2020-10-15 00:44:04 +02:00
Eduardo Broto
c12aed2fe4 Add tests for CARGO_PRIMARY_PACKAGE (workspaces) 2020-10-14 23:35:00 +02:00
Eric Huss
6f8c7d5a87 Normalize raw string indentation. 2020-09-26 17:59:58 -07:00
Thom Chiovoloni
b377c4bb17 Check for quux binary in excluded_default_members_crate_glob test (review feedback) 2020-07-20 09:38:20 -07:00
Thom Chiovoloni
b70a5962c3 Apply workspace.exclude to workspace.default-members. 2020-07-14 13:58:42 -07:00
Julian Wollersberger
d6a1428609 Rephrased error message for disallowed sections in virtual workspace 2020-05-14 10:26:20 +02:00
Eric Huss
4ae79d2ffd Use fs helpers instead of File functions. 2020-04-17 07:56:16 -07:00
Eric Huss
b64d0f3645 Don't use debug display for error object. 2020-04-15 17:29:19 -07:00
Eric Huss
1eca786d7f Add path to the failure to load a dependency. 2020-02-27 08:17:18 -08:00
Eric Huss
a07fec1b7b Provide extra context on a query failure. 2020-02-25 10:17:11 -08:00
Alex Crichton
3a18c89a55 Migrate from the failure crate to anyhow
The `anyhow` crate interoperates with the `std::error::Error` trait
rather than a custom `Fail` trait, and this is the general trend of
error handling in Rust as well.

Note that this is mostly mechanical (sed) and intended to get the test
suite passing. As usual there's still more idiomatic cleanup that can
happen, but that's left to later commits.
2020-01-07 16:50:09 -08:00
Eric Huss
83571aee56 Minor testsuite organization. 2019-11-24 18:42:45 -08:00
Alex Crichton
d7d8ca1e12 Consolidate build key configuration
Add a typed structure which lists all `build` key configuration
throughout Cargo.
2019-10-07 17:12:03 -07:00
Alex Crichton
ebd10526f3 Run rustfmt 2019-09-16 12:00:12 -07:00
Alex Crichton
9115b2c326 Extract support directory to its own crate
Extract out all our test support code to its own standalone crate so it
can be shared between multiple test suites if necessary.
2019-09-16 11:47:09 -07:00
k-nasa
7176df01d6 Change --all to --workspace 2019-09-03 17:14:34 -07:00
Wim Looman
53e84c571d Only apply default-members when building root manifest 2019-08-19 14:47:02 -07:00
bors
85a52ce20e Auto merge of #7242 - ehuss:vendor-ignore-dot, r=alexcrichton
`cargo vendor`: Don't delete hidden top-level files.

`cargo vendor` (without `--no-delete`) will delete all files in the `vendor/` directory when it starts. This changes it so that it will skip any entries starting with a dot. This allows one to track the vendor directory with a source control system like git.

Closes #7109

(Note: two commits, one is a test change.)
2019-08-13 22:47:50 +00:00