45 Commits

Author SHA1 Message Date
Ed Page
5b84fc99c5 feat(test): Snapshot .crate validation 2024-10-17 06:26:47 +08: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
Joe Neeman
a2f0a9e7d6 Adds support for packaging workspaces.
Takes local dependencies into account when packaging a workspace. Builds
a temporary package registry to provide local dependencies, and overlays
it on the upstream registry.

This adds `--registry` and `--index` flags to `cargo package`. They act
much like the same arguments to `cargo publish`, except that of course
we are not actually publishing to the specified registry. Instead, these
arguments affect lock-file generation for intra-workspace dependencies:
when simultaneously packaging a crate and one of its dependencies, the
lock-file will be generated under the assumption that the dependency
will be published to the specified registry.

Co-Authored-By: Tor Hovland <55164+torhovland@users.noreply.github.com>
2024-07-24 16:36:30 +07:00
Weihang Lo
fb56fffbb1
test: omit target-dir name (again)
See commit 47ddb3a57d26257f5ac9fb7ee4643ccef83e5e25
2024-06-28 22:42:25 -04:00
eth3lbert
a2b706b73b
test: migrate publish_lockfile to snapbox 2024-06-27 13:55:55 +08:00
Weihang Lo
47ddb3a57d
test: omit target-dir name
This was found during submodule update in rust-lang/rust repo.

```
error: Expected lines did not match (ignoring order):
0   6        Packaging foo v0.0.1 ([..])
1   0        Archiving Cargo.lock
2   0        Archiving Cargo.toml
3   1        Archiving Cargo.toml.orig
4   0        Archiving src/main.rs
5   0         Updating `dummy-registry` index
6   2     note: package `multi v0.1.0` added to the packaged Cargo.lock file, was originally sourced from `[..]`
7   2     note: package `patched v1.0.0` added to the packaged Cargo.lock file, was originally sourced from `[..]`
8   0         Packaged 4 files, 2.1KiB (1.1KiB compressed)
9        -warning: no (git) Cargo.toml found at `target/tmp/[..]/foo/Cargo.toml` in workdir `[..]`
    9    +warning: no (git) Cargo.toml found at `build/aarch64-apple-darwin/stage2-tools/aarch64-apple-darwin/tmp/cit/t0/foo/Cargo.toml` in workdir `[..]`
```
2024-06-25 12:20:12 -04:00
Tor Hovland
2a1299a878 fix: Include vcs_info even if workspace is dirty. 2024-06-24 13:02:25 +02: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
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
1d0c6ebd8f feat(install): Including Locking message
As we switch to MSRV-aware resolver, this will help users work out why
MSRV-aware resolving isn't helping them.

This will also make it more obvious if we breaking things when
developing the MSRV-aware resolver.
2024-04-16 13:35:25 -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
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
Eric Huss
0afd943dad Fix some test output validation. 2023-11-15 15:10:18 -08:00
Kyle Matsuda
8c4f27fd5b make test clearer 2022-12-19 10:50:55 -07:00
Kyle Matsuda
4d86b26a68 fix test 2022-12-12 15:47:31 -07:00
Kyle Matsuda
4cda74a1a3 add test with current behavior 2022-12-12 11:07:43 -07:00
Anton Lazarev
9333b8f5ba
update package, publish, and publish_lockfile tests 2022-10-28 17:13:25 -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
Scott Schafer
cab6d30c1d fix typos found by the typos-cli crate 2022-05-10 16:47:28 -05:00
Weihang Lo
8c75e2ffa0
Update tests to use registry names 2021-07-22 00:50:30 +08:00
Eric Huss
2c99f654c9 Update nightly failure notification. 2021-07-05 16:08:36 -07:00
Eric Huss
7bbef3defe Rework cargo-features a little.
* Add `removed` support.
* Include the version where it is stabilized.
* Include a links to the documentation in the error/warning messages.
2021-01-21 12:16:35 -08:00
Eric Huss
ff349f0205 Remove publish-lockfile key from manifest.
The feature was stabilized without the key in #7026 about 1.5 years ago.
(Will follow up with an error message in a subsequent commit.)
2021-01-20 19:31:57 -08:00
Eric Huss
6f8c7d5a87 Normalize raw string indentation. 2020-09-26 17:59:58 -07:00
Eric Huss
156c65123f Allow cargo package --list even for things that don't package. 2020-04-28 10:49:21 -07:00
Eric Huss
1232ad3cde Don't require Cargo.toml to be in root of a git repo for path source walking. 2020-04-22 11:29:59 -07:00
Matthias Krüger
1d912002e9 fix most remaining clippy findings (mostly redundant imports) 2020-02-21 12:15:16 +01:00
Eric Huss
90887707ed Copy license-file into package if outside of root. 2020-02-20 13:27:25 -08:00
Eric Huss
3cedb8e33c Fix .gitignore of Cargo.lock in a subdirectory. 2020-01-08 10:40:17 -08:00
Eric Huss
83571aee56 Minor testsuite organization. 2019-11-24 18:42:45 -08:00
Eric Huss
36f01e6492 Allow gitignore of Cargo.lock with explicit include. 2019-09-26 15:02:01 -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
Eric Huss
34307c6122 Stabilize publish-lockfile. 2019-06-10 13:19:18 -07:00
Jethro Beekman
0e0d968825 Update #[test] attribute on all tests in the testsuite
sed -i 's/^#\[test\]/#[cargo_test]/' $(rg -l '^#\[test\]')

Manual fixes:
* proc_macro::proc_macro_doctest
2019-06-07 12:41:26 -07:00
Eric Huss
7d202307ce Include Cargo.lock in package checks.
This includes `Cargo.lock` in the git dirty check. It explicitly excludes
`Cargo.lock` as an untracked file, since it is not relevant for the dirty check;
it is only checked if it is committed to git.

This also adds `Cargo.lock` to the "did anything modify this" check during
verification. I don't see a reason to exclude it (particularly since ephemeral
workspaces do not save the lock file).

Also add "Archiving: Cargo.lock" to the verbose output.
2019-04-17 14:06:05 -07:00
Eric Huss
5553284d05 Avoid multiple index updates.
This also restores the Cargo.lock update during packaging.
2019-04-16 11:03:20 -07:00
Eric Huss
753b03f652 Alter cargo package Cargo.lock modification note.
Try to make it clearer that it is not modifying the actual Cargo.lock file, but
the one that is being stored in the .crate file.
2019-04-16 09:06:59 -07:00
Eric Huss
6eb55abe2c cargo package: Change lock file updates from warning to requiring -v. 2019-04-16 08:54:24 -07:00
Eric Huss
c03c85ad49 publish-lockfile: Change default to true.
The feature still needs to be enabled.
2019-04-16 08:54:24 -07:00
Eric Huss
5f616eb18e Add warnings for yanked dependencies.
This only applies for `cargo package/publish` with the publish-lockfile feature,
or `cargo install --locked`.
2019-04-16 08:54:24 -07:00
Eric Huss
27932ead44 publish-lockfile: Always check Cargo.lock is up-to-date.
This changes it so that `cargo package` will make sure the Cargo.lock file is
in sync with the Cargo.toml that is generated during packaging. This has several
points:

- This makes the Cargo.lock more accurately reflect what would be locked
  if a user runs `cargo install` on the resulting package.
- In a workspace, this removes irrelevant packages from the lock file.
- This handles `[patch]` dependencies and dual-source dependencies (like
  path/version).
- Warnings are generated for any differences in the lock file compared to the
  original.

This has a significant change in how `cargo package` works. It now
unconditionally copies the package to `target/package`. Previously this was only
done during the verification step. This is necessary to run the resolver against
the new `Cargo.toml` that gets generated.
2019-04-16 08:54:24 -07:00
Eric Huss
ebb5764ad8 Move publish-lockfile tests to a dedicated file. 2019-04-16 08:54:24 -07:00