Commit graph

4362 commits

Author SHA1 Message Date
Eric Huss fdeb38b903 Fix documenting with undocumented dependencies. 2022-01-24 17:10:05 -08:00
bors 58790d3b5e Auto merge of #10305 - weihanglo:issue-10268, r=alexcrichton
do not compile test for bins flagged as `test = false`

### What does this PR try to resolve?

Fixes #10268

#6683 introduced a behavior that compiles all bin targets, but for bins with `test = false` they shouldn't be compiled with `--test` as testbins.

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

In the first commit of this PR, I refines the test `test_filtered_excludes_compiling_examples` to reflect the current wrong behavior (test passed). The following two commits correct the behavior and the test accordingly. The last few commits encapsulate scattered target selection logic into functions on `CompileFilter`.
2022-01-20 15:07:43 +00:00
bors bb96b3a3e8 Auto merge of #10086 - epage:toml, r=ehuss
Port cargo from toml-rs to toml_edit

Benefits:
- A TOML 1.0 compliant parser
- Unblock future work
  - Have `cargo init` add the current crate to the workspace, rather
    than error
  - #5586: Upstream `cargo-add`

TODO
- [x] Analyze performance and address regressions
- [x] Identify and resolve incompatibiies
- [x] Resolve remaining test failures, see
      https://github.com/ordian/toml_edit/labels/cargo
- [x] ~~Switch the code from https://github.com/rust-lang/cargo/pull/10176 to only parse once~~ (this PR is being merged first)
2022-01-20 03:56:18 +00:00
Eric Holk 1683cd5eec Refactor create_empty_config to create_default_config 2022-01-19 08:45:03 -08:00
Eric Holk 40c51392dd Fix new::git_default_branch with different default
The test new::git_default_branch would fail if the current user had
already configured a different default branch.

This patch changes the test to first write a .gitconfig file with the
default branch set to master. This puts us in a state where we still
have the old default, and then the subsequent change to the config file
will make sure that config changes are still respected.
2022-01-18 14:51:21 -08:00
Weihang Lo bee3534f27
test: do not compile test for bins flagged as test = false 2022-01-19 03:36:53 +08:00
Weihang Lo f07dcd13a0
test: compile all bins when TESTNAME arg exists
This behavior is not correct should be fixed.
Update this test only for pointing out the current behavior.
2022-01-19 02:47:30 +08:00
bors 95bb3c92bf Auto merge of #10243 - hi-rustin:rustin-patch-collision, r=ehuss
Error when setting crate type of both dylib and cdylib in library

close https://github.com/rust-lang/cargo/issues/10231

Error when setting crate type of both dylib and cdylib in library. Cargo can't support that at this time, since they both output the same filename.
2022-01-18 17:39:35 +00:00
hi-rustin 3738002e43 Error when setting crate type of both dylib and cdylib in library
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-01-16 17:38:43 +08:00
Eric Huss a25d3864d9 Bump to 0.61.0 2022-01-14 10:57:54 -08:00
maxwase 2623af0c43 Use is_symlink() method 2022-01-14 00:36:24 +03:00
Ed Page 320c279f43 Port cargo from toml-rs to toml_edit
Benefits:
- A TOML 1.0 compliant parser
- Unblock future work
  - Have `cargo init` add the current crate to the workspace, rather
    than error
  - #5586: Upstream `cargo-add`
2022-01-13 09:27:27 -06:00
bors e77c0719fd Auto merge of #10269 - ehuss:stabilized-new-features, r=alexcrichton
Stabilize namespaced and weak dependency features.

This stabilizes the namespaced and weak dependency features.  Support is now enabled on crates.io, so this should be ready to go.

As a part of this change, the new feature resolver is now enabled all of the time. This is fairly risky, since there are likely edge cases that haven't been exercised.
NOTE: Projects using `resolver="1"` *should* continue to have the same behavior, the old resolver behavior is emulated.

Closes #8813
Closes #8832
2022-01-12 15:15:09 +00:00
bors 06b9d31743 Auto merge of #10265 - epage:clap-port, r=joshtriplett
Port cargo to clap3

### What does this PR try to resolve?

This moves cargo to the latest major version of clap.

This supersedes #10259  and #10262

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

For testing, I mostly relied on existing tests.  I did manually validate that `cargo run <non-escaped command args>` behaved the same between both
```console
$ cargo run release --help
    Finished dev [unoptimized + debuginfo] target(s) in 0.22s
     Running `target/debug/cargo-release release --help`
cargo-release 0.18.8
...

$ cargo run --manifest-path ../cargo/Cargo.toml -- run release --help
    Finished dev [unoptimized + debuginfo] target(s) in 0.05s
     Running `/home/epage/src/personal/cargo/target/debug/cargo run release --help`
    Finished dev [unoptimized + debuginfo] target(s) in 1.31s
     Running `target/debug/cargo-release release --help`
cargo-release 0.18.8
...
```

For reviewing, I split out each deprecation resolution into a separate commit so its easy to focus on more mechanical changes (most of the deprecation fixes) from interesting ones (the port, the `Arg::multiple` deprecation)

### Additional information

- One parser change found by `cargo_config::includes` is that clap 2
  would ignore any values after a `=` for flags.
  `cargo config --show-origin` is a flag but the test passed `--show-origin=yes` which
  happens to give the desired result for that test but is the same as
  `--show-origin=no` or `--show-origin=alien-invasion`.
- `ArgMatches` now panics when accessing an undefined argument but clap
  takes advantage of that for sharing code across commands that have
  different subsets of arguments defined.  I've extended clap so we can
  "look before you leap" and put the checks at the argument calls to
  start off with so its very clear what is tenuously shared.  This
  allows us to go in either direction in the future, either addressing
  how we are sharing between commands or by moving this down into the
  extension methods and pretending this clap feature doesn't exist
- On that topic, a test found clap-rs/clap#3263.  For now, there is a
  hack in clap.  Depending on how we fix that in clap for clap 4.0, we
  might need to re-address things in cargo.
- `value_of_os` now requires setting `allow_invalid_utf8`, otherwise it
  asserts.  To help catch this, I updated the argument definitions
  associated with lookups reported by:
  - `rg 'values?_os' src/`
  - `rg 'values?_of_os' src/`
- clap now reports `2` for usage errors, so we had to bypass clap's
  `exit` call to keep the same exit code.
- `cargo vendor --sync` did not use `multi_opt` and so it has both
  multiple occurrences **and** multiple values.  If we want to deprecate
  this, we'll need `unstable-grouped` to be stablized (or pin our clap
  version) and ensure each group has only 1 value.
2022-01-11 23:47:29 +00:00
bors 0655dd25a0 Auto merge of #10217 - zhamlin:feat/profile-rustflags, r=ehuss
feat: support rustflags per profile

Fix for issue https://github.com/rust-lang/cargo/issues/7878
2022-01-10 16:56:16 +00:00
Zach Hamlin 68fd67319d feat: support rustflags per profile 2022-01-09 11:35:15 -06:00
Eric Huss 43a063c80a Stabilize namespaced and weak dependency features. 2022-01-06 15:56:56 -08:00
Ed Page f17ecafc24 Upgrade to Clap 3
- One parser change found by `cargo_config::includes` is that clap 2
  would ignore any values after a `=` for flags.
  `cargo config --show-origin` is a flag but the test passed `--show-origin=yes` which
  happens to give the desired result for that test but is the same as
  `--show-origin=no` or `--show-origin=alien-invasion`.
- The parser now panics when accessing an undefined attribute but clap
  takes advantage of that for sharing code across commands that have
  different subsets of arguments defined.  I've extended clap so we can
  "look before you leap" and put the checks at the argument calls to
  start off with so its very clear what is tenuously shared.  This
  allows us to go in either direction in the future, either addressing
  how we are sharing between commands or by moving this down into the
  extension methods and pretending this clap feature doesn't exist
- On that topic, a test found clap-rs/clap#3263.  For now, there is a
  hack in clap.  Depending on how we fix that in clap for clap 4.0, we
  might need to re-address things in cargo.
- `value_of_os` now requires setting `allow_invalid_utf8`, otherwise it
  asserts.  To help catch this, I updated the argument definitions
  associated with lookups reported by:
  - `rg 'values?_os' src/`
  - `rg 'values?_of_os' src/`
- clap now reports `2` for usage errors, so we had to bypass clap's
  `exit` call to keep the same exit code.

BREAKING CHANGE: API now uses clap3
2022-01-05 19:54:54 -06:00
bors 2478331215 Auto merge of #10214 - weihanglo:revert-10188-issue-9528, r=alexcrichton
Be resilient to most IO error and filesystem loop while walking dirs

Let `PathSource::walk` be resilient to most IO errors and filesystem loop.

This PR also

- Add a test validating the resilience against filesystem loop to prevent regression.
- Emit warning when filesystem loop found while walking the filesystem. This is the only way I can think of now to solve #9528

Fixes #10213.
2022-01-05 22:10:29 +00:00
Josh Triplett 65ddbbdfb3 Remove the option to disable pipelining
Cargo has had pipelining enabled by default for a long time, without
issue. Remove support for `build.pipelining = false`. (Continue parsing
the option from the config file, but ignore it.)
2022-01-05 10:25:23 -08:00
Weihang Lo d92dceaeba
Test IO error resilience while walking directories
Remove `build_script::build_script_scan_eacces`  test case because cargo
ignores it and returns its path during a `cargo build`. The caller still
has a chance to hit the IO error if they does access it.
2022-01-05 14:29:59 +08:00
bors 3897749d21 Auto merge of #10088 - joshtriplett:stabilize-strip, r=ehuss
Stabilize the `strip` profile option, now that rustc has stable `-C strip`

https://github.com/rust-lang/rust/pull/90058/ stabilized `-Z strip` as `-C strip`. Stabilize the corresponding Cargo option.

Update the documentation to move it from the unstable reference to the profiles documentation.

Update the tests to account for stabilization.
2022-01-04 17:11:34 +00:00
Josh Triplett 75e544d545 Stabilize the strip profile option, now that rustc has stable -C strip
https://github.com/rust-lang/rust/pull/90058/ stabilized `-Z strip` as
`-C strip`. Stabilize the corresponding Cargo option.

Update the documentation to move it from the unstable reference to the
profiles documentation.

Update the tests to account for stabilization, but make them no-ops on
stable/beta for now until rustc 1.58 releases.
2021-12-23 23:40:13 -08:00
Midas Lambrichts 42528799e2 Make levenshtein distance case insensitive.
When typing in a single character shortcut as a capital, it always
returns `b` as the suggestion as every one-letter abbreviation
is a lev distance 1 away from the capitalized one.
By making the levenshtein distance case insensitive, the case-mismatched
one-letter abbriviation (e.g. `C` to `c`) will be suggested, rather
than `b`
2021-12-21 12:56:28 +01:00
Weihang Lo 6f912788ed
Test cargo build being resilient to filesystem loop 2021-12-21 02:46:05 +08:00
bors b05697de66 Auto merge of #10188 - weihanglo:issue-9528, r=alexcrichton
Detect filesystem loop during walking the projects

Resolves #9528

~~This PR also adds a new dependency `same-file` but since it's already a
dependency of `cargo-util`, so nothing added actually.~~

Use `walkdir` to detect filesystem loop and gain performance boost!
2021-12-16 15:48:52 +00:00
hi-rustin 07843ed8fb add open_no_doc_crate test
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2021-12-16 22:29:32 +08:00
Eric Huss 6e568690a6 Don't document libs with doc=false 2021-12-15 15:13:54 -08:00
Weihang Lo 6fa0f01d87
Test filesystem loop during traversal
Use unordered since order of warning differs on each platform.
2021-12-15 09:42:14 +08:00
bors a359ce1607 Auto merge of #10152 - steven-joruk:quiet-config, r=ehuss
Support `term.quiet` configuration

Fixes #10128

This follows the existing support for `--verbose` and `term.verbose`.

I've renamed the related tests to be a bit clearer now there are more cases, and the existing quiet tests now prove that they hide the cargo log.

I'm unsure whether I'm supposed to regenerate the documentation as part of this?
2021-12-14 18:40:22 +00:00
bors c689f55b8c Auto merge of #10193 - sstangl:help-alias-10138, r=alexcrichton
Display alias target on 'cargo help <alias>`

```
Previously, `cargo help <alias>` resolved the alias and displayed the
help for the targeted subcommand. For example, if `br` were aliased to
`build --release`, `cargo help br` would display the manpage for
cargo-build.

With this patch, it will print "'br' is aliased to 'build --release'".
```

Addresses issue #10138.

This is my first patch to Cargo. I attempted to follow the style of the surrounding code. Please let me know if any changes are required: happy to make them. In particular, I wasn't sure if any tests exist for this path.
2021-12-14 17:50:46 +00:00
bors c87b986a5c Auto merge of #10145 - QiangHeisenberg:deprecated, r=alexcrichton
delete --host command and message

close https://github.com/rust-lang/cargo/issues/10121

The warning for this command has been around for a long time, and it seems safe to delete it now.
According to Alex's words in the issue, I think he supports deletion. I'm sorry if I misunderstood it and feel free to close it.
2021-12-14 17:07:04 +00:00
bors 0bbfc5e536 Auto merge of #10191 - weihanglo:issue-9881, r=alexcrichton
Improve I/O error message for fingerprint of build script

It is a bit rough but I don't think there is a network I/O error
in `pkg_fingerprint`. Checking only `io::Error` type should be fine.

Resolves #9881
2021-12-13 21:09:58 +00:00
bors 1ee19f3403 Auto merge of #10177 - ehuss:list-alias, r=alexcrichton
Explicitly mark aliases in `cargo list`.

This I think makes it a little clearer that these are aliases, and matches the form used for built-in aliases.
2021-12-13 20:26:34 +00:00
bors a4cdd757e5 Auto merge of #10171 - ehuss:no-executable-doc, r=alexcrichton
Don't emit "executable" JSON field for non-executables.

The "executable" field of JSON artifact messages was accidentally filled (with the path to `index.html`) when documenting a binary target. This fixes it so that it is null.

Closes #10149
2021-12-13 19:48:00 +00:00
bors c7db2995d0 Auto merge of #10161 - weihanglo:issue-7473, r=alexcrichton
Do not suggest source config if nothing to vendor

fixes #7473

Also remove the empty vendor dir if we've just created it but didn't vendor anything.
2021-12-13 18:26:26 +00:00
bors 3aaa8f975d Auto merge of #10172 - ehuss:doc-lib-before-bin, r=alexcrichton
Document lib before bin.

This changes it so that documenting a library is required to finish before documenting a binary. The issue is that the binary may have intra-doc links to the library. If they are documented concurrently, then the links will sometimes fail (since it is a race).   Or, if doing `cargo doc --bins`, then the library docs wouldn't exist at all.

Note that in the tests this introduces some more name collisions if you just run `cargo doc --bins` and there is a colliding library/binary name. There is some risk that someone might be trying to run the commands separately to get around the collision error, but I think it is unlikely.
2021-12-13 15:38:31 +00:00
Sean Stangl 4c66d18361 fix panic if an alias is defined to "" 2021-12-12 13:30:31 -07:00
Sean Stangl 6df4b1ef71 Update behavior to pass-through simple aliases
This changes the behavior so that simple aliases that directly alias a
subcommand (with no arguments) pass-through to that subcommand, while
complex aliases (with arguments) show the alias.

So for example, `cargo help b` will show the manpage for `cargo-build`,
while `cargo help my-alias`, aliased to `build --release`, will show
"`my-alias` is aliased to `build --release`".
2021-12-12 10:18:19 -07:00
Sean Stangl e77b254923 Update help::help_alias() to assert the new behavior 2021-12-11 15:31:48 -07:00
Weihang Lo 760ff62f36
Improve I/O error message for fingerprint of build script
It is a bit rough but I don't think there is a network I/O error
in `pkg_fingerprint`. Checking only `io::Error` type should be fine.
2021-12-11 08:31:24 +08:00
Steven Joruk 7ac6f53743 Code review fixes 2021-12-08 22:18:47 +00:00
Eric Huss 910569aac3 Explicitly mark aliases in cargo list. 2021-12-06 14:02:21 -08:00
bors 263b1690c2 Auto merge of #10165 - Aaron1011:stabilize-future-incompat, r=ehuss
Stabilize future-incompat-report

Depends on https://github.com/rust-lang/rust/pull/91535
2021-12-06 18:47:39 +00:00
Eric Huss 6a79008cad Don't emit "executable" JSON field for non-executables. 2021-12-05 18:39:30 -08:00
Eric Huss a09fbf2ef8 Document lib before bin. 2021-12-05 15:14:54 -08:00
bors cf474a5de7 Auto merge of #10133 - joshtriplett:release-short, r=ehuss
Support abbreviating `--release` as `-r`

Of the options people regularly pass to cargo, `--release` seems by far
the most common. Yet even on the command line, we expect people to type
out `--release`.

Add a short version `-r`, and add some tests in the testsuite that
confirm it works.
2021-12-05 19:44:23 +00:00
Aaron Hill 997bf3fffc
Stabilize future-incompat-report
Depends on https://github.com/rust-lang/rust/pull/91535
2021-12-05 14:14:32 -05:00
Weihang Lo 8a8d39a459
Do not suggest source config if nothing to vendor 2021-12-05 00:10:09 +08:00
Steven Joruk ed9ec388fd Support term.quiet configuration
This matches how users can specify `--verbose` on the command line, or
`term.verbose` in the configuration.
2021-12-03 06:25:02 +00:00