Commit graph

5674 commits

Author SHA1 Message Date
bors 4f70d1781a Auto merge of #13213 - stupendoussuperpowers:mulpack-features-git, r=epage
`cargo add` - fix for adding features from repository with multiple packages.

Fixes #13121

As discussed in the issue, when using `cargo add` to add a package with features from a git repository from one of it's members, the command might fail due to improper target for querying for said features.

This PR adds a test for this edge-case where we expect it to fail with current code. It also adds a fix for this, and updates the test to expect success.

While populating available features, the current code does a `Fuzzy` search which might lead to searching for features in a wrong member package. If we change it to an `Exact` query, we get back the proper member to search within.
2023-12-29 18:46:27 +00:00
cui fliter 5c7fbd80f2 Remove repetitive words
Signed-off-by: cui fliter <imcusg@gmail.com>
2023-12-29 13:55:24 +08:00
sanchit e46d80e24e Fixes #13121: Use Exact query during populating features. Update test
fix target output
2023-12-29 10:03:54 +05:30
sanchit 61f6248a07 add test expecting failure: adding features from git repo w multiple packages 2023-12-29 04:54:50 +05:30
Weihang Lo 48cffc6729
fix(cargo-install): clarify --path is installation source 2023-12-26 10:42:57 -05:00
Weihang Lo 14ef091bd0
fix(cargo-install): remove imprecise install root descriptions 2023-12-26 10:42:57 -05:00
hi-rustin dec9e8cc1b Add tests for msrv check
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-12-23 13:24:53 +08:00
hi-rustin eac79ec152 Update other docs to use cargo:: syntax
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-12-23 13:17:55 +08:00
hi-rustin ed9dc44f47 Update other tests to use cargo:: syntax
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-12-23 13:17:55 +08:00
hi-rustin 9eeffbf0d7 Add some syntax tests
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-12-23 13:17:55 +08:00
hi-rustin dfb2795ffe Update build script tests to use cargo::
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-12-23 13:17:55 +08:00
hi-rustin 25365d904c Use syntax_prefix to improve error message
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-12-23 13:17:55 +08:00
hi-rustin 56fdb1d0b6 Add parse_metadata to prase metadata
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-12-23 13:17:55 +08:00
hi-rustin 9ebe3b332a Extend the build directive syntax with cargo::
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-12-23 13:17:55 +08:00
Weihang Lo a3267bfa29
refactor(util-schemas): error type for restricted_names 2023-12-20 10:38:02 -05:00
Ed Page 633929d3aa refactor(schemas): Pull out cargo-util-schemas crate
Fixes #12801
2023-12-15 13:22:25 -06:00
Ed Page 1da305301c refactor: Validate via RegistryName/PackageName 2023-12-13 13:03:27 -06:00
Ed Page db2e314077 fix: Improve registry name errors?
Because of workspace inheritance, the errors aren't the greatest
2023-12-13 11:37:08 -06:00
Ed Page 6b6eb06714 fix: Improve package name errors 2023-12-13 11:27:02 -06:00
Ed Page a3976cd47c fix: Improve profile name errors 2023-12-13 10:53:40 -06:00
Ed Page c1d9b76401 fix: Improve feature name errors
This moves feature name validation early enough in the process to get
TOML errors.
2023-12-13 10:53:40 -06:00
Ed Page a383185c38 refactor: Centralize empty name check 2023-12-13 10:46:38 -06:00
Ed Page 2db5c9dd59 fix(new): Catch empty package names earlier 2023-12-13 10:44:55 -06:00
Ed Page 9de03cd1fd fix(add): Catch empty dep name early 2023-12-13 10:43:55 -06:00
Ed Page 1791353689 fix!: Disallow empty registry names
This was allowed when switching from `toml` v0.5 to `toml_edit` which
started allowing empty keys when parsing TOML.
This mirrors the change
we made for disallowing empty feature names in #12928.
2023-12-13 10:38:37 -06:00
Ed Page 7200646a97 test: Demonstrate existing empty name errors 2023-12-13 10:38:34 -06:00
bors 5dc5118c53 Auto merge of #13156 - hi-rustin:rustin-patch-fix-nightly-test, r=epage
Remove the deleted feature test_2018_feature from the test
2023-12-12 03:04:52 +00:00
hi-rustin e540c66e09 Remove the deleted feature test_2018_feature from the test
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-12-12 10:54:29 +08:00
bors a0339b0ae3 Auto merge of #13155 - epage:lint, r=weihanglo
fix(toml)!: Disallow `[lints]` in virtual workspaces

This was missed with the initial `[lints]` implementation.

While this is a breaking change, this is aligned with ones we've done in the past.  A lot of times, we warn first.  My hope is that isn't needed this time because
- It only exists virtual workspaces so they aren't published
- It is a nop to have this which is likely to be caught
- This is so new that the number of people using it, and likely running into this case, is quite low.
2023-12-11 20:30:22 +00:00
Ed Page 66ce16c72b fix(toml)!: Disallow [lints] in virtual workspaces
This was missed with the initial `[lints]` implementation.

While this is a breaking change, this is aligned with ones we've done in
the past.  A lot of times, we warn first.  My hope is that isn't needed
this time because
- It only exists virtual workspaces so they aren't published
- It is a nop to have this which is likely to be caught
- This is so new that the number of people using it, and likely running
  into this case, is quite low.
2023-12-11 14:10:01 -06:00
bors 7688d896a8 Auto merge of #13135 - linyihai:limit-priv-to-library, r=epage
Limit exported-private-dependencies lints to libraries

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

This PR limit `exported-private-dependencies`  lint in libraray `Target`.

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

Your can checkout out 2348ac2a20edf772495349d7911938251e343bf1 and run test, it will failed and then it will be passed in the commit 2348ac2a20edf772495349d7911938251e343bf1

### Additional information
2023-12-11 17:22:22 +00:00
Lin Yihai 58c673d040 test(pub_priv): covering build.rs test 2023-12-09 17:14:10 +08:00
Lin Yihai ab13b10066 feat: limit -extern priv: to libraries 2023-12-09 16:11:05 +08:00
Lin Yihai db0c5c1d72 test(priv_dep): verify -extern priv: do not limit in lib target. 2023-12-09 16:00:35 +08:00
bors 6feabf9477 Auto merge of #13114 - weihanglo:trim-paths-explicit-cwd, r=epage
fix: explicitly remap current dir by using `.`
2023-12-08 22:38:37 +00:00
Weihang Lo fcd4221c5a
test(trim-paths): don't follow links to separate debuginfo files
For refeference:
https://sourceware.org/binutils/docs/binutils/readelf.html
2023-12-08 16:34:00 -05:00
Weihang Lo bb86adfff7
fix(trim-paths): explicit remap to current dir .
In https://github.com/rust-lang/rust/blob/87e1447aa/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs#L856
when the remap result of `work_dir` is an empty string,
LLVM won't generate some symbols for root debuginfo node.
For example, `N_SO` and `N_OSO` on macOS,
or `DW_AT_comp_dir` on Linux when debuginfo is splitted.
Precisely, it is observed that when the `DIFile` of compile unit was
provied with an empty compilation `Directory` string,
LLVM would not emit those symbols for the root DI node.

This behavior is not desired,
resulting in corrupted debuginfo and degrading debugging experience.

This is might not be a bug of `--remap-path-prefix` in rustc,
since `-fdebug-prefix-map` in clang 16 could have the same result
(`DW_AT_comp_dir` is gone when `work_dir` is remapped to an empty string).
However, in gcc 12 `fdebug-prefix-map` will return an absolute work_dir
when an empty string occurs.

To not bother whether this needs to be fixed in rustc or not,
let's fix it by always appending an explicit `.`
when `--remap-path-prefix` remaps to relative workspace root
a.k.a. where rustc is invoking.

For more on gcc/clang remap options, see
https://reproducible-builds.org/docs/build-path/
2023-12-08 15:52:06 -05:00
Weihang Lo 7cb7b47fe7
test(trim-paths): add test for each split-debuginfo options
Also demonstarte that on Linux with split-debuginfo on the remap is broken
2023-12-08 15:51:55 -05:00
Chris Denton 4ef503fc2d
Don't rely on mtime to test changes 2023-12-08 20:32:28 +00:00
Weihang Lo 985d49b916
test(trim-paths): use --config CLI to change options 2023-12-08 13:57:45 -05:00
Sebastian Thiel 189de40a6f
re-enable flaky tests thanks to update to gix-config. (#11821)
With `gix-config` now being fixed, it will properly respect `GIT_CONFIG_NOSYSTEM`
both for system-wide configuration as well as for the git installation configuration.

That way, credential helpers provided by the git installation won't be called anymore,
which prevents them from 'somehow' emitting information to stderr.

The latter was previously disabled for credential helpers, and despite
everything^1 looking like it should work, it simply didn't.

[1]: https://github.com/rust-lang/cargo/pull/13117#issuecomment-1844881287
2023-12-07 10:19:07 +01:00
Weihang Lo 7ec1367973
test: re-ignore git auth tests for gitoxide 2023-12-06 20:18:22 -05:00
bors 000d279306 Auto merge of #13125 - epage:public, r=weihanglo
fix(toml): Disallow inheriting of dependency public status

### What does this PR try to resolve?

This is a step towards rust-lang/rust#44663.  When discussing inheriting this field
for #13046, we realized that we should probably start by disallowing
inheritance.  We can always add it later.  imo the principle of what should
be inherited is what is truely common among dependencies.  For example,
we don't allow removing features.  Public should not be universally
applied and likely should be explicit so its not over-done, especially
since we can't (atm) lint for when a public dependency could be
non-public.

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

### Additional information

This reverts parts of #12817
2023-12-06 22:08:40 +00:00
bors 862e53a985 Auto merge of #13117 - Byron:enable-tests, r=weihanglo
re-enable previously disabled tests with Windows-specific fix

Related to #11821 for which this is a fix.
However, it's probably not yet the optimal solution, depending on how `stderr` of subprocesses should be handled.

### Tasks

* [x] try to fix the issue with an env var.
    - Failure, as one warning remains that seems to originate from a C# HTTP client
* [x] figure out if `stderr` should be on or off by default - on by default like before, but now one can control it.
* [x] create a new `gix` release and use it here

### Review Notes

* Personally, I think `cargo` should keep `stderr` to be inherited so users can see potentially relevant warnings or errors provided by credential helpers. Thus this is still the default, but the tests that need it explicitly disabled `stderr` of credential helpers.

----

On Windows, `gix` will call the `git-credential-manager, but with
`stderr` set to `inherit` which makes any errors visible to the user,
just like `git` does.

```
1   1         Updating git repository `https://foo.bar/foo/bar`
    2    +warning: auto-detection of host provider took too long (>2000ms)
    3    +warning: see https://aka.ms/gcm/autodetect for more information.
    4    +fatal: A task was canceled.
    5    +warning: auto-detection of host provider took too long (>2000ms)
    6    +warning: see https://aka.ms/gcm/autodetect for more information.`
````

This, however, isn't what's desirable in tests sometimes, nor may
it be desirable in Cargo.

For now, it seems easiest to disable this particular feature that
issues the warning messages, even though a future `gix` update
should allow to control what to do with `stderr`.
2023-12-06 19:04:36 +00:00
Sebastian Thiel 49c48b88cc
re-enable previously disabled tests (#11821)
On Windows, `gix` will call the `git-credential-manager, but with
`stderr` set to `inherit` it makes any errors visible to the user,
just like `git` does.

```
1   1         Updating git repository `https://foo.bar/foo/bar`
    2    +warning: auto-detection of host provider took too long (>2000ms)
    3    +warning: see https://aka.ms/gcm/autodetect for more information.
    4    +fatal: A task was canceled.
    5    +warning: auto-detection of host provider took too long (>2000ms)
    6    +warning: see https://aka.ms/gcm/autodetect for more information.`
````

This, however, isn't what's desirable in tests sometimes, nor may
it be desirable in Cargo.

In the latest version of `gix`, it's possible to control `stderr`
which is now set on a per-test basis.

Also note that for `cargo` as a whole the default didn't change,
and stderr of spawned helper programs will remain visible in the
enclosing terminal.
2023-12-06 17:09:17 +01:00
bors 9787229614 Auto merge of #12933 - epage:pkgid-spec, r=weihanglo
feat(spec): Extend PackageIdSpec with source kind + git ref for unambiguous specs

### What does this PR try to resolve?

This tries to add just enough information to Package ID Specs that we can be sure they are unambiguous.  On its own thats important but this will unblock #12914 so we can have a user-facing ID that can be used with cargo's CLI.

More specifically, this adds
- `git+`, etc prefixes to the scheme
  - These were previously stabilized for `cargo metadata`s source id urls
  - Like with `SourceID`, this will allow `PackageIDSpec` to generate `directory+` and `local-registry+` prefixes but not parse them.  I'm assuming that the layers where those are dealt with they won't appear here but I don't have enough experience with them
- git ref query strings for URLs

Things from `SourceID` that this does not include
- precise: this seems less related to matching (e.g. ignored for `impl Ord for SourceId`)
- canonical URL for git kinds: this could be nice for users but users aren't the target audience and we can switch to these later

Fixes #10256

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

Per-commit

### Additional information
2023-12-06 02:29:23 +00:00
bors 0124d280ff Auto merge of #13118 - weihanglo:object-works-macos, r=epage
test(trim-paths): assert `OSO` and `SO` cannot be trimmed
2023-12-06 01:50:28 +00:00
Ed Page 00557a2a77 fix(toml): Disallow inheriting of dependency public status
This is a step towards #44663.  When discussing inheriting this field
for #13046, we realized that we should probably start by disallowing
inheritance.  We can always add it later.  imo the principle of what should
be inherited is what is truely common among dependencies.  For example,
we don't allow removing features.  Public should not be universally
applied and likely should be explicit so its not over-done, especially
since we can't (atm) lint for when a public dependency could be
non-public.

This reverts parts of #12817
2023-12-05 17:00:01 -06:00
Weihang Lo a4c607cde4
test(trim-paths): assert OSO and SO cannot be trimmed
See
* rust-lang/rust issue 117652
* rust-lang/rust issue 116948
2023-12-05 17:58:32 -05:00
bors a5fa676731 Auto merge of #13097 - epage:schemas, r=ehuss
refactor(schemas): Pull out mod for proposed schemas package

Originally for #12801 we talked about a `cargo-util-manifest-schema` package
- `util` in the name to not clash with plugins
- manifest specific to keep the scope down

The problem is we have types that aren't manifest specific, like
- `PartialVersion` (currently slated for `cargo-util-semverext`)
- `RustVersion`
- `PackageIdSpec`
- `SourceKind` (soon)

Things get messy if we try to break things down into common packages. Instead, I think it'd be useful to have a schemas package that has mods for each type of schema, re-exporting what is needed.

Normally, componentizing your package by the layer in the stack is a recipe for pain.
I don't think that'll apply here because these are meant to be so low level.

The other big concern could be compile times.  My hope is it won't be too bad.

So this moves the `util/toml` types into the module and we can add more in the future.
2023-12-05 00:15:22 +00:00