Commit graph

3010 commits

Author SHA1 Message Date
hi-rustin 6c9f36d99b Update not in list error message
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-10-24 22:50:25 +08:00
hi-rustin 66a8488cf6 Update error messages for tests
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-10-24 21:25:47 +08:00
bors 6e9da768f5 Auto merge of #11278 - ehuss:deleted-entry-test, r=epage
Add test for deleted index entry

This adds a test for when an entry is deleted from the index. This is done on crates.io occasionally for things like copyright takedown requests.

This behavior was tripping a debug assert which this removes. I'm not entirely certain why the debug assert is there, but I think it is not correct, since this is obviously a scenario where there might be a cached file, but the index responds with NotFound.
2022-10-24 13:14:51 +00:00
Eric Huss 5e6da66c03 Add test for deleted index entry 2022-10-22 18:20:52 -07:00
bors 071eeaf210 Auto merge of #11273 - epage:toml, r=weihanglo
fix: Remove leading newline in vendor output

This supersedes #11271
2022-10-22 01:17:55 +00:00
Ed Page a9f704aaaa fix: Remove leading newline in vendor output
This supersedes #11271
2022-10-21 12:27:21 -05:00
Arlo Siemsen 49fb8f3d88 Fix publishing with a dependency on a sparse registry 2022-10-20 17:21:32 -05:00
Basile Henry 3ff6d9e698 Add built-in alias shadowing not warning test 2022-10-13 22:22:52 +01:00
Ed Page 5f30808d00 chore: Update tests for latest clap 2022-10-13 15:16:38 -05:00
Ed Page f2fc5ca86d fix(publish): Block until it is in index
Originally, crates.io would block on publish requests until the publish
was complete, giving `cargo publish` this behavior by extension.  When
crates.io switched to asynchronous publishing, this intermittently broke
people's workflows when publishing multiple crates.  I say interittent
because it usually works until it doesn't and it is unclear why to the
end user because it will be published by the time they check.  In the
end, callers tend to either put in timeouts (and pray), poll the
server's API, or use `crates-index` crate to poll the index.

This isn't sufficient because
- For any new interested party, this is a pit of failure they'll fall
  into
- crates-index has re-implemented index support incorrectly in the past,
  currently doesn't handle auth, doesn't support `git-cli`, etc.
- None of these previous options work if we were to implement
  workspace-publish support (#1169)
- The new sparse registry might increase the publish times, making the
  delay easier to hit manually
- The new sparse registry goes through CDNs so checking the server's API
  might not be sufficient
- Once the sparse registry is available, crates-index users will find
  out when the package is ready in git but it might not be ready through
  the sparse registry because of CDNs

So now `cargo` will block until it sees the package in the index.
- This is checking via the index instead of server APIs in case there
  are propagation delays.  This has the side effect of being noisy
  because of all of the "Updating index" messages.
- This is done unconditionally because cargo used to block and that
  didn't seem to be a problem, blocking by default is the less error
  prone case, and there doesn't seem to be enough justification for a
  "don't block" flag.

The timeout was 5min but I dropped it to 1m.  Unfortunately, I don't
have data from `cargo-release` to know what a reasonable timeout is, so
going ahead and dropping to 60s and assuming anything more is an outage.

Fixes #9507
2022-10-13 12:56:40 -05:00
Ed Page 04d836fa71 feat(publish): Support 'publish.timeout' config behind '-Zpublish-timeout'
Originally, crates.io would block on publish requests until the publish
was complete, giving `cargo publish` this behavior by extension.  When
crates.io switched to asynchronous publishing, this intermittently broke
people's workflows when publishing multiple crates.  I say interittent
because it usually works until it doesn't and it is unclear why to the
end user because it will be published by the time they check.  In the
end, callers tend to either put in timeouts (and pray), poll the
server's API, or use `crates-index` crate to poll the index.

This isn't sufficient because
- For any new interested party, this is a pit of failure they'll fall
  into
- crates-index has re-implemented index support incorrectly in the past,
  currently doesn't handle auth, doesn't support `git-cli`, etc.
- None of these previous options work if we were to implement
  workspace-publish support (#1169)
- The new sparse registry might increase the publish times, making the
  delay easier to hit manually
- The new sparse registry goes through CDNs so checking the server's API
  might not be sufficient
- Once the sparse registry is available, crates-index users will find
  out when the package is ready in git but it might not be ready through
  the sparse registry because of CDNs

This introduces unstable support for blocking by setting
`publish.timeout` to non-zero value.

A step towards #9507
2022-10-13 08:53:36 -05:00
Scott Schafer 66b62d2745 test(publish): Demonstrate the impact of non-blocking publish 2022-10-13 08:40:26 -05:00
Scott Schafer 8fadfe7f33 test(registry): Allow custom_responders to call normal responders 2022-10-13 08:40:26 -05:00
bors 5788d76d68 Auto merge of #11209 - arlosi:sparse-kind, r=ehuss
Add new SourceKind::SparseRegistry to differentiate sparse registries

Refactor sparse registry to have its own `SourceKind`.
Follow up from https://github.com/rust-lang/cargo/pull/11177#issuecomment-1272395571

r? `@ehuss`
2022-10-12 21:03:19 +00:00
Arlo Siemsen d51ed05324 Fix deadlock when build scripts are waiting for input on stdin 2022-10-12 11:46:51 -05:00
bors 83a1f66d11 Auto merge of #11210 - epage:publish, r=weihanglo
refactor(tests): Prepare for wait-for-publish test changes

In #11062, we are updating `cargo publish` to wait until a package is published.   The problem is a lot of our tests will block until the timeout.  In finding the tests to update, I was originally relying on test failures from the extra output when timing out.  The problem is not all tests verify the test output so they don't fail.

This tries to update the tests to make the introduction of a timeout more obvious.
- Adding `with_stderr` where it wasn't before
- Moving away from `with_stderr_contains` for publish tests

To help with that, I made the predicates on cargo commands more consistent.

I also moved descriptions of tests to be outside of the test so I can more easily document the `registry::init` calls with what we are doing.
2022-10-11 22:59:06 +00:00
Ed Page 487d7e5268 refactor(tests): Publish using a real registry 2022-10-11 15:24:54 -05:00
Arlo Siemsen d77aef5ba4 Add configuration option for controlling crates.io protocol
`registries.crates-io.protocol` can be set to either `sparse` or `git`.
The default is `git` unless `-Z sparse-registry` is passed.
2022-10-11 14:44:09 -05:00
Arlo Siemsen 56f68168f3 Add new SourceKind::SparseRegistry to differentiate sparse registries 2022-10-11 09:26:59 -05:00
Ed Page 33ba607783 refactor(tests): Hack publish to balance testing/wait_for_publish 2022-10-10 13:10:29 -05:00
Ed Page 8995e84124 docs(tests): Clarify why a local registry is preferred 2022-10-10 13:05:56 -05:00
Ed Page 08df53ba48 refactor(tests): Be explicit about publish stderr 2022-10-10 13:03:20 -05:00
Ed Page 5e5b5325be refactor(tests): Be more explicit about publish stderr
This will help find tests timing out due to #11062
2022-10-10 12:54:32 -05:00
Ed Page 5e1a647924 refactor(tests): Consistent predicate ordering 2022-10-10 12:50:54 -05:00
Ed Page af82aa0b68 refactor(tests): Remove redundant with_status(0) 2022-10-10 12:45:46 -05:00
Ed Page 0846b8eba4 refactor(tests): Document case outside the test, rather than in
This will make it easier to document some of the lines of code
2022-10-10 12:42:53 -05:00
hi-rustin 6b24d5c761 Rename infer_package to infer_package_for_git_source
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-10-10 22:19:32 +08:00
bors 0c29d43b9a Auto merge of #11077 - weihanglo:issue-10992, r=ehuss
Config file loaded via CLI takes priority over env vars

### What does this PR try to resolve?

Fixes #10992

Behaviour changes: After this commit, config files loaded via CLI take
priority over env vars. Config files loaded via [`config-include`]
feature also get a higher priority over env vars, if the initial config
file is being loaded via CLI.

Cargo knows why it loads a specific config file with `WhyLoad` enum,
and store in the field of `Definition::Cli(…)`. With this additional data,
config files loaded via `--config <path>` get a `Definition::Cli(Some(…))`.
In contrast, `--config <value>` with ordinary values become `Definition::Cli(None)`.

The error message of the `Definition::Cli(Some(…))` is identical to
`Definition::Path(…)`, so we won't lose any path information to debug.

[`config-include`]: https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#config-include

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

Reviewing commit by commit is probably fine. The first two commits adding tests to `config-cli` and `config-include`, which exercises the expected behaviour we are going to fix in the next commits.

To check the precedence, set up a project with an extra config file, such as

```
# Expect to have a target-dir named `foo`
CARGO_BUILD_TARGET_DIR='env' cargo c --config 'build.target-dir = "cli"' --config .cargo/foo.toml

# Inside .cargo/foo.toml
[build]
target-dir = "foo"
```

### Additional information

This is a bit hacky IMO. I don't like leaking the path info to `Definition::Cli`. However, it is really tricky to provide information for deserialization before values get merged.
2022-10-09 15:24:20 +00:00
Weihang Lo e0502e4e78
test(config-include): fix typo
Co-authored-by: Jon Gjengset <jon@thesquareplanet.com>
2022-10-09 16:14:20 +08:00
Arlo Siemsen dd5134c7a5 Implement RFC 3289: source replacement ambiguity 2022-10-07 22:30:59 -05:00
bors 8743325fe0 Auto merge of #11193 - cassaundra:wrong-cargo-test, r=ehuss
Use correct version of cargo in test

Fix `cargo_remove::offline` test using wrong version of cargo in test, the local version and calling instance of cargo instead of the one being tested.

Issue discovered in #10907 after merge of  #11099.
2022-10-08 00:47:04 +00:00
Cassaundra Smith 40a387c4bd
Use correct version of cargo in test 2022-10-07 17:03:29 -07:00
bors 882c5dd830 Auto merge of #11145 - hi-rustin:rustin-patch-login, r=weihanglo
Check empty input for login

### What does this PR try to resolve?

close https://github.com/rust-lang/cargo/issues/11144
Check empty input for login.

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

- unit test
- cargo login and enter
2022-10-07 20:37:58 +00:00
bors d1a2592265 Auto merge of #11069 - arlosi:retry, r=Eh2406
Add retry support to sparse registries

Sparse (HTTP) registries currently do not respect Cargo's retry policy for http requests.

This change makes sparse registries use the same retry system as package downloads.
2022-10-07 19:56:05 +00:00
bors 3cdf1ab25d Auto merge of #11190 - epage:test, r=weihanglo
fix(test): Distinguish 'testname' from escaped arguments

When working on clap v4, it appeared that `last` and `trailing_var_arg`
are mutually exclusive, so I called that out in the debug asserts in
#4187.  Unfortunately, I didn't document my research on this
as my focus was elsewhere.

When updating cargo to use clap v4 in #11159, I found `last` and
`trailing_var_arg` were used together.  I figured this was what I was
trying to catch with above and I went off of my intuitive sense of these
commands and assumed `trailing_var_arg` was intended, not knowing about
the `testname` positional that is mostly just a forward to `libtest`,
there for documentation purposes, except for a small optimization.

So it looks like we just need the `last` call and not the
`trailing_var_arg` call.

This restores us to behavior from 531ce1321d which is what I originally
wrote the tests against.

It looks like #11159 was merged after the last beta branch was made, so we shouldn't
need to cherry-pick this into any other release.

For reviewing this, I made the test updates in the first commit, showing the wrong behavior.  The following commit fixes the behavior and updates the tests to expected behavior.

Fixes #11191
2022-10-07 17:34:03 +00:00
Arlo Siemsen dcc512b317 Add retry support to sparse registries 2022-10-07 12:00:24 -05:00
Ed Page 3dd8413f77 fix(test): Distinguish 'testname' from escaped arguments
When working on clap v4, it appeared that `last` and `trailing_var_arg`
are mutually exclusive, so I called that out in the debug asserts in
clap-rs/clap#4187.  Unfortunately, I didn't document my research on this
as my focus was elsewhere.

When updating cargo to use clap v4 in #11159, I found `last` and
`trailing_var_arg` were used together.  I figured this was what I was
trying to catch with above and I went off of my intuitive sense of these
commands and assumed `trailing_var_arg` was intended, not knowing about
the `testname` positional that is mostly just a forward to `libtest`,
there for documentation purposes, except for a small optimization.

So it looks like we just need the `last` call and not the
`trailing_var_arg` call.

This restores us to behavior from 531ce1321 which is what I originally
wrote the tests against.
2022-10-07 10:23:55 -05:00
bors aff3bb8083 Auto merge of #11177 - arlosi:sparse-lockfile, r=weihanglo
Fix sparse registry lockfile urls containing 'registry+sparse+'

The `Cargo.lock` file for alternative sparse registries incorrectly lists the url as `registry+sparse+` rather than `sparse+`.

Fixes #10963
2022-10-07 15:22:39 +00:00
Ed Page dd6228ebdb test(test): Verify escaping behavior 2022-10-07 10:08:26 -05:00
hi-rustin 6ae292100b Update cargo add test
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-10-07 19:00:14 +08:00
Cassaundra Smith 805f424535
Add tests for cargo remove 2022-10-06 13:05:42 -07:00
Arlo Siemsen 931d8cbf99 Fix sparse registry lockfile urls containing 'registry+sparse+' 2022-10-05 11:08:00 -05:00
Eric Huss fc1f5a43fb Provide a better error message when mixing dep: with / 2022-10-02 18:03:01 -07:00
hi-rustin ff575b290f Also check the token argument
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-09-29 17:01:12 +08:00
hi-rustin b3da66f65b Add tests
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-09-29 17:01:12 +08:00
Ed Page 96948f7a24 refactor(cli): Upgrade to clap v4 2022-09-28 13:32:14 -05:00
bors 928561a0c5 Auto merge of #11135 - Muscraft:remove-ref-to-project, r=weihanglo
Reduce references to `[project]` within cargo

There was an issue (#11129) with `[project]` being put in the docs but nothing else stating what `[project]` is. This was an oversight by me when writing the docs as `[project]` is still supported in cargo. [Back in 2014](86b2a2a432) `[project]` was [renamed to `[package]`](https://github.com/rust-lang/cargo/issues/3388#issuecomment-266504735), since then it has kinda sat as something that exists and is supported but not really. I brought this up in a [zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/removal.20of.20.60.5Bproject.5D.60), and it was suggested that we could show a warning when `[project]` is used in a manifest of a _top-level_ crate.

To go slightly further than this I tried to change as many references from `[project]` to `[package]` as possible. This should hopefully help with confusion between `[project]` and `[package]` in the future.

This PR also includes a cherry-picked commit from #11131 as it was having issues with bors and fits well with the changes that are being made in this PR.

This should ideally be reviewed commit by commit
2022-09-27 09:26:27 +00:00
bors f6de921a5d Auto merge of #11114 - matklad:build-falgs, r=ehuss
Iteratively construct target cfg

When setting target features via rustflags via `[build]` config key, cargo correctly propagates them to rustc (via -C flag) and to build.rs (via CARGO_CFG_TARGET_FEATURE env var).

However, if `[target.cfg]` is used instead, build.rs doesn't get the flags (rustc still gets them though).

This changes it so that cargo will call `rustc` up to two times to collect the `cfg` values, updating which flags to use on the second call based on the cfg discovered in the first call.

Closes #6858.
2022-09-27 01:08:14 +00: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
Aleksey Kladov c333b0a7be when learning target information, run a little fixedpoint iteration loop 2022-09-26 13:22:43 +01:00
jiangying 260620e755
Update test.rs 2022-09-26 15:28:16 +08:00
bors 902bb0c2fc Auto merge of #11111 - Muscraft:http-publish-not-noop, r=ehuss
Http publish not noop

Currently the `cargo-test-support` `HttpServer` is noop on publish. This was causing issues with #11062 as there is [not function registry to pull from](https://github.com/rust-lang/cargo/pull/11062#issuecomment-1241220565). [A suggested fix](https://github.com/rust-lang/cargo/pull/11062#issuecomment-1241349110) to this was to have the test `HttpServer` act like a real registry and write to the filesystem. This would allow for tests to be run over the HTTP API and not fail since there was nothing to pull from.

This PR implements that suggestion by adding a body field to `Request`, and when hitting the publish endpoint it will try and write the `.crate` and manifest information to the filesystem.
2022-09-23 00:08:26 +00:00
bors 9230e4839d Auto merge of #11113 - rdimartino:maybeworkspace-deserialize, r=epage
Improve errors for TOML fields that support workspace inheritance

Fixes #10997

This also addresses the issue with `MaybeWorkspace<VecStringOrBool>` mentioned in #10942:

```
Caused by:
  invalid type: string "foo", expected a boolean or vector of strings for key `package.publish`
```

I removed the `maybe_workspace_vec_string` deserializer in 7a50c0c718 because the error message from the inner `Vec<String>` is now surfaced, but I can revert that if it's preferable to keep those changes.

I tried to base the `deserialize` implementation off of the derived impl for an untagged enum from `cargo expand`. This approach [ultimately led me](https://github.com/serde-rs/serde/blob/v1.0.144/serde/src/private/de.rs#L218) to adding the `serde-value` dependency.
2022-09-22 20:10:33 +00:00
Scott Schafer 251a2c7915 cargo-test-support: Make publish http api write to file system 2022-09-22 10:00:49 -06:00
Weihang Lo ef7a4ef062
Dont swallow errors when checking existence of a config key 2022-09-22 10:52:39 +01:00
Weihang Lo 2c6647df80
test(alias): with malformed config no proper error emitted
This demonstrate the old behaviour that no proper error is emitted if
there is a parse error during configuration parsing.
2022-09-22 10:46:32 +01:00
bors 23ab870c50 Auto merge of #11106 - x-hgg-x:issue-7992, r=epage
Add support for relative git submodule paths

Fixes #7992.

This is a continuation of #9592, tested on Linux and Windows.

> Git allows submodules to have relative URLs, but cargo does not handle this correctly, and simply fails to update submodules as described in issue https://github.com/rust-lang/cargo/issues/7992. This PR fixes that by passing in the parent git repo url to update_submodules.

The previous PR wasn't compatible on Windows, since it used [`std::path::Path`](https://doc.rust-lang.org/std/path/struct.Path.html) for merging the parent and relative submodule urls.

This PR uses [`url::Url`](https://docs.rs/url/latest/url/struct.Url.html) instead, which has the same behavior on all platforms. It also refers to the [git documentation](https://git-scm.com/docs/git-submodule#Documentation/git-submodule.txt-add-bltbranchgt-f--force--nameltnamegt--referenceltrepositorygt--depthltdepthgt--ltrepositorygtltpathgt) for the definition of a relative git submodule path.
2022-09-21 18:09:09 +00:00
bors bee9c896c0 Auto merge of #11098 - Emilgardis:early-fail, r=epage
make unknown features on `cargo add` more discoverable

When adding an unknown feature via `cargo add -F krate/feat`, it can be easy to miss the fact that the change failed.

This fixes that by showing the following output on fail

<img width="474" alt="image" src="https://user-images.githubusercontent.com/1502855/191100141-3603cc9a-d4b6-4d6a-bbc6-41b34144b3f0.png">
2022-09-21 17:25:19 +00:00
bors a74a8d0456 Auto merge of #11122 - weihanglo:issue-11101, r=epage
Unlink old final artifacts before compilation
2022-09-21 16:43:29 +00:00
Weihang Lo bf1523b663
test: renamed uplifted artifact remains unmodified after rebuild 2022-09-21 16:02:42 +01:00
x-hgg-x 942f7f9c59 Add support for relative git submodule paths 2022-09-21 13:08:41 +02:00
Emil Gardström 1cc21b65d1
make unknown features on cargo add more discoverable 2022-09-21 08:07:16 +02:00
Ed Page 8f8a79a5a4 fix(cli): Error trailing args rather than ignore
This warning has been in for a sufficient time, requires a hack from
clap to avoid all argument ID validation, and allows users to run the
wrong command (imagine `cargo -- publish --dry-run`).

See also https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/Cargo.20ignoring.20arguments.20with.20.60cargo.20--.20check.20--ignored.60
2022-09-20 16:54:01 -05:00
Robert DiMartino 7b16e59896 Add metadata test for invalid publish field 2022-09-20 09:34:58 -04:00
Aleksey Kladov 1a07767587 add failing test for CARGO_CFG_TARGET_FEATURE
When setting target features via rustflags via `[build]` config key,
cargo correctly propagates them to rustc (via -C flag) and to build.rs
(via CARGO_CFG_TARGET_FEATURE env var).

However, if `[target.cfg]` is used instead, build.rs doesn't get the
flags (rustc still gets them though).
2022-09-20 10:56:56 +01:00
Robert DiMartino 7a50c0c718 Remove maybe_workspace_vec_string specific deserializer 2022-09-19 23:45:51 -04:00
Robert DiMartino 06c31de972 Improve errors for TOML fields that support workspace inheritance 2022-09-19 23:41:20 -04:00
Weihang Lo e997fbc794
test(config_include): take priority over env when loaded from cli 2022-09-16 15:36:44 +01:00
Weihang Lo fafb8a9dac
test(config_cli): multi-occurrence cli args with paths 2022-09-16 15:32:00 +01:00
Weihang Lo 22ac249db2
Run reach_max_unpack_size test only on debug build 2022-09-15 19:02:26 +01:00
Weihang Lo d87d57dbbd
CVE-2022-36114: add tests 2022-09-14 10:54:49 +02:00
Weihang Lo dafe4a7ea0
CVE-2022-36113: add tests 2022-09-14 10:54:47 +02:00
Ed Page be257b8b25 fix(add): Remove redundant version in build metadata cases 2022-09-12 09:51:38 -05:00
Ed Page 7ce2b7d42a fix(add): Limit 'Features as of vX.Y.Z' to when relevant
This will only show the messaeg if we didn't already show a version req
with full precision specified ... mostly.  We'll also skip it if its a
local or git dependency but we never show the version in those cases
because it doesn't matter.

The `precise_version` logic came from cargo-upgrade.
2022-09-12 09:46:22 -05:00
Ed Page 73906aeaf8 fix(add): Clarify which version the features are added for
This gives a hint to users that we might not be showing the feature list
for the latest version but the earliest version.

Also when using a workspace dependency or re-using an existing
dependency, this is a good reminder of what the version requirement is
that was selected.

However, when the user or add (the common case) selected a full
precision requirement, this is redundant.

I'm also mixed on whether the meta version should show up.

Fixes #11073
2022-09-12 09:39:47 -05:00
Dawid Ciężarkiewicz c712f08862 Do not add home bin path to PATH if it's already there
This is to allow users to control the order via PATH if they so desire.

Fix #11020
2022-09-08 09:37:41 -07:00
bors 646e9a0b9e Auto merge of #10511 - weihanglo:issue-10477, r=ehuss
Support inheriting jobserver fd for external subcommands
2022-09-02 14:29:28 +00:00
Eric Huss 23735d4c09 Rework test error handling 2022-08-27 19:23:30 -07:00
BlackHoleFox b676088572 Update non-ASCII crate name warning message 2022-08-23 14:23:59 -05:00
hi-rustin 64e3991907 Remove useless log deps and add more test for precise update
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-08-21 17:16:01 +08:00
hi-rustin f0b5bdad65 Add test for aggressive update
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-08-21 17:14:07 +08:00
Weihang Lo 52a418c516
test: ignore broken but excluded file during traversing 2022-08-20 00:56:43 +01:00
hi-rustin 99b3564d0d Update old tests
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-08-19 10:56:29 +08:00
hi-rustin a58489dfbb Add test for aggressive update
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-08-17 21:53:12 +08:00
hi-rustin f95deaafeb Warning when precise or aggressive without -p flag
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-08-17 21:53:07 +08:00
bors 9809f8ff33 Auto merge of #10944 - kcrimson-ar:master, r=epage
Improve error message for an array value in the manifest

Fixes https://github.com/rust-lang/cargo/issues/10942

The error message will be:

```
error: failed to parse manifest at `/Users/..`

Caused by:
  invalid type: string "Ky", expected an array for key `package.authors`
```
2022-08-16 22:10:06 +00:00
bors 34cba461f2 Auto merge of #10930 - ehuss:enable-windows-tests, r=weihanglo
Enable two windows tests

These two tests were disabled on Windows a long time ago. AFAICT, the reasons are no longer relevant, and it should be safe to enable these tests. See each commit for a more detailed exposition.
2022-08-11 22:30:26 +00:00
bors 1ac43cf649 Auto merge of #10968 - hi-rustin:rustin-patch-msg, r=ehuss
Improve error msg for get target runner

Actually, we'll get this config from three places. So this msg may be confusing when you set it up in `.cargo/config.toml` or pass it by `--config`.
We already printed the location of the config, so I think it's OK to change it to `configurations`.
2022-08-11 03:23:09 +00:00
hi-rustin 6bb4050552 Fix test
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-08-10 23:19:35 +08:00
bors 1fcbca84ee Auto merge of #10961 - Nemo157:skip-implicit-override, r=epage
Only override published resolver when the workspace is different

### What does this PR try to resolve?

Ensures when publishing a package that uses an implicit `resolver = "1"` to maintain an MSRV before the `resolver` key was stabilized the implicitness is retained rather than being turned into an explicit setting.

fixes #10954 (assuming that the workspace and its packages are configured with a consistent resolver)
2022-08-10 14:30:11 +00:00
Wim Looman 492358a19f
Only override published resolver when the workspace is different 2022-08-10 09:26:50 +02:00
Josh Triplett 934e79072a Only show advice to use cargo update --precise for non-local packages
Packages in the local workspace can't get updated this way; the user
just needs to point to a different source, or otherwise update the
package themselves.
2022-08-08 10:37:15 -07:00
Josh Triplett dcbb433340 Make the rust-version error recommend cargo update -p crate@ver --precise ...
People encountering a dependency with a newer `rust-version` requirement
may not know about `cargo update --precise`, or may consider alternate
approaches that may be harmful (such as pinning with a `=` dependency).

Provide specific guidance in the error message.

If the user is using `cargo install`, suggest `cargo install --locked` instead.
2022-08-08 10:37:15 -07:00
Ky Phan 8f1a75d584 Add unit test for invalid authors, refactor name 2022-08-08 22:05:43 +07:00
bors 7259757dc6 Auto merge of #10322 - eholk:reserved-windows-name, r=ehuss
Test if reserved filenames are allowed in Windows

Recent versions of Windows have removed the limitation on filenames like `aux` or `con`. This change allows the `package::reserved_windows_name` to still pass by first trying to create a file with a reserved name to see if Windows supports it. If so, it skips the rest of the test. Otherwise, we keep the same behavior as before.
2022-08-04 00:32:49 +00:00
Eric Holk e9c7544c19 Move Windows path test function to test code 2022-08-03 15:59:59 -07:00
Eric Holk f122dbbd41 Use GetFullPathNameW to test restricted names
The previous commit tests whether the current machine supports Windows
restricted names by creating a file and checking whether that succeeds.
This commit reworks this testto use GetFullPathNameW, which can be done
without having to create and remove new files.
2022-08-03 15:59:58 -07:00
Eric Holk 0adcc183bc Test if reserved filenames are allowed in Windows
Recent versions of Windows have removed the limitation on filenames like
`aux` or `con`. This change allows the `package::reserved_windows_name`
to still pass by first trying to create a file with a reserved name to
see if Windows supports it. If so, it skips the rest of the test.
Otherwise, we keep the same behavior as before.
2022-08-03 15:59:58 -07:00
akabinds 222d90b78e test checking full stderr output, with new message, resulting from a "did you mean" 2022-08-03 11:38:41 -05:00
akabinds 8f5f2ed2a2 implement test checking if stderr, after using +toolchain, contains message stating that the directive is not handled by Cargo 2022-08-03 11:07:17 -05:00
akabinds 13776d2c59 Merge branch 'master' of https://github.com/rust-lang/cargo into better-no-such-subcommand 2022-08-03 10:53:47 -05:00
akabinds b1829b8dbd Merge branch 'master' of https://github.com/rust-lang/cargo into better-no-such-subcommand 2022-08-03 10:17:56 -05:00
Eric Huss 8bf7b8b89b Revert "Drop check for mingw32-make."
This reverts commit 8e35e2f044.
2022-08-03 06:59:35 -07:00
bors 333478d0aa Auto merge of #10929 - ehuss:ignore-reason, r=weihanglo
Add reasons to all ignored tests.

This adds a reason string to all `#[ignore]` attributes. This will be displayed when running the test (since 1.61), which can help quickly see and identify why tests are being ignored. It looks roughly like:

```
test basic ... ignored, requires nightly, CARGO_RUN_BUILD_STD_TESTS must be set
test build::simple_terminal_width ... ignored, --diagnostic-width is stabilized in 1.64
test check_cfg::features_with_cargo_check ... ignored, --check-cfg is unstable
test plugins::panic_abort_plugins ... ignored, requires rustc_private
```
2022-08-03 03:54:05 +00:00
binds adf5441b7a
Merge branch 'master' into better-no-such-subcommand 2022-08-02 20:47:20 -07:00
lucas 02e606d799 Grammar fixup unused patch message 2022-08-03 02:22:50 +01:00
akabinds 5f3ded124f stop mixing of newlines and \n in tests 2022-08-02 19:43:16 -05:00
akabinds 42df87409b fix formatting 2022-08-02 18:27:36 -05:00
akabinds b2f44de83d implemented requested changes; tests pass 2022-08-02 18:23:55 -05:00
Eric Huss c0be32b5de Re-enable version_works_without_rustc on windows.
This test was ignored in https://github.com/rust-lang/cargo/pull/3189
without much discussion of explaining why.

AFAICT, this test works fine on Windows on both MSVC and GNU.
Empty paths do the expected behavior (preventing cargo from running
rustc). There are some special rules on Windows about discovering the
process to run (such as searching the app's launch directory), but
I do not think that is relevant here. Confirmed by trying to run
`cargo check` in this test fails to find `rustc`.
2022-08-02 12:54:16 -07:00
Eric Huss 01747aa145 Re-enable killing_cargo_releases_the_lock on windows.
AFAICT, we do not test on these older platforms anymore.
Regardless, the test seems to work fine on 32-bit windows-gnu
on Windows 10.

See https://github.com/rust-lang/cargo/pull/3102#issuecomment-260815269
where it was originally disabled.
2022-08-02 12:30:42 -07:00
Eric Huss 7eb007ddbf Add reasons to all ignored tests. 2022-08-02 12:24:00 -07:00
akabinds ba3de81017 Merge branch 'better-no-such-subcommand' of https://github.com/akabinds/cargo into better-no-such-subcommand 2022-08-02 13:01:36 -05:00
akabinds b55e8d47a9 implemented requested changes; fixed one failing test (need to fix other) 2022-08-02 13:01:32 -05:00
bors 0fb9e85e45 Auto merge of #10918 - ehuss:fix-formats_source, r=Eh2406
Fix formats_source test requiring rustfmt.

The requirements added in #9892 that `rustfmt` must be present doesn't work in the `rust-lang/rust` environment. There are two issues:

* Cargo is run without using rustup. If you also have rustup installed, the test will fail because the `rustfmt` binary found in `PATH` will fail to choose a toolchain because HOME points to the sandbox home which does not have a rustup configuration.
* rust-lang/rust CI uninstalls rustup, and does not have rustfmt in PATH at all.  It is not practical to make rustfmt available there.

The solution here is to just revert the behavior back to where it was where it checks if it can run `rustfmt` in the sandbox. This should work for anyone who has a normal rustup installation (including Cargo's CI). If running the testsuite without rustup, then the test will be skipped.

This also includes a small enhancement to provide better error information when rustfmt fails.
2022-08-02 14:41:51 +00:00
Eric Huss e8d92919cf Disable scrape_examples_complex_reverse_dependencies 2022-08-02 06:57:34 -07:00
Eric Huss 15f9c2dc06 Fix formats_source test requiring rustfmt. 2022-08-01 21:07:19 -07:00
bors 223e84a981 Auto merge of #10844 - yerke:yerke/negative_jobs, r=ehuss
Support for negative --jobs parameter, counting backwards from max CPUs

Fixes #9217.

Continuation of https://github.com/rust-lang/cargo/pull/9221.
2022-08-01 03:41:10 +00:00
Yerkebulan Tulibergenov 767368fd02 Merge branch 'master' into yerke/negative_jobs 2022-07-31 18:21:33 -07:00
Eric Huss 8e35e2f044 Drop check for mingw32-make.
From what I can tell, it is no longer necessary on GitHub Actions.
This removes it to help simplify things.
2022-07-31 16:06:25 -07:00
Eric Huss bcf982cf24 Add missing requires_git requirements. 2022-07-31 15:19:17 -07:00
Eric Huss 9d43ffc02a Remove CARGO_TEST_DISABLE_GIT_CLI
This appears to no longer be necessary since we have migrated to
GitHub Actions.
2022-07-30 19:36:58 -07:00
Eric Huss 1c3640e05c Add requirements to cargo_test. 2022-07-30 19:36:58 -07:00
Wim Looman d953c3b2d7
Override to resolver=1 in published package 2022-07-29 16:03:05 +02:00
Ed Page 5789c12e45 fix(add): Update the lock file
This is done in the command, rather than in the op,
- To consistently construct the `Workspace`
- It is more composable as an API

A downside is we update the git dependencies a second time.

We are not rolling back on error.
- For some errors, the user might want to debug what went wrong
- Rollback adds its own complications and risks, including since its
  non-atomic

Fixes #10901
2022-07-26 14:59:07 -05:00
Ed Page 323c7bc306 test(add): Make test data valid
Resolving the manifests will fail due to inconsistencies.  This
addresses those.
2022-07-25 11:06:12 -05:00
Ed Page b5c4a765ef fix(add): Respect --locked
This is prep for #10901 to avoid the most common failure case for the
lock file.  We are assuming if the users action caused a change in the
manifes, then it will cause a change in the lock file.  This isn't
entirely true but close enough and I think these semantics can make
sense.
2022-07-25 09:52:00 -05:00
Eric Huss 8a487abedd Make the empty rustc-wrapper test more explicit. 2022-07-24 13:10:35 -07:00
Scott Schafer 2c810afda9 Stabilize workspace inheritance 2022-07-23 09:36:49 -05:00
Eric Huss cde8f6f692
Merge branch 'master' into stabilize-crate-type 2022-07-17 13:14:44 -07:00
Weihang Lo db3b5801d7
Update tests to reflect -Zmultitarget stabilization 2022-07-17 11:02:01 +01:00
bors 576356f414 Auto merge of #10668 - weihanglo:issue-10652, r=ehuss
Normalize path for `cargo vendor` output
2022-07-16 22:41:57 +00:00
Weihang Lo f128cbd5da
Stabilize --crate-type flag for cargo rust 2022-07-16 23:25:55 +01:00
bors bd5db301b0 Auto merge of #10868 - Muscraft:add-reason-for-nightly-tests, r=ehuss
add a reason to `masquerade_as_nightly_cargo` so it is searchable

When I was working on the stabilization for workspace inheritance, it was very tedious to find all of the places to remove `.masquerade_as_nightly_cargo()`. I [suggested](https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/problems.20finding.20.60.2Emasquerade_as_nightly_cargo.28.29.60) to add a reason to `.masquerade_as_nightly_cargo()` so that it would be easier to find all of the places to remove it. By adding the reason it makes it easy to search for all places with the features name. This PR adds the reason(s) to all of the places `.masquerade_as_nightly_cargo()` is called, as well as updates the documentation so it talks about adding a reason when making the call.
2022-07-16 18:36:58 +00:00
Scott Schafer c239e407e7 add a reason to masquerade_as_nightly_cargo so it is searchable 2022-07-15 21:32:23 -05: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 4bc8fe85bd remove unneeded nightly flags from various tests 2022-07-14 19:55:44 -05:00
Scott Schafer 22721597f7 remove .masquerade_as_nightly_cargo() from build_script_extra_link_arg.rs 2022-07-14 15:05:33 -05:00
bors 8827baaa78 Auto merge of #10862 - Muscraft:workspace-selection-test, r=epage
Add a test for regressions in selecting the correct workspace root

This adds a test to check for regressions in selecting the correct workspace when there are nested workspaces.

#10846 solved a problem with nested workspace resolution that was caused by #10776. `@ehuss` [suggested](https://github.com/rust-lang/cargo/pull/10846#issuecomment-1183754728) that a test should be added to ensure that this issue does not pop up again.

I ensured that this worked by testing against commit before #10846. Sporadically I would get an error that was the same as described in #10846.
```
error: package `{path}/cargo/target/tmp/cit/t0/foo/sub/foo/Cargo.toml` is a member of the wrong workspace
expected: {path}/cargo/target/tmp/cit/t0/foo/sub/Cargo.toml
actual:   {path}/cargo/target/tmp/cit/t0/foo/Cargo.toml
```
I then tested it on the commit with the fix and the test passed every time.

---

While this does add a test to catch any regression I am worried that it will not catch it every time.  It was noted in #10846 that this error would sometimes happen but not every time, in my testing I found this to be true as well. Since this is caused by the `HashMap` order changing each run, switching to something ordered like `BTreeMap` **_should_** catch any regressions every run (if the implementation were to ever change). I'm not sure if this is necessary so I figured I would note the concern here.
2022-07-14 02:56:51 +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
Ed Page b78f91831e test(add): Ensure comments are preserved
A comment on killercup/cargo-edit#15 had me worried that `cargo add` was
deleting comments now.  It appears that isn't the case for inline
tables.

Standard tables however do delete comments.  The work to make sure they
don't conflicts with another need.  When changing the source, we delete
the old source fields and append the new which can cause some formatting
to be carried over unnecessarily.

For example, what would normally look like
```toml
cargo-list-test-fixture-dependency = { optional = true, path = "../dependency", version = "0.0.0" }
```
When fixed to preserve comments with my naive solution looks like
```toml
cargo-list-test-fixture-dependency = { optional = true , path = "../dependency", version = "0.0.0" }
```
Note that `optional = true` used to be last, so space separating it and
`}` was kept, now separating it and `,`.

More work will be needed to get this into an ideal state but we can at
least have confidence with inline tables for now.
2022-07-13 13:38:10 -05:00
Yerkebulan Tulibergenov 2a75b44bc5 fix the test 2022-07-10 16:31:24 -07:00
Yerkebulan Tulibergenov dc23d97d5b Merge branch 'master' into yerke/negative_jobs 2022-07-10 14:20:26 -07:00
Eric Huss 79d7dc0e49 Update terminal-width flag. 2022-07-08 07:57:40 -07:00
Eric Huss c46e57b0cf Fix corrupted git checkout recovery. 2022-07-05 21:02:08 -07:00
Ed Page 18f7dfe0f5 fix(add): Don't panic with --offline
For some reason, I defined my own `--offline` flag and it didn't get
updated with the global `--offline` flag, so it started failing.

Fixes #10814
2022-07-02 23:04:00 -05:00
Urgau 23f59d4eeb Add regression tests for check-cfg unstable config 2022-06-29 14:52:20 +02:00