Commit Graph

754 Commits

Author SHA1 Message Date
Eric Huss 9cb59bc202 Idiom lints are now configured in the manifest. 2023-11-18 17:49:18 -08:00
Eric Huss 3ca00ad8cd Integrate rustfix's manifest into the workspace. 2023-11-18 17:40:20 -08:00
Eric Huss 2eac6f5c0c Fix clippy-wrapper test race condition. 2023-11-18 17:23:29 -08:00
Eric Huss 73e5506338 Merge remote-tracking branch 'rustfix/master' into rustfix 2023-11-18 16:51:22 -08:00
Weihang Lo e2f5925bb0
chore: bump version for member crates 2023-11-16 13:19:44 -05:00
Weihang Lo 7a4754a1d3
lint: allow `print_stdout` and `print_stderr` 2023-11-16 11:35:21 -05:00
Weihang Lo 870f9ea7b3
lint: allow `disallow_methods` 2023-11-16 11:35:21 -05:00
Weihang Lo 1539b3dfc1
lint: dogfood ourselves `lints` table in manifest
These lint rules are from src/lib.rs. We aim to remove
them in the source code once `Zlints` hit stable.
2023-11-16 11:35:21 -05:00
Eric Huss 1d35833e3b Switch from AtomicU64 to Mutex.
Not all platforms support AtomicU64, so this swaps the usage with
Mutex. The difference in performance should be imperceptible.
2023-11-15 14:41:56 -08:00
Jacob Finkelman 6835fa3867 query{_vec} should use IndexSummary 2023-11-13 19:39:25 +00:00
Eric Huss 80ffb1de1c Fix --quiet being used with nested subcommands.
This fixes an issue where `--quiet` doesn't work with commands that have
subcommands. This is because `config_configure` only looks at the global
and top-level subcommand, and not deeper subcommands. The issue was that
`--quiet` was not defined as a global flag. This was changed in
https://github.com/rust-lang/cargo/pull/6358 in order to give a better
help message for `cargo test --quiet`. I don't remember if clap just
didn't support overriding at the time, or if we just didn't know how it
worked. Anyways, it seems to work to override it now, so I think it
should be fine to mark it as global.

This should bring in `--quiet` more in-line with how `--verbose` works.
This means that `--quiet` is now accepted with `cargo report`,
`cargo help`, and `cargo config`.

This also fixes `--quiet` with `cargo clean gc`.

This should also help with supporting `--quiet` with the new `cargo
owner` subcommands being added in
https://github.com/rust-lang/cargo/pull/11879.

Fixes #12957
2023-11-12 11:17:43 -08:00
Eric Huss 56c8d90d13 Use walkdir's built-in sorting option. 2023-11-11 10:56:59 -08:00
Eric Huss da3ca05677 Add a global cache garbage collector.
This adds a garbage collector which will remove old files from cargo's
global cache.

A general overview of the changes here:

- `cargo::core::global_cache_tracker` contains the `GlobalCacheTracker`
  which handles the interface to a sqlite database which stores
  timestamps of the last time a file was used.
- `DeferredGlobalLastUse` is a type that implements an optimization for
  collecting last-use timestamps so that they can be flushed to disk all
  at once.
- `cargo::core::gc` contains the `Gc` type which is the interface for
  performing garbage collection. It coordinates with the
  `GlobalCacheTracker` for determining what to delete.
- Garbage collection can either be automatic or manual. The automatic
  garbage collection supports some config options for defining when
  it runs and how much it deletes.
- Manual garbage collection can be performed via options to `cargo
  clean`.
- `cargo clean` uses the new package cache locking system to coordinate
  access to the package cache to prevent interference with other cargo
  commands running concurrently.
2023-11-11 10:56:58 -08:00
Eric Huss 9588fb6dda Add a du utility function.
This adds a very primitive `du` function for determining the disk usage
in a directory. This should probably be improved or replaced at some
point in the future, this is just a start for supporting tracking sizes
of cache data.
2023-11-11 10:56:58 -08:00
Ed Page 6bfc32a15e refactor(resolver): Pull MSRV handling to VersionPreferences 2023-11-07 20:39:35 -06:00
Ed Page bf2987b09b refactor(resolver): Track minimal-versions in VersionPreferences
This had repurcussions on direct-minimal-versions as it before relied on
the ordering parameter to `sort_sumarries`.
2023-11-07 20:39:35 -06:00
Ed Page 3cdddbf033 test(resolver): Improve failure output 2023-11-07 20:39:35 -06:00
Ed Page e70e310ce0 fix: Report more detailed semver errors
For `cargo install` we'll now show a more specific parse error for
semver, much like other parts of cargo.

This came out of my work on #12801.  I was looking at what might be
appropriate to put in a `cargo-util-semver` crate and realized we have
the `ToSemver` trait that exists but doesn't do much, so I dropped it.
2023-11-06 15:24:32 -06:00
Ed Page 293f2250d6 feat(doc): Print the generated docs links
I've wanted something like this myself.  I dislike using `--open`
because I tend to move up to re-run my `cargo doc` run but then have to
edit it to remove `--open`.
Also makes it annoying when opening docs when `cargo doc` is wrapped by
a tool like `make`.

This was previously attempted in #5592:
- Unlike the request in #5562, this aligns with #5592 in always printing
  rather than using a flag as this seems generally useful
- Unlike #5592, this prints as an alternative to "Opening" to keep
  things light
- Unlike #5592, this prints afterwards as the link is only valid then

Fixes #5562
2023-10-19 10:51:56 -05:00
bors f7e7cc2356 Auto merge of #12820 - linyihai:broken-symlink-target, r=weihanglo
add detailed message when target folder path is invalid

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

add more detailed message when target folder path is invalid

# How should we test and review this PR?

Before this PR, if the target folder refer to broken symbolic link like /a/b/c, then run cargo build, the output is:

```
error: Not a directory (os error 20)
```
the detailed error message is missing.

This PR will add the error context for it, the finall output will be
```
cargo build
error: failed to create directory `/root/workspace/playground/target`

Caused by:
  Not a directory (os error 20)
```
2023-10-14 04:43:58 +00:00
Lin Yihai ceac419776 add detailed message when target folder path is invalid 2023-10-14 11:34:42 +08:00
Ed Page 7846fe8cb4 chore: Sort dependency tables
This will make `cargo add` put things in the right place.

Verified by doing `cargo add arcstr && git diff && git reset --hard`
2023-10-10 15:03:22 -05:00
bors b48c41aedb Auto merge of #12706 - ehuss:cache-lock-mode, r=epage
Add new package cache lock modes

The way locking worked before this PR is that only one cargo could write to the package cache at once (otherwise it could cause corruption). However, it allowed cargo's to read from the package cache while running a build under the assumption that writers are append-only and won't affect reading. This allows multiple builds to run concurrently, only blocking on the part where it is not possible to run concurrently (downloading to the cache).

This introduces a new package cache locking strategy to support the ability to safely modify existing cache entries while other cargos are potentially reading from the cache. It has different locking modes:

- `MutateExclusive` (new) — Held when cargo wants to modify existing cache entries (such as being introduced for garbage collection in #12634), and ensures only one cargo has access to the cache during that time.
- `DownloadExclusive`  (renamed) — This is a more specialized name for the lock that was before this PR.   A caller should acquire this when downloading into the cache and doing resolution.  It ensures that only one cargo can append to the cache, but allows other cargos to concurrently read from the cache.
- `Shared` (new) — This is to preserve the old concurrent build behavior by allowing multiple concurrent cargos to hold this while a build is running when it is reading from the cache

**Reviewing suggestions:**
There are a few commits needed to help with testing which are first. The main commit has the following:
- `src/cargo/util/cache_lock.rs` is an abstraction around package cache locks, and is the heart of the change. It should have comments and notes which should guide what it is doing. The `CacheLocker` is stored in `Config` along with all our other global stuff.
- Every call to `config.acquire_package_cache_lock()` has been changed to explicitly state which lock mode it wants to lock the package cache in.
- `Context::compile` is the key point where the `Shared` lock is acquired, ensuring that no mutation is done while the cache is being read.
- `MutateExclusive` is not used in this PR, but is being added in preparation for #12634.
- The non-blocking `try_acquire_package_cache_lock` API is not used in this PR, but is being added in preparation for #12634 to allow automatic gc to skip running if another cargo is already running (to avoid unnecessary blocking).
- `src/cargo/util/flock.rs` has been updated with some code cleanup (removing unused stuff), adds support for non-blocking locks, and renames some functions to make their operation clearer.
- `tests/testsuite/cache_lock.rs` contains tests for all the different permutations of ways of acquiring locks.
2023-10-09 15:56:42 +00:00
Eric Huss b4982adfd9 Add a new package cache locking system.
This introduces a new `CacheLocker` which manages locks on the package
cache. Instead of either being "locked" or "not locked", the new locker
supports multiple modes:

- Shared lock: Cargo can read from the package sources, along with any
  other cargos reading at the same time.
- Download exclusive lock: Only one cargo can perform downloads.
  Download locks do not interfere with Shared locks, since it is
  expected that downloading does not modify existing files (only adds
  new ones).
- Mutate exclusive lock: Only one cargo can have this lock, and it also
  prevents shared locks. This is so that the cargo can modify the
  package cache (such as deleting files) without breaking concurrent
  processes.
2023-10-08 14:16:51 -07:00
Eric Huss b85ef38187 Add test helpers for waiting for an operation with a timeout. 2023-10-08 14:16:51 -07:00
Eric Huss 83fff2d1b1 Add a test helper for retrying a function multiple times. 2023-10-08 14:16:51 -07:00
bors 0871c0e2f4 Auto merge of #12795 - weihanglo:semver-checks, r=ehuss
ci: bump cargo-semver-checks to 0.24.0
2023-10-08 21:15:54 +00:00
Weihang Lo 60539e94dc
ci: bump cargo-semver-checks to 0.24.0
Also remove workaround since the issue was fixed in upstream.
2023-10-08 16:24:23 -04:00
Ed Page 03a642b1d8 fix: Set MSRV in all published packages 2023-10-06 16:34:42 -05:00
Tobias Bieniek 9e5dac18b9
crates.io: Bump version to 0.39.1 2023-10-06 16:11:38 +02:00
Tobias Bieniek e287f43006
crates-io: Add doc comment for `NewCrate` struct 2023-10-06 14:04:03 +02:00
Ed Page 72f4f0cb3f chore: Simplify releasing `home`
I'm not seeing any benefit derived by `html_root_url`
2023-10-02 12:13:49 -05:00
bors 9a94183771 Auto merge of #12744 - tompscanlan:atomic-write, r=epage
fix bug: corruption when cargo killed while writing

### What does this PR try to resolve?

fix  #11386, superseding #12362

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

Added unit test showing basic equivalency to existing `write(path, content)`. Full test suite should exercise write.
Added tests for cargo add and remove. These are timing tests, so take a bit of time to run. 5-10s each.  They may not fail every time, but do so regularly.  Making the change to these two writes seems to prevent me from failing these tests at all.

### Additional information

This uses tempfile::persist which was an existing dependency. atomicwrites crate, an alternative option for this fix, indicates `tempfile::persist` is the same thing.  Since we already use tempfile as a dep, I stuck with that.
2023-10-02 13:34:00 +00:00
Tom Scanlan aee8c75410
bug: corruption when killed while writing 2023-10-01 08:29:24 -04:00
Ed Page 37c6f3d085 fix(test): Add back in newlines to diffs
Errors like this aren't too helpful
```
error: stderr did not match:
1   1     error: failed to parse manifest at `[..]`2   2     3   3     Caused by:4   4       TOML parse error at line 3, column 275   5         |6   6       3 |                 version = 17
  7         |                           ^8        -  invalid type: integer `1`, expected SemVer version    8    +  invalid type: integer `1`, expected a string or workspace
```

This was broken in #12581
2023-09-29 20:02:53 -05:00
Ed Page 796398563a refactor(test): Switch termcolor to anstream 2023-09-29 10:16:15 -05:00
cui fliter c8f4d234bb Fix some typos
Signed-off-by: cui fliter <imcusg@gmail.com>
2023-09-24 23:10:07 +08:00
Eric Huss ebea09d8f4 Fix spurious errors with networking tests. 2023-09-22 13:37:26 -07:00
Eric Huss 495ed7ebe2 Add a summary to `cargo clean`.
This adds a summary at the end when `cargo clean` finishes that displays
how many files and bytes were removed.
2023-09-19 18:16:40 -07:00
bors f9335babbc Auto merge of #12707 - epage:spell, r=ehuss
chore: Fix typos

This is a repeat of #11561
2023-09-19 22:07:03 +00:00
Jacob Finkelman 679d65103f shortest path is probably more informative than random path for error messages 2023-09-19 20:39:02 +00:00
Ed Page e4e10f2393 chore: Fix typos
This is a repeat of #11561
2023-09-19 15:28:48 -05:00
Jacob Finkelman 245e69ce10 add a test for shortest path 2023-09-19 20:22:13 +00:00
Ed Page 4135f562b8 refactor(manifest): Clarify the specialized role of RustVersion 2023-09-13 21:59:26 -06:00
Weihang Lo 463622ad81
lint: fix errors for self-named module files 2023-09-14 13:43:48 +08:00
Weihang Lo aef3bd22d3
lint: fix errors for rust 2018 idioms 2023-09-14 13:43:48 +08:00
Weihang Lo 437942ee7e
lint: use `eprintln` for human-facing outputs 2023-09-14 13:43:47 +08:00
Weihang Lo f9d82a1703
lint: remove unused `dbg!` 2023-09-14 13:43:47 +08:00
Jacob Finkelman 205fd1a765 libgit2 fixed upstream 2023-09-11 19:25:45 +00:00
Jacob Finkelman 2b2838302f bump cargo-platform 2023-09-08 19:16:42 +00:00
Jacob Finkelman 44666f7377 Ues strip_prefix for cleaner code 2023-09-07 17:57:28 +00:00
Weihang Lo e575448574
refactor: flatten module path of `SourceId` 2023-09-07 21:06:35 +08:00
Weihang Lo b6c4e47cc0
refactor: put `Source` trait under `cargo::sources` 2023-09-07 21:06:34 +08:00
bors baca00ebe1 Auto merge of #12636 - ehuss:fs-metadata-wrappers, r=weihanglo
Add wrappers around std::fs::metadata

This adds wrappers around `std::fs::metadata` and `std::fs::symlink_metadata` which provide better error messages indicating the path that caused the error. This just helps clean up some duplicated code, and is also going to be used to assist with some code changes in #12634.
2023-09-07 08:54:50 +00:00
bors 282424e42d Auto merge of #12635 - ehuss:with-stdout-unordered, r=weihanglo
Add with_stdout_unordered.

This adds the `with_stdout_unordered` method to cargo's test system so that tests can use it to check stdout but ignoring the order of lines. Nothing in this PR actually uses this method, but it is added to support #12634. I also expect it could potentially be useful in other cases in the future.
2023-09-07 06:26:51 +00:00
Eric Huss 62d86470d1 Add wrappers around std::fs::metadata
This adds wrappers around std::fs::metadata and
std::fs::symlink_metadata which provide better error messages indicating
the path that caused the error.
2023-09-06 21:41:54 -07:00
Eric Huss 0adb9f1b2a Add with_stdout_unordered.
This adds Execs::with_stdout_unordered to check stdout ignoring the
order of lines.
2023-09-06 21:40:56 -07:00
Eric Huss 8964f3fd5d Fix example for creating a git project test. 2023-09-06 18:56:12 -07:00
bors cff6d19f6e Auto merge of #12615 - Eh2406:split_once, r=epage
use split_once for cleaner code

### What does this PR try to resolve?

Search the code base for `.splitn(2` and replace with `.split_once` where it was clearer. I don't think any of them matter in practice.

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

This was an internal re-factor, and the tests still pass.
The two methods have subtly different semantics, so please review carefully.
2023-09-03 02:27:49 +00:00
Jacob Finkelman 1ea81a3692 use split_once for cleaner code 2023-09-01 21:45:55 +00:00
Jacob Finkelman 16b330bc59 stop using lazy_static 2023-09-01 21:38:03 +00:00
Ed Page 4820624ce7 feat(resolver): Respect MSRV 2023-08-25 10:42:26 -05:00
bors f797978283 Auto merge of #12553 - epage:version, r=weihanglo
refactor: Pull out cargo-add MSRV code for reuse

### What does this PR try to resolve?

#12078 added MSRV code in `cargo add`. Our assumption when writing it is that we'd need to generalize the code before reusing it in other places, like `cargo install`.  This PR focused purely on that refactor because I'm hopeful it will be useful for other work I'm doing.  Despite not having a user for this yet, I think the `cargo install` case is inevitable and I feel this does a bit to clean up MSRV related code by using a more specific type everywhere.

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

Each commit gradually progresses things along
2023-08-25 14:56:24 +00:00
Deadbeef b2b34e4ca2 update tests 2023-08-25 01:43:29 +00:00
Deadbeef 3d50f47197 Add fields for bindeps on the registry 2023-08-25 01:43:29 +00:00
Ed Page 423a334520 refactor: Parse, don't validate, rust_version
By using the `PartialVersion` type with serde, we get the context for
the error automatically.
2023-08-24 14:15:35 -05:00
Ed Page 7a65c826a0 fix: Set MSRV for internal packages
For now, I'm punting on packages we generally expect others to use
2023-08-22 16:46:47 -05:00
Ed Page 576f901f81 fix(log): Use a more compact relative-time format
This changes logged messages from
```
2023-08-23T01:01:59.922018Z DEBUG cargo::core::compiler::fingerprint: filesystem up-to-date "/home/epage/src/personal/dump"
```
To
```
   0.041729583s DEBUG cargo::core::compiler::fingerprint: filesystem up-to-date "/home/epage/src/personal/dump"
```
Benefits
- Less horizontal space taken up in boilerplate
- Easier to compare within a run

Downsides
- Harder to correlate with other processes, like with crates.io server
  operations

This gives us up to 4 digits for seconds which should be sufficient for
cargo build times.

We could make this more compact by dropping the digits of precision from
9 to 6 but that would require a custom Timer which might be a paint to
keep in sync between packages.
2023-08-22 20:34:07 -05:00
Eric Huss 96da3c4872 Support hidden lines. 2023-08-17 18:18:10 -07:00
Eric Huss 4c1d8f1364 Document the special code block annotations. 2023-08-17 18:18:10 -07:00
Arlo Siemsen 763edbab09 rename crate to cargo-credential-libsecret 2023-08-17 16:05:31 -05:00
Weihang Lo 5691da2b79
chore(cargo-util): bump version to 0.2.6 2023-08-16 20:06:40 +01:00
Weihang Lo 1ee9db3123
fix(xtask-bump-check): query by package name to detect changes
versions and paths of a workspace members between the original and
a checked-out workspace are different, and shouldn't be included in
hash keys when querying packages.
2023-08-16 15:46:43 +01:00
Weihang Lo c07043b7cf
fix(log): enable ansi color only in terminal 2023-08-14 15:45:25 +01:00
Weihang Lo 9d707e4b9a
chore: remove `log`, `env_logger`, and `pretty_env_logger` 2023-08-07 12:02:19 +01:00
Weihang Lo 7e69050c64
refactor: setup `tracing-subscriber` 2023-08-07 12:02:19 +01:00
Weihang Lo 23561f36a1
chore: add `tracing-subscriber` crate 2023-08-07 11:25:41 +01:00
Weihang Lo af1a78b424
refactor: find & replace `log::` -> `tracing::`
Except HTTP network debugging
2023-08-07 11:25:40 +01:00
Weihang Lo 9f0565e985
chore: add `tracing` crate 2023-08-07 11:21:55 +01:00
bors 6145d0c4d2 Auto merge of #12395 - weihanglo:cargo-semver-checks, r=epage
ci: rewrite bump check and respect semver

### What does this PR try to resolve?

This ports `ci/validate-version-bump.sh` and #12200 to the new xtask `bump-check`. It also adds the ability to set the correct baseline revision when checking version bump. That is, it fixes #12347.

In addition, this integrates the community tool `cargo-semver-checks`. SemVer violation can now be detected earlier.

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

This PR extracts the registry query part from `xtask-unpublished` and removes other pars. I don't feel like we need it in the short term.

For how it works, please the check doc comment in each function.

One concern is that this check is still a required job for bors. I believe `@obi1kenobi` is quite responsive and willing to help if there is something wrong. So, waiting for an upstream fix won't be a problem for cargo. Also as a good citizen in the community, we can always contribute back.
(Take it easy `@obi1kenobi,` don't be stressed out 🙂)
<!-- homu-ignore:end -->
2023-08-01 23:00:45 +00:00
Weihang Lo 8d31d626a2
chore: remove `xtask-unpublished` 2023-08-01 22:54:41 +01:00
Weihang Lo 9cca5721e4
chore: new xtask `bump-check`
This is a rewrite of old `ci/validate-version-bump.sh` in Rust.
2023-08-01 22:54:40 +01:00
renovate[bot] a63bc76577
chore(deps): update alpine docker tag to v3.18 2023-08-01 02:18:33 +00:00
Weihang Lo 46bf05dcaf
chore: update `home` to 0.5.7 2023-07-26 11:26:49 +01:00
Arlo Siemsen 2b39792aef Credential provider implementation 2023-07-21 16:02:24 -05:00
Weihang Lo 31b500c7c0
refactor(crates-io): use `thiserror`
Optionally use `thiserror` to reduce boilerplates but this part can
be dropped if we don't want.
2023-07-18 22:22:47 +01:00
Weihang Lo b4499af4e9
refactor(crates-io): remove `anyhow`
This removes the dependency `anyhow` and uses our own custom Error
enum, so that crates-io consumer can access `Error::API::challenge`
field.
2023-07-18 22:22:47 +01:00
Weihang Lo a561e8b781
feat(crates-io): use our own `Result` wrapper everywhere 2023-07-18 22:22:47 +01:00
Weihang Lo ed6692b1c6
refactor(crates-io): rename `ResponseError` to `Error` 2023-07-18 22:22:47 +01:00
Weihang Lo 00a872740a
fix(crates-io): don't let server sneak extra lines anywhere
From 5febbe5587/src/cargo/sources/registry/http_remote.rs (L234-L237)
2023-07-18 22:22:46 +01:00
Weihang Lo 6805944715
feat(crates-io): expose headers for `ResponseError::Api`
In response to RFC 3231 [^1], our registry client need to return headers
to caller, so that the caller (cargo binary) can continue parsing
challenge headers.

[^1]: https://rust-lang.github.io/rfcs/3231-cargo-asymmetric-tokens.html#the-authentication-process
2023-07-18 22:22:46 +01:00
Ed Page 83a5859221 chore(platform): Version bump 2023-07-17 13:21:41 -05:00
Ed Page 4bd5f9ca50 chore(util): Version bump 2023-07-17 13:21:41 -05:00
Ed Page 5d80aa263d refactor: Provide workspace-level default license 2023-07-17 13:21:41 -05:00
Ed Page 3752929dd4 refactor: Update home to 2021 edition 2023-07-17 13:21:41 -05:00
Ed Page e4877cc701 refactor: Update resolver-tests to 2021 edition 2023-07-17 13:21:41 -05:00
Ed Page f358359a17 refactor: Provide a workspace-level default edition 2023-07-17 13:21:40 -05:00
Ed Page 8b02d4927e refactor: Infer package.readme 2023-07-17 13:21:10 -05:00
Arlo Siemsen d45ba88290 Bump version of crates-io due to unintentional semver-breaking change 2023-07-13 14:35:09 -05:00
Eric Huss 43c253e69a Rustfmt with latest nightly. 2023-07-11 16:58:53 -07:00
Eric Huss 9835622853 Convert valid feature name warning to an error. 2023-06-20 12:39:27 -07:00
Eric Huss 75bcada1eb Show a better error when container tests fail. 2023-06-13 11:15:39 -07:00
Ed Page b2b4d9771f test(cli): Verify precedence over external subcommands 2023-06-09 13:16:12 -05:00
Weihang Lo c977baa9cf
refactor: rename `RegistryPackage` to `IndexPackage`
This is a better name to reflect it is from "index" files.
2023-06-07 23:01:55 +01:00
Weihang Lo fa7cc198aa
refactor: replace some usages of `lazy_static` with `OnceLock`
* Some usages still wait for `LazyCell`.
* `TEST_ROOTS` is no longer used. Removed.
2023-06-01 22:11:20 +01:00
Weihang Lo 8cb220f5eb
refactor: use `IsTerminal` from std instead of `is-terminal` crate 2023-06-01 21:50:43 +01:00
trevyn 5dfae689fa Improve error chain formatting 2023-05-30 13:55:05 +04:00
trevyn 0b8c12f5c6 Document reasoning and report previous error chain 2023-05-30 07:51:07 +04:00
trevyn ddc49783ce Fall back to `fs::remove_dir_all` on error 2023-05-28 17:57:49 +04:00
Weihang Lo 7b4e32d64b
test: set retry sleep to 1ms for all tests 2023-05-27 11:28:58 +01:00
bors d90ff55ca5 Auto merge of #11968 - bzEq:aix-libpath, r=weihanglo
fix: AIX searches dynamic libraries in `LIBPATH`.

### What does this PR try to resolve?

On IBM AIX machines people have encountered issues in `compiletest` and rustc's bootstrap builder. They haven't encountered any in cargo. This PR is made for avoiding potential failures in the future in cargo.

It's documented in <https://www.ibm.com/support/pages/libpath-environment-variables-aix-platforms>:

> The `LIBPATH` environment variable tells AIX applications where to find shared libraries when located in a different directories than those specified in the header section of the executable.

See also the counterpart in <https://github.com/rust-lang/rust/pull/109526>

### How to verify and test this in Cargo's CI?

This is indeed an issue. At IBM people are maintaining a buildbot since GitHub Action doesn't support AIX yet.
2023-05-25 10:20:29 +00:00
bors 5a396277e8 Auto merge of #12126 - weihanglo:ci-version-bump, r=epage
ci: check if any version bump needed for member crates

### What does this PR try to resolve?

Check if a crate requires a version bump in CI.

Part of #12033

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

Demo action result: <https://github.com/weihanglo/cargo/actions/runs/4941952784/jobs/8835049007>

### Additional information

This doesn't devalue #12089. I love the changelog detection, saving maintainers' times a lot ( I am the one writing changelogs for each release for now). However, the amount of code there is too excessive to me. I think someday when we are going to integrate [cargo-release](https://crates.io/crates/cargo-release) and/or [ehuss/cargo-new-release](https://github.com/ehuss/cargo-new-release), we can remove this script perhaps entirely :)

I tried to document the script a bit hard. Hope it won't get worse over time.
2023-05-23 02:28:15 +00:00
WANG Rui 6a9cb23923 Remove useless drop of copy type 2023-05-13 16:51:30 +08:00
Weihang Lo 8eb3f51725
doc: explain what xtask-unpublished does 2023-05-10 23:28:45 +01:00
Eric Huss dd25e89460 Update the semver-check script to be able to run in any directory. 2023-05-09 12:53:05 -07:00
Weihang Lo 8620f5a7d5
xtask-unpublished: table output 2023-05-05 16:32:07 +01:00
Weihang Lo 0bffcbcb8a
chore: `publish = false` for pkgs not meant to be published
These tree packages are considered to be published something.
To reduce the logic of xtask-unpubilshed, let's flag them false for now.
We can always set it `true` when needed.
2023-05-05 16:24:19 +01:00
Weihang Lo 8d753a767c
xtask-unpublished: respect `--package` flag 2023-05-05 16:24:18 +01:00
bors 33c64109fe Auto merge of #12055 - QiangHeisenberg:crates-io-doc-test, r=weihanglo
fix:  doc-test failures

### What does this PR try to resolve?

When I read the source code, I found that the `Registry::new_handle` document test failed and seemed to be missing parameters;

There is no change in this [PR](https://github.com/rust-lang/cargo/pull/10592/files#diff-12973056cf99e8de997011a8738a6740a7dfd06142a73f122f3b35218db37351).
2023-05-04 14:30:42 +00:00
QiangHeisenberg ff7ff7d50d Added the no_run attribute 2023-05-04 16:25:12 +08:00
QiangHeisenberg ea0d487b99 fix cargo-test-support doc test 2023-05-04 11:16:34 +08:00
Scott Schafer 34b8c39d77 chore: Use `[workspace.dependencies]` 2023-04-28 09:56:09 -05:00
cui fliter 825c75af31 Remove repeated definite articles
Signed-off-by: cui fliter <imcusg@gmail.com>
2023-05-01 21:37:28 +08:00
bors 393ce5b416 Auto merge of #12048 - weihanglo:mdman, r=epage
chore: move build-man workflow away from shell
2023-04-28 15:48:53 +00:00
bors 7a90ba1ecc Auto merge of #12043 - epage:rust-version, r=weihanglo
feat: Add `-Zmsrv-policy` feature flag

### What does this PR try to resolve?

Nothing noticeable....

The intent is to unblock experiments with different compatible MSRV policies like
- #9930
- #10653
- #10903

While I normally don't like PRs that do nothing on their own, this at least allows any one of those efforts to move forward with different people without juggling these base commits for whoever is first to include in their PR

While there isn't an RFC for this yet, this is intended to allow us to experiment to get a better idea of what we should put in an RFC.  In some cases, we first do an eRFC for this but I assumed this wouldn't be needed in this case as this builds on rust-lang/rfcs#2495 and, I'm assuming, will be more surgical in nature

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

The `Summary` changes are largely untested as they will be mostly tested through the future work that builds on this PR.  However, I wasn't too concerned about that because the code is relatively trivial.

### Additional information

I chose the name `msrv-policy` to distinguish this unstable feature from `rust-version`.  Though those appear in different places (`Cargo.toml` vs `-Z`), I can see them being confusing which was especially apparent when editing `unstable.md` which has an anchor for `rust-version`.
2023-04-28 14:55:25 +00:00
Weihang Lo 137c82a54b
mdman: update mdman's example outputs 2023-04-28 15:46:37 +01:00
Weihang Lo e3dec38f4b
mdman: use `cargo build-man` everywhere 2023-04-28 15:46:37 +01:00
Weihang Lo c01bad9b20
mdman: make build-man part of xtask
Turn `src/doc/build-man.sh` into a Cargo binary target.
So is `crates/mdman/build-man.sh`.
2023-04-28 15:46:37 +01:00
Weihang Lo 9c426c90de
mdman: remove dangling Cargo.lock 2023-04-28 15:44:24 +01:00
Weihang Lo 36653ab85a
ci: add job `stale-label` 2023-04-28 12:02:51 +01:00
Weihang Lo 981282891f
xtask-stale-label: check stale paths in autolabel defintions 2023-04-28 12:02:51 +01:00
QiangHeisenberg 796f9acbcb fix test failed 2023-04-28 17:08:04 +08:00
Utkarsh Gupta fd1f1043e0
home: bump version & update changelog 2023-04-27 22:00:19 +05:30
Utkarsh Gupta c078c0ca21
home: fix & enhance documentation 2023-04-27 21:49:05 +05:30
bors 0ad289b264 Auto merge of #12045 - epage:publish, r=weihanglo
chore: Mark unpublished crates as such

This is a follow up to #12039.
This makes it easier for tools to report less irrelevant information.

I did both `publish = false` and `version = "0.0.0"` to help draw attention to the fact that these crates are internal (inspired by a matklad post).

I left `cargo-test-macro` and `cargo-test-support` in for my own personal bias of one day wanting to see those crates published...

The only one removed that had previously been published was `mdman` but seeing as that was a `0.0.0`, I'm assuming that was a mistake or just reserving the name.

Before:
```console
$ cargo unpublished
name published current
==== ========= =======
cargo-platform 0.1.2 0.1.3
cargo-test-macro - 0.1.0
cargo-test-support - 0.1.0
cargo-util 0.2.3 0.2.4
crates-io 0.36.0 0.36.1
mdman 0.0.0 0.1.0
resolver-tests - 0.1.0
cargo 0.70.1 0.72.0
semver-check - 0.1.0
cargo-credential 0.1.0 0.2.0
cargo-credential-1password 0.1.0 0.2.0
cargo-credential-gnome-secret 0.1.0 0.2.0
cargo-credential-macos-keychain 0.1.0 0.2.0
cargo-credential-wincred 0.1.0 0.2.0
benchsuite - 0.1.0
```

After:
```console
name published current
==== ========= =======
cargo-platform 0.1.2 0.1.3
cargo-test-macro - 0.1.0
cargo-test-support - 0.1.0
cargo-util 0.2.3 0.2.4
crates-io 0.36.0 0.36.1
cargo 0.70.1 0.72.0
cargo-credential 0.1.0 0.2.0
cargo-credential-1password 0.1.0 0.2.0
cargo-credential-gnome-secret 0.1.0 0.2.0
cargo-credential-macos-keychain 0.1.0 0.2.0
cargo-credential-wincred 0.1.0 0.2.0
```
2023-04-27 05:54:17 +00:00
bors 42a45c841f Auto merge of #12041 - cassaundra:publish-rust-version, r=epage
Include rust-version in publish request

crates.io reads rust-version from the tarball directly, but we can include it in the publish request for the sake of consistency for third-party registries. See [relevant Zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/318791-t-crates-io/topic/rust-version.20field).

Validation for the field was already implemented in #8037.
2023-04-27 01:13:35 +00:00
bors 8bcf8fe770 Auto merge of #12039 - epage:xtask, r=weihanglo
chore(xtask): Add `cargo xtask unpublished`

### What does this PR try to resolve?

This tries to make it easy to see what existing versions have not been published.  A future version of this could post to a PR what the current delta in version numbers for touched crates so reviewer have more context when deciding if they should ask for a crate version to be bumped
```console
$ cargo unpublished
    Finished dev [unoptimized + debuginfo] target(s) in 0.12s
     Running `/home/epage/src/personal/cargo/target/debug/xtask unpublished`
    Updating crates.io index
name published current
==== ========= =======
cargo-test-macro - 0.1.0
cargo-test-support - 0.1.0
cargo-util 0.2.3 0.2.4
mdman 0.0.0 0.1.0
resolver-tests - 0.1.0
cargo 0.70.0 0.71.0
cargo-credential 0.1.0 0.2.0
cargo-credential-1password 0.1.0 0.2.0
cargo-credential-gnome-secret 0.1.0 0.2.0
cargo-credential-macos-keychain 0.1.0 0.2.0
cargo-credential-wincred 0.1.0 0.2.0
benchsuite - 0.1.0
```

Room for improvement
- Aligning the start of each column
- Filtering the list by a commit range
- Adding this to an action to post to a review
- Maybe sorting the output
- Marking some our crates as `package.publish = false`, like benchsuite and resolver-tests

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

This is broken down commit by commit for easier seeing of the building blocks for our first xtask
2023-04-26 23:09:59 +00:00
Ed Page 077b1bc311 chore: Mark unpublished crates as such
This is a follow up to #12039.
This makes it easier for tools to report less irrelevant information.

I did both `publish = false` and `version = "0.0.0"` to help draw
attention to the fact that these crates are internal (inspired by a
matklad post).

I left `cargo-test-macro` and `cargo-test-support` in for my own
personal bias of one day wanting to see those crates published...

The only one removed that had previously been published was `mdman` but
seeing as that was a `0.0.0`, I'm assuming that was a mistake or just
reserving the name.

Before:
```console
$ cargo unpublished
name published current
==== ========= =======
cargo-platform 0.1.2 0.1.3
cargo-test-macro - 0.1.0
cargo-test-support - 0.1.0
cargo-util 0.2.3 0.2.4
crates-io 0.36.0 0.36.1
mdman 0.0.0 0.1.0
resolver-tests - 0.1.0
cargo 0.70.1 0.72.0
semver-check - 0.1.0
cargo-credential 0.1.0 0.2.0
cargo-credential-1password 0.1.0 0.2.0
cargo-credential-gnome-secret 0.1.0 0.2.0
cargo-credential-macos-keychain 0.1.0 0.2.0
cargo-credential-wincred 0.1.0 0.2.0
benchsuite - 0.1.0
```

After:
```console
name published current
==== ========= =======
cargo-platform 0.1.2 0.1.3
cargo-test-macro - 0.1.0
cargo-test-support - 0.1.0
cargo-util 0.2.3 0.2.4
crates-io 0.36.0 0.36.1
cargo 0.70.1 0.72.0
cargo-credential 0.1.0 0.2.0
cargo-credential-1password 0.1.0 0.2.0
cargo-credential-gnome-secret 0.1.0 0.2.0
cargo-credential-macos-keychain 0.1.0 0.2.0
cargo-credential-wincred 0.1.0 0.2.0
```
2023-04-26 17:51:16 -05:00
Ed Page f3728d3250 feat: Expose 'rust_version' in the Summary 2023-04-26 15:59:22 -05:00
Ed Page 07e3bb880d feat(test): Manual publishes set 'rust_version' in Index 2023-04-26 15:59:22 -05:00
cassaundra 5554889f88
Include rust-version in publish request
crates.io reads rust-version from the tarball directly, but we can include it in
the publish request for the sake of consistency for third-party registries.
2023-04-26 11:59:29 -07:00
Ed Page 5b13963044 perf(xtask): Split xtask binaries
This will allow running an xtask without requiring building the world.
In most cases, a user will already have been building cargo but not in
CI.

The packages keep an `xtask-` prefix to help raise awareness of them but
exposed as `cargo <suffix>` to avoid having a direction proxy to wrap
`cargo run -p xtask-<suffix>` as `cargo xtask <suffix>`.
2023-04-26 11:18:51 -05:00
Eric Huss a4f01c0352 Update home dependency 2023-04-25 11:38:52 -07:00
Ed Page c6f8ee9e51 feat(xtask): First pass at 'cargo xtask unpublished' 2023-04-25 03:06:46 -05:00
Ed Page 0b20bd99e3 chore(xtask): Add core cargo flags 2023-04-25 02:33:47 -05:00
Ed Page a675e047e7 chore(xtask): Add xtask skeleton 2023-04-25 02:13:56 -05:00
bors a4a8bd1742 Auto merge of #12021 - ehuss:update-windows-sys, r=weihanglo
Update windows-sys

This updates the windows-sys dependency from 0.45 to 0.48. This shouldn't add or remove any duplicate dependencies (since there are other dependencies still using 0.45 and 0.42). The intent is to move it along the direction towards unifying in the future (though it seems like a moving target that will be difficult to ever hit).

This also bumps the home crate version. I think it should be OK to make the migration from winapi to windows-sys a patch version, though there seems to be some issues with the way windows-sys works that could introduce some build-time problems in some situations (such as those encountered in https://github.com/rust-lang/rust/pull/108665 and https://github.com/rust-lang/rust/pull/106610). However, I don't expect too much of an issue.
2023-04-24 11:50:26 +00:00
Eric Huss eea69e549f Bump versions of local crates 2023-04-23 13:01:29 -07:00
Eric Huss ac25009500 Update windows-sys 2023-04-23 12:40:00 -07:00
Weihang Lo ff216ebc96
chore: make `server-check` a workspace member 2023-04-21 10:58:45 +01:00
Ed Page 895435fba9 chore: Use globs for workspace members
This is a short-term option until we can have a better solution for
globbing.  This does not update `benches/` to support which has a README
in there preventing globbing; this seems low-churn enough not to find a
solution for it.

On the next sync-up with rust-lang/rust, we'll need to update 4e46301258/src/bootstrap/tool.rs (L588-L603)

Fixes #11988
2023-04-18 20:02:21 -05:00
Ed Page 943edea4a4 fix(cred): Get wincred building on all platforms 2023-04-18 09:10:20 -05:00
Ed Page b533f89c43 refactor(cred): Move win impl to inline mod 2023-04-18 09:07:17 -05:00
Ed Page 72fee8015c fix(cred): Get macos building on all platforms 2023-04-18 09:06:09 -05:00
Ed Page 2e3dde1843 refactor(cred): Move macos impl to inline mod 2023-04-18 09:05:02 -05:00
Ed Page feb6d881d8 feat(cred): Common unsupported credentials 2023-04-18 09:00:55 -05:00
bors b0742b2145 Auto merge of #11882 - hi-rustin:rustin-patch-clippy-fix, r=weihanglo
Correct the bug report for `cargo clippy --fix`
2023-04-14 07:05:37 +00: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
Kai Luo c5ed77629b AIX searches dynamic libraries in `LIBPATH`. 2023-04-13 13:20:54 +08:00
bors c429784fd5 Auto merge of #11951 - ehuss:check-token-tab, r=hi-rustin
Fix credential token format validation.

The existing validation incorrectly excluded tab because of a missing backslash. This updates to add the backslash.

This also rewords the comments. I found the current comments to be a little confusing.

This also extends the test to verify more valid inputs.

cc #11600
2023-04-10 04:02:43 +00:00
Eric Huss 35f5862979 Validate token on publish. 2023-04-09 12:15:40 -07:00
Eric Huss 57264ed433 Fix credential token format validation. 2023-04-09 11:53:46 -07:00
Alex Touchet 2ddee8c93a
Fix typo 2023-04-07 09:35:38 -07:00
Alex Touchet 91d431f95d Update repo URL 2023-04-06 15:29:11 -07:00
Eric Huss 1ee340c0a7 Don't query permutations of the path prefix. 2023-04-04 18:49:42 -07:00
Eric Huss 78970bd4a8 Update git2 2023-04-02 15:37:53 -07:00
Eric Huss c38e050fc6 Allow RegistryBuilder responder URLs to be a String
This allows tests to generate dynamic URLs for custom responders.
2023-03-31 14:04:48 -07:00
Lukas Wirth a127a0a2a8 Drop derive feature from serde in cargo-platform 2023-03-30 17:09:51 +02:00
Eric Huss 3e20ffda68 Update proptest 2023-03-25 13:13:24 -07:00
bors 16d0495d29 Auto merge of #11624 - vext01:poll-loop-fixes, r=ehuss
Poll loop fixes

### What does this PR try to resolve?

A couple of minor issues. See individual commits.

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

The existing test suite should have sufficient coverage.

### Additional information

(I have 5 apparently unrelated failures locally when running `cargo test`)
2023-03-20 12:42:45 +00:00
bors 2b901be4a1 Auto merge of #11713 - ehuss:publish-waiting-extra-info, r=epage
Add more information to wait-for-publish

This reworks the console output when waiting for a publish to be available:

* Shows a "Published" status to try to make it clear that the publish is complete, and that Cargo is moving to a separate phase.
* Removes the repeated status bars and updating messages, and uses a single progress bar to track the publish.
* Provides more of a description of why Cargo is waiting to try to make it clearer what is happening.
* Provides more information when a timeout happens to try to explain what might be happening.
* Shows a "Completed" message at the end to let the user know that everything is complete.

Comparing the output:

Before (with git):

```
    Updating crates.io index
   Packaging delay v0.0.2 (/Users/eric/Proj/rust/cargo/target/tmp/cit/t0/foo)
    Packaged 3 files, 761.0B (569.0B compressed)
   Uploading delay v0.4.27 (/Users/eric/Proj/rust/cargo/target/tmp/cit/t0/foo)
    Updating crates.io index
     Waiting on `delay` to propagate to crates.io index (ctrl-c to wait asynchronously)
    Updating crates.io index
    Updating crates.io index
    Updating crates.io index
    Updating crates.io index
    Updating crates.io index
    Updating crates.io index
    Updating crates.io index
    Updating crates.io index
    Updating crates.io index
    Updating crates.io index
```

Before (with sparse):

```
    Updating crates.io index
   Packaging delay v0.0.2 (/Users/eric/Proj/rust/cargo/target/tmp/cit/t0/foo)
    Packaged 3 files, 761.0B (569.0B compressed)
   Uploading delay v0.0.2 (/Users/eric/Proj/rust/cargo/target/tmp/cit/t0/foo)
    Updating crates.io index
     Waiting on `delay` to propagate to crates.io index (ctrl-c to wait asynchronously)
       Fetch [=============================>   ] 36 complete; 1 pending
```

New (git or sparse):

```
    Updating crates.io index
   Packaging delay v0.0.2 (/Users/eric/Proj/rust/cargo/target/tmp/cit/t0/foo)
    Packaged 3 files, 761.0B (569.0B compressed)
   Uploading delay v0.0.2 (/Users/eric/Proj/rust/cargo/target/tmp/cit/t0/foo)
    Uploaded delay v0.0.2 (/Users/eric/Proj/rust/cargo/target/tmp/cit/t0/foo)
note: Waiting for `delay@0.0.2` to be available at registry `crates-io`.
You may press ctrl-c to skip waiting; the crate should be available shortly.
     Waiting [===>                       ] 11/60
   Published delay v0.0.2 (/Users/eric/Proj/rust/cargo/target/tmp/cit/t0/foo) has been successfully published to registry `crates-io`
```

(Note: In the last two cases the progress bar disappears when it is done, I have just included it here to illustrate.)

Fixes #11304
2023-03-15 16:22:28 +00:00
Eric Huss f60666ca6e Reword published/completed to uploaded/published 2023-03-15 08:15:00 -07:00
Eric Huss 7e4764a56b Add more information to wait-for-publish 2023-03-15 08:15:00 -07:00
Eric Huss 7b19a6e8ef Add some more publish timeout tests 2023-03-15 08:15:00 -07:00
Ed Page f8f7e7cb99 docs: Address warnings
This is to help prepare for checking for doc warnings across the entire
workspace being created in rust-lang/cargo#11851

`Mutation` was made `pub`, along with its fields, but they aren't
actually usable with anything, so I went and made it private to match
what its documentation references
2023-03-14 00:45:28 -05:00
Dirkjan Ochtman 20a5d2b82f Accurately show status when downgrading dependencies 2023-03-13 13:29:30 +01:00
Weihang Lo 8296cfe547
Bump crates-io to 0.36.0
This was an overlook of https://github.com/rust-lang/cargo/pull/11600
2023-03-09 17:10:32 +00:00
Weihang Lo f3778f9193
Revert "#11738" - Use test name for dir when running tests
This reverts commit 64b0e793ce, reversing
changes made to 958078633e.
2023-03-08 15:17:48 +00:00
Andreas Hollmann 2f0ecf5425 Use sha2 to calculate SHA256 2023-03-05 00:03:28 +01:00
Sebastian Thiel cfffda9ae5
add `-Zgitoxide=fetch` feature toggle and implementation.
This allows to use `gitoxide` for all fetch operations, boosting performance
for fetching the `crates.io` index by a factor of 2.2x, while being consistent
on all platforms.

For trying it, nightly builds of `cargo` can specify `-Zgitoxide=fetch`.
It's also possible to set the `__CARGO_USE_GITOXIDE_INSTEAD_OF_GIT2=1` environment
variable (value matters), which is when `-Zgitoxide=none` can be used
to use `git2` instead.

Limitations
-----------
Note that what follows are current shortcomings that will be addressed in future PRs.

- it's likely that authentication around the `ssh` protocol will work differently in practice
  as it uses the `ssh` program.
- clones from `file://` based crates indices will need the `git` binary to serve the locatl repository.
- the progress bar shown when fetching doesn't work like the orgiinal, but should already feel 'faster'.
2023-03-02 12:35:50 +01:00
bors 80f1a5d0f7 Auto merge of #11688 - epage:minimal, r=Eh2406
feat(resolver): `-Zdirect-minimal-versions`

This is an alternative to `-Zminimal-versions` as discussed in #5657.

Problems with `-Zminimal-versions` includes
- Requires the root most dependencies to verify it and we then percolate that up the stack.  This requires a massive level of cooperation to accomplish and so far there have been mixed results with it to the point that cargo's unstable
 documentation discourages its use.
- Users expect `cargo check -Zminimal-versions` to force resolving to minimal but it doesn't as the default maximal resolve is compatible and requires `cargo update -Zminimal-versions`
- Different compatible versions might be selected, breaking interop between crates, changing feature unification, and breaking `-sys` crates without bad `links`

`-Zdirect-minimal-versions` instead only applies this rule to your
direct dependencies, allowing anyone in the stack to immediately adopt
it, independent of everyone else.

Special notes
- Living up to the name and the existing design, this ignores yanked
  crates.  This makes sense for `^1.1` version requirements but might
  look weird for `^1.1.1` version requirements as it could select
  `1.1.2`.
- This will error if an indirect dependency requires a newer version.
  Your version requirement will need to capture what you use **and** all
  of you dependencies.  An alternative design would have tried to merge
  the result of minimum versions for direct dependencies and maximum
  versions for indirect dependencies.  This would have been complex and
  led to weird corner cases, making it harder to predict.  I also suspect
  the value gained would be relatively low as you can't verify that
  version requirement in any other way.
  - This also means discrepancies between `dependencies` and `dev-dependencies` are errors
  - The error could be improved to call out that this was from minimal
    versions but I felt getting this out now and starting to collect
    feedback was more important.

One advantage of this approach over `-Zminimal-versions` is that it removes most of the problems that [cargo-minimal-versions](https://github.com/taiki-e/cargo-minimal-versions) tried to workaround.

As for the implementation, this might not be the most elegant solution but it works and we can always iterate and improve on it in the future.
- We keep the state as a `bool` throughout but compensate for that by explicitly creating a variable to abstract away constants
- The name changes depending on the context, from `direct_minimal_version` when dealing with the unstable flag to `first_minimal_version` when the concept of "direct" is lost to `first_version` when we split off the ordering concept into a separate variable
- Packages that respect `direct_minimal_versions` are determined by whether they are the top-level `summaries` that get past into `resolve`

### What does this PR try to resolve?

The primary use case is verifying version requirements to avoid depending on something newer than might be available in a dependent

For this to help the MSRV use case, the crate author must directly depend on all indirect dependencies where their latest release has too new of an MSRV but at least they can do so with the `^` operator, rather than `<` and breaking the ecosystem.

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

The first two commits add tests using `-Zminimal-versions`.  The commit that adds `-Zdirect-minimal-versions` updates the tests, highlighting the differences in behavior.

### Additional information

Potential areas of conversation for stablization
- Flag name
- Handling of yanked (pick first non-yanked, pick yanked, error)
- Quality of error message
- Should the package have a "memory" of this flag being set by writing it to the lockfile?

Potential future work
- Stablize this
- Remove `-Zminimal-versions`
- Update `cargo publish`s `--verify` step to use this.
  - The challenge is this won't be using the packaged `Cargo.lock` which probably should also be verified.
2023-03-01 19:26:59 +00:00
Scott Schafer 019aeedeb4 feat: Use test name for dir when running tests 2023-03-01 11:38:58 -06:00
Weihang Lo b9bfda596f
chore: bump jobserver to respect `--jobserver-auth=fifo:PATH`'
See https://github.com/alexcrichton/jobserver-rs/pull/49
2023-02-28 16:08:12 +00:00
hi-rustin fbe7ac2571 Update comment 2023-02-24 09:01:46 +08:00
hi-rustin 0b06a456f2 Make blocking tests non blocking 2023-02-23 09:11:52 +08:00
hi-rustin a8233d4df5 Support store public request body in the HTTP mock server 2023-02-23 09:11:52 +08:00
Eric Huss 0fcacd0e6c Scrub more environment variables from the test environment. 2023-02-22 08:56:53 -08:00
Eric Huss 969c12dc89 Sort and organize the env_remove list. 2023-02-22 08:55:29 -08:00
klensy a485a8a4b8 mdman: update pretty_assertions to reduce duplicated deps 2023-02-21 14:39:30 +03:00
akida31 823ab52f19
Address review comments
* moved `is_empty` check into `check_token`
* improved error message (is quite long now but should explain the error
  well)
* removed one helper function from new test
2023-02-16 19:12:46 +01:00
akida31 3d2e107b5a
Error on invalid token for registry auth
When using registry operations with authentication there will be now an
error if the given token is not valid.
This is a technically a breaking change because a registry might give
some tokens which will be denied by these new checks.
In practice these tokens cause issues with HTTP so no registry should
generate them.
2023-02-16 16:42:30 +01:00
Scott Schafer c3043d9a9e chore: Make dependencies alphabetical order 2023-02-15 09:22:08 -06:00
Enyium 36d3a5e467 Amend `mdman` tests.
- Revert most of changes to expected test output from commit 2a4ec9f2.
- Keep later changes to expected test output from commit 0263ef43.
- Change test input that's converted to trigger similar output as previously.
2023-02-15 12:07:53 +01:00
Ed Page 1d153f1d64 feat(resolver): `-Zdirect-minimal-versions`
This is an alternative to `-Zminimal-versions` as discussed in #5657.

The problem with `-Zminimal-versions` is it requires the root most
dependencies to verify it and we then percolate that up the stack.  This
requires a massive level of cooperation to accomplish and so far there
have been mixed results with it to the point that cargo's unstable
documentation discourages its use.

`-Zdirect-minimal-versions` instead only applies this rule to your
direct dependencies, allowing anyone in the stack to immediately adopt
it, independent of everyone else.

Special notes
- Living up to the name and the existing design, this ignores yanked
  crates.  This makes sense for `^1.1` version requirements but might
  look weird for `^1.1.1` version requirements as it could select
  `1.1.2`.
- This will error if an indirect dependency requires a newer version.
  Your version requirement will need to capture what you use **and** all
  of you dependencies.  An alternative design would have tried to merge
  the result of minimum versions for direct dependencies and maximum
  versions for indirect dependencies.  This would have been complex and
  led to weird corner cases, making it harder to predict.  I also suspect
  the value gained would be relatively low as you can't verify that
  version requirement in any other way.
  - The error could be improved to call out that this was from minimal
    versions but I felt getting this out now and starting to collect
    feedback was more important.
2023-02-14 15:44:30 -06:00
Enyium 0263ef4379 Enable smart punctuation in mdBook. 2023-02-14 08:15:29 +01:00
Enyium 2a4ec9f2f1 Update `pulldown-cmark` to next breaking version. 2023-02-14 08:15:29 +01:00
Edd Barrett 5c3825ffc5
Set non-blocking IO more robustly.
- Check for errors.
 - Add O_NONBLOCK on top of any existing flags.

set_nonblock() is adapted from lang_tester:
e01072a0a4/src/tester.rs (L1041-L1048)
2023-01-25 12:15:14 +00:00
Edd Barrett 493ca3364a
Fix incorrect comment.
The event loop uses poll(2), not select(2).
2023-01-25 12:15:14 +00:00
Eric Huss 9247e8155f Fix unused attribute on Windows. 2023-01-22 14:02:23 -08: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
bors 35e45fd2e4 Auto merge of #11699 - epage:warn, r=ehuss
Deny warnings in CI, not locally

### What does this PR try to resolve?

The problem with #![deny(warnings)] is it makes iteration more difficult as you might have intermediate states with warnings. Its slightly better that we defer this to cargo test --lib but that still means you can't run a subset of tests against your experiment until you've cleaned up all of your warnings. This can lead to users [working around the problem which could accidentally slip in](d92d04840c).

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

The first round for this PR includes a warning in the `cargo` crate to ensure it breaks CI.  It will then be reverted.

### Additional information

See also https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/.60.23!.5Bcfg_attr.28test.2C.20deny.28warnings.29.29.5D.60
2023-02-11 18:12:10 +00:00
Ed Page d52f29897a chore: Deny warnings across entire cargo repo 2023-02-10 16:17:33 -06:00
Eric Huss 7a67332d3c Update 1password to the version 2 CLI 2023-02-08 21:08:17 -08:00
bors f9c267bfe9 Auto merge of #11656 - attila-lin:dev/windows, r=epage
Replace `winapi` with `windows-sys` crate.

### What does this PR try to resolve?

replace `winapi` with `windows-sys` crate.

It's officially maintained.

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

I just do the replacement of API. I think it is quite clear.

And I found a `cfg` for `windows` may miss checked error.

### Additional information

No one.
2023-02-01 03:01:55 +00:00
Eric Huss 2878129d09 Update cross test instructions for aarch64-apple-darwin 2023-01-31 11:41:20 -08:00
hzlinyiyu bf10d8d36b more 2023-01-31 23:16:12 +08:00
hzlinyiyu f89e58f300 MORE 2023-01-31 22:40:28 +08:00
hzlinyiyu 8342c1e9f2 more 2023-01-31 20:12:58 +08:00
hzlinyiyu d9537b8187 fix 2023-01-31 19:14:45 +08:00
hzlinyiyu ae91d4ed41 do some clean up 2023-01-31 18:02:57 +08:00
bors 99b13692dd Auto merge of #11572 - khuey:dwp, r=weihanglo
Make cargo aware of dwp files.

When using -Csplit-debuginfo=packed on Linux, rustc will produce a dwp file. Unlike the dwo files, whose paths are embedded into the binary, there's no information in the binary to help a debugger locate a dwp file. By convention, the dwp file for `<EXE>` is given the name `<EXE>.dwp` and placed next to `<EXE>`.

When cargo hardlinks the executable file rustc put in target/debug/deps into target/debug, it also needs to hardlink the dwp file along with it. Failing to do this prevents the debugger from finding the dwp file when the binary is executed from target/debug, as there's no way for the debugger to know to look in the deps subdirectory.

The split_debuginfo option is passed down into file_types to make this possible. For cargo clean manual handling is added to match the other split_debuginfo files. bin_link_for_target also passes in None because it won't care about the dwp file.
2023-01-30 12:00:19 +00:00
Kyle Huey 847dc6ed06 Make cargo aware of dwp files.
When using -Csplit-debuginfo=packed on Linux, rustc will produce a dwp file.
Unlike the dwo files, whose paths are embedded into the binary, there's no
information in the binary to help a debugger locate a dwp file. By convention,
the dwp file for <EXE> is given the name <EXE>.dwp and placed next to <EXE>.

When cargo hardlinks the executable file rustc put in target/debug/deps into
target/debug, it also needs to hardlink the dwp file along with it. Failing to
do this prevents the debugger from finding the dwp file when the binary is
executed from target/debug, as there's no way for the debugger to know to look
in the deps subdirectory.
2023-01-14 23:11:57 -08:00
Eric Huss 4cb9ac35bf Add network container tests 2023-01-14 15:10:16 -08:00
bors abc6abe34d Auto merge of #11561 - epage:typos, r=ehuss
chore: Fix typos

Seeing several typo PRs, like #11560, I figured I'd run my source code spell checker on cargo to help catch a lot of these earlier, in one big batch.
2023-01-11 14:15:24 +00:00
Ed Page ed8b85f10e chore: Fix typos 2023-01-10 20:03:11 -06:00
bors 0849a28cc2 Auto merge of #11556 - pietroalbini:cve-2022-46176, r=weihanglo
Add fix for CVE-2022-46176

r? `@ehuss`
2023-01-10 17:26:08 +00:00
Eric Huss 1387fd4105
Validate SSH host keys 2023-01-10 14:36:22 +01:00
Weihang Lo 3d862d8d8b
by default saves credentials to `.cargo/credentials.toml` 2023-01-04 16:25:52 +00:00
bors dd9900585a Auto merge of #11407 - dnbln:reasons-for-rebuilding, r=weihanglo
Reasons for rebuilding
2022-12-30 13:25:46 +00:00
bors 7fb01c68c1 Auto merge of #10771 - Eh2406:asymmetric_tokens, r=ehuss
Asymmetric tokens

Builds on and is blocked by #10592. This adds initial support for Asymmetric Tokens #10519.
2022-12-29 16:39:06 +00:00
Dinu Blanovschi 0beb5fe93d Simple explanations for why cargo rebuilds crates 2022-12-28 16:27:50 +01:00
Jacob Finkelman cd967098ea Indentation and spelling 2022-12-19 19:08:48 +00:00
Julien Merzoug Cosnuau 4db4a13662 Fix typo 2022-12-16 22:02:41 +01:00
Jacob Finkelman 5e709d45f1 add comment to Mutation 2022-12-14 20:50:51 +00:00
Jacob Finkelman 29ff25f6d9 cleanups round 1 2022-12-13 23:49:07 +00:00
Jacob Finkelman 2ac15086fb end-to-end tests 2022-12-12 21:50:08 +00:00
Jacob Finkelman 6d1c07bcc5 Send asymmetric tokens with mutations 2022-12-12 20:11:26 +00:00
Lucio Franco ac9da4b193 home: Remove github ci, link license, remove others 2022-12-12 13:52:23 -05:00
Lucio Franco 6a1a9edd40 Merge branch 'homemerge' into lucio/home-crate 2022-12-12 13:46:59 -05:00
Lucio Franco dbb8dada19 Add crate 2022-12-12 13:46:41 -05:00
Ed Page 48895b1681 fix: Move off atty to resolve soundness issue
There is a soundness issue with atty when building on Windows with a
custom allocator.

This PR switches direct dependencies on atty to is-terminal.  New semver
compatible versions of clap and snapbox remove atty. #11417 upgrades
env_logger to remove it from there.

Fixes #11415
2022-11-25 06:28:01 -06:00
bors de56c1251b Auto merge of #10343 - willcrichton:example-analyzer, r=weihanglo
Change rustdoc-scrape-examples to be a target-level configuration

This PR addresses issues raised in rust-lang/cargo#9525. Specifically:
1. It enables examples to be scraped from `#[test]` functions, by passing additional flags to Rustdoc to ensure that these functions aren't ignored by rustc.
2. It moves the `arg` from `-Z rustdoc-scrape-examples={arg}` into a target-level configuration that can be added to Cargo.toml.

The added test `scrape_examples_configure_target` shows a concrete example. In short, examples will be default scraped from Example and Lib targets. Then the user can enable or disable scraping like so:

```toml
[lib]
doc-scrape-examples = false

[[test]]
name = "my_test"
doc-scrape-examples = true
```
2022-11-25 06:58:20 +00:00
Expyron bb837662d8 chore: Upgrade miow 2022-11-18 14:08:46 +01:00
Arlo Siemsen 9827412fee Implement RFC 3139: alternative registry authentication support 2022-11-16 14:36:19 -06:00
Will Crichton 39e6737de7 Change rustdoc-scrape-examples to be a target-level configuration 2022-11-16 09:18:33 -08:00
Weihang Lo 054a19ba2f
Bump crate `crates-io` to 0.35.0 2022-11-13 10:55:15 +00:00
Weihang Lo 851492c788
Bump crate `cargo-util` to 0.2.3 2022-11-13 10:55:10 +00:00
RyanAD eb8d3e2932 simplify `join_paths` error message and add test 2022-11-12 18:44:22 -07:00
RyanAD 730e8ca46d make call to `paths::join_paths` and warn if path contains invalid chars 2022-11-12 18:43:46 -07:00
RyanAD 23c1a51ad0 Improve error message in `join_paths` when env contains a path separator 2022-11-12 18:43:37 -07:00
hi-rustin 6de9ed11be Fix not a hyperlink warnings
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-11-10 08:52:32 +08:00
Arlo Siemsen 90c6b5854d Fix waiting for publishing to complete when publishing to a sparse registry 2022-11-08 18:14:52 -06:00
bors 9286a1beba Auto merge of #11328 - epage:upgrade, r=weihanglo
chore: Upgrade dependencies

This upgrades several dependencies to the latest "major" release.  The original intent was just to get onto the latest snapbox but I noticed several others that could be updated and thought "why not".

- `snapbox` broke compatibility on less used APIs
- Its unclear from the docs if `miow` or `remove_dir_all` even broke compatibility

I did not touch `mdman` as that has several large, stale deps
2022-11-04 06:41:49 +00:00
Ed Page 8d6a828c18 chore: Upgrade miow 2022-11-03 19:59:25 -05:00
Eric Huss fa8375b3c9 Remove remove_dir_all 2022-11-03 16:51:48 -07:00
Ed Page 25f838bfb7 chore: Upgrade snapbox 2022-11-02 23:15:48 -05:00
bors 352175f810 Auto merge of #11285 - jonhoo:cargo-env, r=weihanglo
Make cargo forward pre-existing CARGO if set

Currently, Cargo will always set `$CARGO` to point to what it detects its own path to be (using `std::env::current_exe`). Unfortunately, this runs into trouble when Cargo is used as a library, or when `current_exe` is not actually the binary itself (e.g., when invoked through Valgrind or `ld.so`), since `$CARGO` will not point at something that can be used as `cargo`. This, in turn, means that users can't currently rely on `$CARGO` to do the right thing, and will sometimes have to invoke `cargo` directly from `$PATH` instead, which may not reflect the `cargo` that's currently in use.

This patch makes Cargo re-use the existing value of `$CARGO` if it's already set in the environment. For Cargo subcommands, this will mean that the initial invocation of `cargo` in `cargo foo` will set `$CARGO`, and then Cargo-as-a-library inside of `cargo-foo` will inherit that (correct) value instead of overwriting it with the incorrect value `cargo-foo`. For other execution environments that do not have `cargo` in their call stack, it gives them the opportunity to set a working value for `$CARGO`.

One note about the implementation of this is that the test suite now needs to override `$CARGO` explicitly so that the _user's_ `$CARGO` does not interfere with the contents of the tests. It _could_ remove `$CARGO` instead, but overriding it seemed less error-prone.

Fixes #10119.
Fixes #10113.
2022-11-02 12:38:30 +00:00
Anton Lazarev d70a4ee93c
update stderr in tests for unrelated functionality 2022-10-28 17:13:25 -07:00
Rageking8 61813d9d72 fix dupe word typos 2022-10-26 12:15:45 +08:00
Jon Gjengset 724a1977ce Make cargo forward pre-existing CARGO if set
Currently, Cargo will always set `$CARGO` to point to what it detects
its own path to be (using `std::env::current_exe`). Unfortunately, this
runs into trouble when Cargo is used as a library, or when `current_exe`
is not actually the binary itself (e.g., when invoked through Valgrind
or `ld.so`), since `$CARGO` will not point at something that can be used
as `cargo`. This, in turn, means that users can't currently rely on
`$CARGO` to do the right thing, and will sometimes have to invoke
`cargo` directly from `$PATH` instead, which may not reflect the `cargo`
that's currently in use.

This patch makes Cargo re-use the existing value of `$CARGO` if it's
already set in the environment. For Cargo subcommands, this will mean
that the initial invocation of `cargo` in `cargo foo` will set `$CARGO`,
and then Cargo-as-a-library inside of `cargo-foo` will inherit that
(correct) value instead of overwriting it with the incorrect value
`cargo-foo`. For other execution environments that do not have `cargo`
in their call stack, it gives them the opportunity to set a working
value for `$CARGO`.

One note about the implementation of this is that the test suite now
needs to override `$CARGO` explicitly so that the _user's_ `$CARGO` does
not interfere with the contents of the tests. It _could_ remove `$CARGO`
instead, but overriding it seemed less error-prone.

Fixes #10119.
Fixes #10113.
2022-10-25 13:51:27 -07:00