Commit graph

5610 commits

Author SHA1 Message Date
bors 60e65eefb2 Auto merge of #13046 - linyihai:cargo-add-public, r=epage
Add `--public` for `cargo add`

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

This PR want to add `--public/--no public` flag for `cargo add`

Note: this assumes we'll remove workspace inheritance support for `public` as it sounds like we'll be reverting it https://github.com/rust-lang/rust/issues/44663#issuecomment-1826474620.  If we decide to keep workspace inheritance, we'll need to come back and update this.

## How should we test and review this PR?
Most of Code were reference `cargo add --optional`, So can reviewed the new code based on the part of  `optional` code.

The new testcases were origin from the `cargo add --optional` part.
- `public` testcase:there is no dependencies and will be add `public` dependencies.
- `no_public` testcase:  there is no dependencies  and will be add `no_public` dependencies.
- `overwrite_public` testcase: the dependencies already exists but will be overwrite with `public`.
- `overwrite_no_public` testcase: the dependencies already exists but will be overwrite with `no_public`.
- `overwrite_public_with_no_public` testcase: the dependencies already marked as `no_public` and will be overwrite with `public`.
- `overwrite_no_public_with_public` testcase: the dependencies already marked as `public` and will be overwrite with `no_public`.
2023-12-01 17:33:20 +00:00
bors c192d989b3 Auto merge of #13091 - weihanglo:trim-paths-lldb, r=epage
test(trim-paths): exercise with real world debugger
2023-12-01 15:47:10 +00:00
bors 847958971b Auto merge of #13053 - linyihai:cargo-uninstall-fixed, r=weihanglo
Fixed uninstall a running binary failed on Windows

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

The problem reproduce when you try to uninstall a running binary and it will failed on Windows,  this is because that cargo had already remove the installed binary tracker information in disk,  and next to remove the running binary but it is not allowed in Windows.  And to the worst,  you can not uninstall the binary already and only to reinstall it by the `--force` flag.

### How to solve the issue?
This PR try to make the uninstall a binary more reasonable that  only after remove the binary sucessfully then remove the tracker information on binary and make the remove binary one by one.

### How should we test and review this PR?
Add testcase 0fd4fd357b
- install the `foo`
- run `foo` in another thread.
- try to uninstall running `foo` and only failed in Windows.
- wait the `foo` finish, uninstall `foo`
- install the `foo`

### Additional information
2023-12-01 15:10:56 +00:00
Lin Yihai db144c9d0a Add tracker verification for test case uninstall_running_binary 2023-12-01 22:23:40 +08:00
Weihang Lo 5c32fe0432
test(trim-paths): exercise with real world debugger 2023-12-01 08:48:24 -05:00
Lin Yihai 48c998fec7 Add detect_workspace_inherit_public test case. 2023-12-01 11:22:26 +08:00
Lin Yihai a6ca281948 chore: add lib.rs for new test cases 2023-12-01 10:21:33 +08:00
bors 1ef8575839 Auto merge of #13077 - GuillaumeGomez:filter-workspace-scrape-example, r=epage
Don't filter on workspace members when scraping doc examples

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

I confirmed locally that it fixed the issue in docs.rs.

cc `@willcrichton`
r? `@epage`
2023-11-30 16:42:35 +00:00
Guillaume Gomez 689d9a7e4f Don't filter on workspace members when scraping doc examples 2023-11-30 17:38:49 +01:00
Guillaume Gomez 95a27cdbd1 Add regression test for scraped examples in crates without [workspace] 2023-11-30 17:36:46 +01:00
Lin Yihai 1e3b4231da chore: fixed clippy 2023-11-30 15:46:02 +08:00
bors 430effa37d Auto merge of #12484 - adrianEffe:fix/error-count, r=weihanglo
Fixes error count display is different when there's only one error left

### What does this PR try to resolve?

When there's only 1 error left, the number 1 appears in the output so that it scans the same as the output when there's more than 1 error, so:

```
error: could not compile `crate` (lib test) due to 1 previous error
```
instead of the current:
```
error: could not compile `crate` (lib test) due to a previous error
```

Fixes #12390

rustc related PR [#114759](https://github.com/rust-lang/rust/pull/114759)
2023-11-29 19:07:16 +00:00
bors 07f1208a9f Auto merge of #13065 - weihanglo:remap-path-prefix-order, r=ehuss
fix: reorder `--remap-path-prefix` flags for `-Zbuild-std`

### What does this PR try to resolve?

Order of `--remap-path-prefix` flags is important for `-Zbuild-std`.
We want to show `/rustc/<hash>/library/std` instead of `std-0.0.0`.

Fixes rust-lang/rust#117839

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

Follow the steps in rust-lang/rust#117839, or run

```
CARGO_RUN_BUILD_STD_TESTS=true cargo +nightly t --test build-std
```

to verify.
2023-11-29 18:28:07 +00:00
Adrian 3e297a6803
Update test for override respects spec metadata 2023-11-29 18:47:27 +02:00
Adrian b7b5a093a1
Fix cargo errors counter 2023-11-29 18:47:14 +02:00
belovdv 6b86f93713 remove jobserver in shim for tests in testsuite/fix 2023-11-29 15:30:58 +03:00
Lin Yihai 0fd4fd357b Add test case for cargo uninstall while try to uninstalling a running Bin. 2023-11-29 17:52:22 +08:00
Weihang Lo 8709835a01
fix: reorder --remap-path-prefix flags for -Zbuild-std
Order of `--remap-path-prefix` flags is important for `-Zbuild-std`.
We want to show `/rustc/<hash>/library/std` instead of `std-0.0.0`.
2023-11-28 15:29:03 -05:00
Weihang Lo d6b46bfd37
test(trim-paths): demonstrate not work properly with -Zbuild-std 2023-11-28 15:07:10 -05:00
Lin Yihai 703446165b chore: add the missing flag for cargo add --public 2023-11-28 11:25:10 +08:00
Lin Yihai 07ba57dd8b Remove unnecessary code for cargo add --public testcases 2023-11-27 08:54:05 +08:00
Lin Yihai 509535675b Make the public/no-public next to the pair optional/no-optional 2023-11-27 08:09:54 +08:00
Lin Yihai 58e0ab825b reuse add_basic.in/lib.rs for testcase 2023-11-25 12:41:01 +08:00
Lin Yihai 9ac30323b3 Add not overwrite testcase for cargo add --public 2023-11-25 11:29:39 +08:00
Lin Yihai 7c8d997e26 Add overwrite testcase for cargo add --public 2023-11-24 15:11:51 +08:00
Lin Yihai a1a75e81c9 Update cargo add --help testcase 2023-11-24 15:04:52 +08:00
bors 65d0eb536d Auto merge of #12997 - hi-rustin:rustin-patch-cargo-test-support, r=epage
cargo-test-support: Add features to the default Cargo.toml file
2023-11-22 01:47:31 +00:00
bors 71cd3a926f Auto merge of #13016 - dtolnay-contrib:messagetype, r=ehuss
Handle $message_type in JSON diagnostics

### What does this PR try to resolve?

Unblocks https://github.com/rust-lang/rust/pull/115691.

Without this change, Cargo's testsuite fails in `doc::doc_message_format` and `metabuild::metabuild_failed_build_json`.

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

Tested with and without https://github.com/rust-lang/rust/pull/115691.

In Cargo repo: `cargo test --test testsuite`
In Rust repo: `x.py test src/tools/cargo` (separately on master and $message_type PR)
2023-11-20 15:30:57 +00:00
David Tolnay 65bb09d434
Handle $message_type in JSON diagnostics 2023-11-19 20:37:16 -08:00
Urgau 4781592e18 Fix --check-cfg invocation with zero features 2023-11-19 18:08:32 +01:00
hi-rustin 12d7818192 Add features to the default Cargo.toml file
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-11-19 22:03:57 +08:00
Eric Huss 2eac6f5c0c Fix clippy-wrapper test race condition. 2023-11-18 17:23:29 -08:00
Yerkebulan Tulibergenov e81d84cc17 feat: Add CARGO_RUSTC_CURRENT_DIR
This is an alternative to #12158's `CARGO_WORKSPACE_DIR` that was
implementing the solution to #3946 that previously discussed in the
cargo team meeting.

`CARGO_WORKSPACE_DIR` is a bit awkward to document / describe because
its the effective workspace directory of the thing being built.
If the thing being built doesn't have a workspace, it falls back to
`CARGO_MANIFEST_DIR`.

It would also be hard to take into account what the
`CARGO_WORKSPACE_DIR` would be for path dependencies into foreign
workspaces *and* it wouldn't solve the problem the user is having.

What the user really wants is the CWD of rustc when it is invoked.
This is much simpler to describe and is accurate when using a path
dependency to a foreign package.

Because the CWD is a much simpler mechanism to talk about, I figured we
could diverge from our prior consensus and make it always present,
rather than limiting it to tests.

Remaining work for #3946: get this stabilized
2023-11-17 09:25:46 -06:00
Ed Page c75c456de4 test(compiler): Make inner test names more specific
This will make it easier to verify other env variables later
2023-11-17 09:25:34 -06:00
bors 22bbc95f3c Auto merge of #12995 - linyihai:issue_11383, r=weihanglo
Exited with hard error when custom build file no existence or not in package

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

## How should we test and review this PR?
Add test `build_script_outside_pkg_root`,  this will check `custom_build.rs` existence and whether in the package root, if not then exited with a hard error

## Additional information
The code just handle the `custom build` target that i know how to test it.  Other target type is skipped.
2023-11-24 01:41:19 +00:00
Lin Yihai 75aaa40c78 Remove the unnecessary backticks 2023-11-22 11:09:55 +08:00
Lin Yihai edfbcf0a6c Return a hard error when custom build outside package 2023-11-21 11:10:46 +08:00
Lin Yihai 92ce5a2b27 Change the logging level and other improvement. 2023-11-20 12:57:26 +08:00
Lin Yihai ac1e66d947 Add testcase for custom build file warning 2023-11-17 17:11:57 +08:00
bors 9f3b4883e8 Auto merge of #12178 - weihanglo:dogfood-lints-table, r=epage
chore: dogfood Cargo `-Zlints` table feature
2023-11-16 19:40:13 +00:00
Mohammad AlSaleh 0bbabecbf3 Fix a rustflags test using a wrong buildfile name
The test seem to have always had the wrong buildfile `build.rs.rs`.

Signed-off-by: Mohammad AlSaleh <CE.Mohammad.AlSaleh@gmail.com>
2023-11-16 20:03:01 +03: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 0afd943dad Fix some test output validation. 2023-11-15 15:10:18 -08:00
bors 6658e1abe3 Auto merge of #12977 - Eh2406:bug_12941, r=epage
If the only path is a loop then counted as the shortest path.

This is a fix for #12941

This graph data structure is used to store dependency DAGs. Where each edge represents a dependency from a package to the package that fulfilled the dependency. Different parts of the resolver store this data in opposite directions, sometimes packages point at the things that depend on them other times packages point to the parents that required them. Error messages often need to report on why a package is in the graph, either by walking up toward parents or down toward children depending on how this graph is stored. #12678 unified the two different walking implementations, and replace them with a breadth first search so as to find the shortest path. This code ignored when edge pointed at a package that had already been reached, because that generally describes a longer path to an existing package.

Unfortunately, when I said this was a DAG that was a simplification. There can be cycles introduced as dev-dependencies. The existing code would reasonably ignore the cycles figuring that if we continue searching we would eventually find the root package (a package that nothing depended on). Missing the possibility that the root package created the cycle.

Now we search through the entire graph looking for a root package. If we do not find a root package we report the path to the last package we processed.
2023-11-15 16:09:00 +00:00
bors 0fcc90dc24 Auto merge of #12950 - epage:msrv, r=Eh2406
fix(resolver): Prefer MSRV, rather than ignore incompatible

### What does this PR try to resolve?

This is another experiment for #9930.

Comparing preferring over exclusively using MSRV compatible:

Benefits
- Better error messages
- `--ignore-rust-version` is implicitly sticky

Downsides
- Can't backtrack for MSRV compatible version
- Still requires workspace-wide MSRV (compared to our desired end state of declaring MSRV as yet another dependency)

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

### Additional information

Note: `--ignore-rust-version` is not yet implemented for the resolver.

This builds on #12930
2023-11-14 21:56:00 +00:00
Ed Page 0d29d3f71b fix(resolver): Prefer MSRV, rather than ignore incompatible
This is another experiment for #9930.

Comparing preferring over exclusively using MSRV compatible:

Benefits
- Better error messages
- `--ignore-rust-version` is implicitly sticky

Downsides
- Can't backtrack for MSRV compatible version
- Still requires workspace-wide MSRV (compared to our desired end state of declaring MSRV as yet another dependency)

This builds on #12930
2023-11-14 14:56:58 -06:00
Ed Page 0bc5d22285 test(resolver): Verify backtracking for MSRV resolver 2023-11-14 14:56:53 -06:00
Jacob Finkelman d19273c04d If the only path is a loop then counted as the shortest path. 2023-11-14 20:18:43 +00:00