Commit graph

17532 commits

Author SHA1 Message Date
Ed Page
1162546c8b docs(ref): Flatten the check-cfg structure 2024-05-20 09:03:15 -05:00
Ed Page
88b15d7473 docs(ref): Simplify text for link to check-cfg example 2024-05-20 09:02:16 -05:00
Ed Page
27e067c8d5 docs(ref): Fix typo on check-cfg 2024-05-20 08:59:40 -05:00
Ed Page
bea65c71ae docs(ref): Remove blog post link
Blog posts are not evergreen documentation.
2024-05-20 08:58:45 -05:00
bors
2332d7a428 Auto merge of #13935 - Urgau:local-independent-git-test, r=epage
Make `git::use_the_cli` test truly locale independent

### What does this PR try to resolve?

The current `git::use_the_cli` test part the output of Git but that output is locale dependant, making it fail on my non-english system.

Specifically this part of the test is local-dependent:
```
From [..]
 * [new ref] [..] -> origin/HEAD[..]
```

Adding the `LC_ALL=C` env to the cargo invocation solve the issue, making the test locale independent.

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

Trying putting a different `LC_ALL` locale and the test will fail without this PR and will not fail with my PR.
2024-05-20 13:28:53 +00:00
Urgau
8fdac923e8 Make git::use_the_cli test truly locale independent 2024-05-19 19:39:34 +02:00
bors
c256d74031 Auto merge of #13929 - ehuss:squelch-unittest-warnings, r=weihanglo
Silence warnings running embedded unittests.

The `util::toml::embedded::test_expand` unittests were printing warnings directly to stderr, circumventing the libtest override. They were displaying ``warning: `package.edition` is unspecified, defaulting to `2021` ``. That warning doesn't look particularly important for those tests, so this changes it to swallow the output.

We may want to have some kind of utility function for generating a GlobalContext for testing purposes that does this, since this is a repeated pattern.
2024-05-19 02:25:57 +00:00
bors
0f685f6198 Auto merge of #13930 - ehuss:squelch-git-output, r=weihanglo
Fix warning output in build_with_symlink_to_path_dependency_with_build_script_in_git

The test `build_with_symlink_to_path_dependency_with_build_script_in_git` was emitting a large warning block (in my case, about init.defaultBranch) because it was running `git` without filtering its output. It's not clear to me why this test was shelling out to `git` instead of using the built-in test support functions. From what I can tell, this should be exactly equivalent, and silences the warning output.
2024-05-19 01:23:50 +00:00
bors
198ba31be3 Auto merge of #13572 - linyihai:multi-dep-same-name, r=ehuss
Fix:  Make path dependencies with the same name stays locked

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

This is a workround based on https://github.com/rust-lang/cargo/issues/13405#issuecomment-1930496807

### How should we test and review this PR?
first commit will pass, second commit fixed it and update test.

### Additional information
2024-05-18 22:12:27 +00:00
bors
986dac36af Auto merge of #13931 - ehuss:standard_lib-no-sysroot, r=weihanglo
Temporarily fix standard_lib tests on linux.

This fixes the standard_lib tests which are broken in the latest nightly. The latest nightly now requires rust-lld to be in the sysroot for x86_64-unknown-linux-gnu. This broke these tests which were trying to verify that the standard library is not required. This temporarily removes this validation, but we should have some way of enforcing it (https://github.com/rust-lang/wg-cargo-std-aware/issues/31).

cc https://github.com/rust-lang/rust/issues/125246
2024-05-18 21:34:38 +00:00
Eric Huss
473e770cdd Temporarily fix standard_lib tests on linux. 2024-05-18 14:00:06 -07:00
Eric Huss
2e9dcdbdf5 Fix warning output in build_with_symlink_to_path_dependency_with_build_script_in_git 2024-05-18 13:19:53 -07:00
Eric Huss
369f5dea13 Silence warnings running embedded unittests. 2024-05-18 12:59:43 -07:00
Lin Yihai
ab927171ce fix: Make path dependencies with the same name stays locked 2024-05-18 12:45:11 -07:00
Lin Yihai
5c1b6313fa test: Add a test about patched re-export 2024-05-18 12:43:48 -07:00
bors
0de7f2ec6c Auto merge of #13913 - Urgau:check-cfg-lints-sub-config, r=epage
Add special `check-cfg` lint config for the `unexpected_cfgs` lint

### What does this PR try to resolve?

This PR adds a special `check-cfg` lint config for the `unexpected_cfgs` lint, as it was decided by T-cargo (in today's meeting).

The goal of this lint config is to provide a simple and cost-less alternative to the build-script `cargo::rustc-check-cfg` instruction.

```toml
[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(foo, values("bar"))'] }
```

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

I recommand reviewing commit by commit; and looking at all the new tests added in `check_cfg.rs`, I tried making them as exhaustive as I could, many of them are very similar to their non-config counterpart.

### Additional information

I didn't add *(actually removed from the 1st version of this PR)* the possibility to omit the `level` field if `check-cfg` is specified, https://github.com/rust-lang/cargo/pull/13913#discussion_r1600609229.

Regarding the implementation, I tried making it is as straight forward as possible, nothing over-engineered or complex.

r? `@epage` (or `@weihanglo` maybe)
2024-05-17 16:54:54 +00:00
bors
2b8804475d Auto merge of #13924 - weihanglo:registry, r=epage
refactor: more comments and variable rename
2024-05-17 15:05:37 +00:00
Weihang Lo
9d69986331
docs: tweak comments for patches 2024-05-17 10:27:25 -04:00
Weihang Lo
8e051a692b
refactor: rename and type-alias to clarify patch arguments 2024-05-17 00:29:02 -04:00
Weihang Lo
4e393497fa
refactor: unindent two levels for registry query function 2024-05-16 22:46:28 -04:00
Urgau
5e9ac4b314 Remove now unnecessary local-only build.rs example for check-cfg 2024-05-16 20:36:25 +02:00
Urgau
980afaabd4 Move malformatted check-cfg config warning to error
since it's always backwards compatible to go from error to warn, but not
the inverse.
2024-05-16 18:44:45 +02:00
Urgau
3335a6da1e Dogfood tests for check-cfg config of the unexpected_cfgs lint
Those new tests tries to be as exhaustive as possible while being
reasonable in the number of them. To do so we try to check for
check/doc/test/build-script/features with a the `check-cfg` config.

Many of those tests are very similar to their non-config counterpart.
2024-05-16 17:03:42 +02:00
Urgau
e6dca67a84 Add special check-cfg config for the unexpected_cfgs lint
This permits things like this to be recognized and passed to
rustc/rustdoc.

```rust
[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ["cfg(foo)"] }
```
2024-05-16 17:03:42 +02:00
Urgau
1e4857a4d9 Allow lint config to have extra custom configs
And report the unused manifest key warning for every key that we do not
use, which is currently every of them.
2024-05-16 17:03:42 +02:00
bors
8d68ed4fb2 Auto merge of #13920 - weihanglo:git-safe-directory, r=ehuss
test: set safe.directory for git repo in apache container

### What does this PR try to resolve?

Failure in container tests due to a new version of `git` package in Alpine Linux Package repository.

See also <https://github.com/rust-lang/cargo/pull/13913#issuecomment-2113712049>

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

Alpine Linux Package repository 3.19 just bumped git package to 2.43.4 from 2.43.0.
The docker image `httpd:2.4-alpine` we use in container tests failed due to the git version bump.
The `httpd` log shown that

```
240.10.0.1 - - [16/May/2024:03:52:36 +0000] "GET /repos/bar.git/info/refs?service=git-upload-pack HTTP/1.1" 500 -
[16/May/2024:03:52:36 +0000] 240.10.0.1 TLSv1.3 TLS_AES_256_GCM_SHA384 "GET /repos/bar.git/info/refs?service=git-upload-pack HTTP/1.1" -
fatal: detected dubious ownership in repository at '/repos/bar.git'
To add an exception for this directory, call:

        git config --global --add safe.directory /repos/bar.git
```

git/git@f4aa8c8bb1 is likely the commit causing problems.

So I ended up adding `git config --system --add safe.directory '*'` to the Dockerfile of apache container.
Note that we need `--system` instead of `--global` because `httpd` are running under the other user www-data, not root.
2024-05-16 13:54:54 +00:00
Weihang Lo
2fd4b440bc
test: use git clone --bare instead of manual mv 2024-05-16 00:14:12 -04:00
Weihang Lo
699f6f454d
test: set safe.directory for git repo in apache container
See f4aa8c8bb1
2024-05-16 00:14:12 -04:00
bors
fc13634f78 Auto merge of #13917 - weihanglo:resolve, r=epage
refactor: misc refactors for `ops::resolve`

### What does this PR try to resolve?

This is a preparation for another `-Zpatch-files` experiment,
so that the future PR can move things around easier without too many conflicts.

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

Generally they shouldn't affect anything existing behavior.
a6230e348b might be a bit dubious,
though I believe preloading workspace members is kinda idempotent
and registering patches/lockfile never cares about it.

### Additional information
2024-05-15 14:39:18 +00:00
Weihang Lo
327649b24f
refactor: make keep-previous-lockfile clousre a type alias 2024-05-15 09:02:26 -04:00
Weihang Lo
178bde773b
refactor: iterator instead of extra allocation for registering patches 2024-05-15 08:52:46 -04:00
bors
0ea330d5a4 Auto merge of #13898 - stevenengler:cargo-add-perms, r=weihanglo
Preserve file permissions on unix during `write_atomic`

### What does this PR try to resolve?

Fixes #13896.

> When you run `cargo add`, it changes the file permissions of `Cargo.toml` to 600 (user read+write only). This is a little bit painful when you're building the code as a different user than the user writing the code, for example if you're running the code in a container. This applies to `cargo remove` as well. I tested this behaviour on Cargo 1.78.0 and nightly.

I'm not entirely sure how permissions are handled on Windows, but the tempfile lib [doesn't seem to support them](https://docs.rs/tempfile/3.10.1/tempfile/struct.Builder.html#windows-and-others), so I haven't changed the behaviour on Windows.

Only the user/group/other read/write/execute permission bits are copied.

This PR sets the permissions ~twice~ once:
~1. When creating the file. This has the umask applied, but means that we don't create a file that is more permissive than the original.~
2. After the file has been created. This doesn't apply the umask, resulting in the file having the same u/g/o r/w/x permissions as the original file.

Since this PR changes a util function, it has a wider scope than just changing the behaviour of `cargo add` and `cargo remove`. `write_atomic` is called from the following functions:

- [`migrate_manifests`](4de0094ac7/src/cargo/ops/fix.rs (L340))
- [`update_manifest_with_new_member`](4de0094ac7/src/cargo/ops/cargo_new.rs (L1008))
- [`LocalManifest::write`](4de0094ac7/src/cargo/util/toml_mut/manifest.rs (L299))
- [`gc_workspace`](4de0094ac7/src/bin/cargo/commands/remove.rs (L274))

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

Unit test was added (`cargo test -p cargo-util write_atomic_permissions`).
2024-05-15 12:44:40 +00:00
Weihang Lo
a6230e348b
refactor: start workspace preload earlier before patching
This is a preparation for patch re-resolving.
2024-05-15 01:09:07 -04:00
Weihang Lo
f6d8f9ccf8
refactor: exact [replace] locking to a function 2024-05-15 00:59:49 -04:00
Weihang Lo
ab95ab4cc1
refactor: remove unnecessary Workspace::preload
Already did that in
2f17770a15/src/cargo/ops/resolve.rs (L375-L378)

See also rust-lang/cargo@cda5f82498
2024-05-15 00:27:20 -04:00
Steven Engler
36a63b4039 fix: preserve file permissions on unix during write_atomic
Preseves u/g/o r/w/x permissions on unix platforms.
2024-05-14 22:50:28 -04:00
Steven Engler
038ccd29c0 test: write_atomic changes file permissions to 0o600 on unix 2024-05-14 22:48:34 -04:00
bors
2f17770a15 Auto merge of #13901 - gmorenz:fix_bench, r=weihanglo
Update benchmark formatting for new nightly
2024-05-11 12:57:28 +00:00
Greg Morenz
4ea824b51e Update benchmark formatting for new nightly 2024-05-11 08:19:03 -04:00
bors
4de0094ac7 Auto merge of #13893 - justsmth:rust-script-doc-fix, r=weihanglo
Fix docs for unstable script feature

### What does this PR try to resolve?
* [Recent change](https://github.com/rust-lang/cargo/pull/13861) to accepted syntax in the script feature is not reflected in the documentation.

### How should we test and review this PR?
* Verify that this documentation is consistent with syntax expected.

### Additional information
N/A
2024-05-09 16:09:22 +00:00
bors
baca68ef47 Auto merge of #13880 - Muscraft:refactor-cargo-lint-tests, r=weihanglo
Refactor cargo lint tests

In #13621, it was brought up that [the lints tests are nested more deeply than other UI tests](https://github.com/rust-lang/cargo/pull/13621#discussion_r1538065181). This got me wondering if there was a better way to structure all the lint tests.
What I came up with was:
- Lints should not have UI tests, only parts of the diagnostic system, i.e., how warnings, errors, notes, etc., look
  - This is because UI tests should focus on parts of the system that make up each lint's output
  - We can always add UI tests for each lint if desired
- All tests related to the linting system should live in `tests/testsuite/lints/`
- Tests related to `[lints.cargo]` should stay in `lints_table.rs` as it is for the whole lints table
- Each lint will get a file in `lints/` for all of its tests
  - This makes `lints/mod.rs` smaller and targeted only at tests for the linting system itself
  - It makes it much easier to know where to place a test
2024-05-09 15:39:41 +00:00
Justin Smith
ad254b884d Fix docs for unstable script feature 2024-05-09 11:38:37 -04:00
bors
7297f0f06f Auto merge of #13890 - weihanglo:rustfix, r=ehuss
test(rustfix): run some tests only on nightly
2024-05-09 14:16:19 +00:00
Weihang Lo
a47766149f
test(rustfix): bless multiple-solutions.nightly.rs 2024-05-09 09:30:25 -04:00
Weihang Lo
26bcf58bfe
test(rustfix): run some tests only on nightly 2024-05-09 09:30:25 -04:00
Scott Schafer
b79fd591ce
test: Add UI tests showing parts of diagnostic system 2024-05-08 22:42:35 -06:00
bors
1fec089991 Auto merge of #13874 - torhovland:old-syntax-suggestion, r=weihanglo
Old syntax suggestion

Fixes #13868.

The build error in the issue will now include a suggestion:

```
   Compiling zerocopy v0.8.0-alpha.9
error: the `cargo::` syntax for build script output instructions was added in Rust 1.77.0, but the minimum supported Rust version of `zerocopy v0.8.0-alpha.9` is 1.56.0.
Consider using the old `cargo:` syntax in front of `rustc-check-cfg=`.
See https://doc.rust-lang.org/cargo/reference/build-scripts.html#outputs-of-the-build-script for more information about build script outputs.
```

The suggestion is only included for reserved prefixes.

A test has been added.
2024-05-08 21:27:30 +00:00
Scott Schafer
6f81cff16c
refactor: Move lint specific tests to lints/mod.rs 2024-05-08 15:18:49 -06:00
Tor Hovland
3ea3638c1b Adjusted the suggestion text. 2024-05-08 23:04:59 +02:00
Tor Hovland
ff0453b21f Added another test. 2024-05-08 23:04:59 +02:00