216 Commits

Author SHA1 Message Date
Eric Huss
c35cb56d32 Update tests to deal with linker warnings
Nightly recently introduced the `linker-messages` lint which prints any
messages from linkers. These tests were triggering that lint because
they were passing missing directories to the linker. This fixes it by
creating empty directories to pass to the linker.

Note that this lint will be downgraded soon via
https://github.com/rust-lang/rust/pull/136098, but it seemed worthwhile
to fix the underlying problem.

This also fixes a problem where build_script_needed_for_host_and_target
was not testing for the correct command-line flags. These got lost
in https://github.com/rust-lang/cargo/pull/14132.
2025-01-26 13:25:17 -08:00
Mara Bos
a9b50c201b Make "C" explicit in extern "C". 2025-01-08 18:14:15 +01:00
Weihang Lo
b7d98618b6
test: relax panic output assertion
rust-lang/rust#122565 adds a new line to thread panic output.
To make the current test suites works on stable, beta, and nightly,
similar to rust-lang/cargo#14602,
this relaxes the assertion around that by globbing everything.
2024-12-29 13:45:24 -05:00
Ed Page
8e90ce9a24 feat(build-script): Pass CARGO_CFG_FEATURE
This may look redundant with `CARGO_FEATURE_<CASE_CONVERTED_NAME>=1`
except that doesn't provide a lossless way of getting the names, e.g. for
forwarding for child builds like tests that need to build examples.

This also makes things more consistent as users
conditionalize on features through `cfg` and this even fits with what
the `CARGO_CFG_` docs say:

> For each configuration option of the package being built, this
> environment variable will contain the value of the configuration, where
> <cfg> is the name of the configuration uppercased and having -
> translated to _. Boolean configurations are present if they are set, and
> not present otherwise. Configurations with multiple values are joined to
> a single variable with the values delimited by ,. This includes values
> built-in to the compiler (which can be seen with rustc --print=cfg) and
> values set by build scripts and extra flags passed to rustc (such as
> those defined in RUSTFLAGS). Some examples of what these variables are:

Fixes #3702
2024-12-09 12:38:11 -06:00
Ed Page
f80fc018a6 test: Ensure we don't rely on unit return values
This will allow changing `Execs::run` return type
2024-11-18 20:52:53 -06:00
Ed Page
af3cfd5abe fix(test): Un-deprecate contains assertions 2024-11-07 15:55:35 -06:00
Eric Huss
9ce30a6ca3 Update tests to resolve recent changes
Upstream changed these messages slightly.
2024-10-29 08:12:43 -07:00
Tor Hovland
032bc29bb8 feat: cargo::error build script directive. 2024-10-29 08:02:55 -07:00
Tor Hovland
3fade07a0b test: cargo::error build script directive. 2024-10-29 08:02:55 -07:00
Ed Page
a6cf1be655 test: Switch from allow to expect deprecated
This caught a couple of lingering items.
2024-09-23 20:44:06 -05:00
Ed Page
d2ec764995 fix(resolve): Dont show locking workspace members
This is for `cargo generate-lockfile` and when syncing the lockfile with
the manifest.
We still show it for `cargo update` because of `cargo update
--workspace`.

We hacked around this previously by filtering out the `num_pkgs==1` case
for single packages but this didn't help with workspaces.
2024-08-22 16:57:06 -05:00
Shashi Sugrim
465701526b Fix issue ' cargo t --doc does not respect --color when a compilation error occurs #14403 ' 2024-08-19 17:23:25 -04:00
Jem Tucker
978514251a fix: use longhand gitoxide path-spec patterns 2024-08-10 20:21:40 +01:00
Jem Tucker
972d5346a2 test: Add test for issue rust-lang#14379 2024-08-10 20:13:01 +01:00
Ed Page
b0e515aa61 fix(test): Move 'cargo_home' from 'install' to 'paths'
This is used outside of `cargo install` contexts and this makes it more
discoverable for those use cases.
2024-07-19 10:50:42 -05:00
bors
f10c069629 Auto merge of #14266 - epage:path2url, r=weihanglo
fix(test): Move path2url to CargoPathExt::to_url

### What does this PR try to resolve?

This is a small step, like #14243, to improve the clarity of `cargo-test-support`s API.

Overall, I'm trying to make it more obvious on https://docs.rs/cargo-test-support/latest/cargo_test_support/ which items to reach for when.  I figured this is one that could be demoted to `paths` When doing so, I noticed `CargoPathExt`. I figured if we had any extension traits for `Path`, then this is a
reasonable one to add.

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

### Additional information
2024-07-18 20:57:05 +00:00
Ed Page
3a615ca9c8 feat(test): Add CargoPathExt to prelude 2024-07-18 15:22:29 -05:00
Greg Morenz
9098072ee3 Store links_overrides in Unit 2024-07-16 10:05:33 -04:00
Greg Morenz
76381aa81b Add test verifying behavior of links_overrides with target-applies-to-host and an implicit target 2024-07-16 10:05:33 -04:00
Ed Page
5b9799c6f4 refactor: Migrate from extern crate to test-support prelude
We now include the prelude in so many places, this simplifies how we can
present how `cargo-test-support` works.

Yes, this included some `use` clean ups but its already painful enough
walking through every test file, I didn't want to do it twice.
2024-07-12 15:57:00 -05:00
eth3lbert
447ac75d3e
fix(test): Reduce over-prescription to the caller
This is a follow-up fix that addresses the suggestion made in
https://github.com/rust-lang/cargo/pull/14200#discussion_r1667239028
for the remaining files.
2024-07-09 15:25:36 +08:00
eth3lbert
b87ce14c5d
test: migrate build_script to snapbox 2024-07-05 12:34:02 +08:00
Ed Page
dc5ac62cab fix(test): Deprecate non-snapbox assertions
While this is noisy and hides other deprecations, I figured deprecations would
make it easier for people to discover what tasks remain and allow us to
divide and conquer this work rather than doing a heroic PR.
In theory, this will be short lived and we'll go back to seeing
deprecations in our tests.
2024-06-10 10:20:52 -05:00
bors
54d9c3306b Auto merge of #13902 - heisen-li:plugin, r=weihanglo
fix(toml): remove `lib.plugin` key support and make it warning

### What does this PR try to resolve?

Remove `lib.plugin` key, making it an "unused key" warning.

Remove some of the tests, which should look useless (I hope I'm understanding this

- [x] Remove key, and related tests.
- [x] Adjust the documentation about the plugin.
- [ ] Some of the comments and function names have not yet finished being modified.

part of #13629

Closes #13246
2024-06-09 18:07:55 +00:00
Ed Page
3054936cab refactor: Port from assert_matches_exact to assert_e2e
This leaves off `validate_crate_contents` as that would be an effort on
its own
2024-05-29 14:08:10 -05:00
heisen-li
8056001e8a remove or change lib.plugin related test 2024-05-16 20:18:54 +08: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
Tor Hovland
4b498267c8 Added a similar suggestion when using cargo::metadata=. 2024-05-08 23:04:59 +02:00
Tor Hovland
4aac847678 Added test. 2024-05-07 10:59:07 +02:00
Urgau
388a17f23f Update regular tests for always-on check-cfg 2024-05-01 12:56:04 +02:00
Weihang Lo
ba5ec686f9
fix: emit 1.77 syntax error only when msrv is incompatible 2024-04-26 09:30:26 -04:00
Weihang Lo
f70bfd3f4a
test: emit 1.77 syntax error only when msrv is incompatible 2024-04-26 09:01:56 -04:00
Ed Page
1876326b6b feat(resolve): Tell the user the style of resovle done
This is to help with #9930

Example changes:
```diff
-[LOCKING] 4 packages
+[LOCKING] 4 packages to latest version
-[LOCKING] 2 packages
+[LOCKING] 2 packages to latest Rust 1.60.0 compatible versions
-[LOCKING] 2 packages
+[LOCKING] 2 packages to earliest versions
```

Benefits
- The package count is of "added" packages and this makes that more
  logically clear
- This gives users transparency into what is happening, especially with
  - what rust-version is use
  - the transition to this feature in the new edition
  - whether the planned config was applied or not (as I don't want it to
    require an MSRV bump)
- Will make it easier in tests to show what changed
- Provides more motiviation to show this message in `cargo update` and
  `cargo install` (that will be explored in a follow up PR)

This does come at the cost of more verbose output but hopefully not too
verbose.  This is why I left off other factors, like avoid-dev-deps.
2024-04-13 20:39:59 -05:00
bors
bd1cf584af Auto merge of #13560 - heisen-li:build_flag, r=weihanglo
[fix]:Build script not rerun when target rustflags change

### What does this PR try to resolve?

Fixes https://github.com/rust-lang/cargo/issues/13003
2024-04-08 15:54:04 +00:00
heisen-li
db7afeba4e
fix: rerun build script when target rustflags changed
fixes #13003
2024-04-08 10:48:20 -04:00
heisen-li
cdda9008a3
fix: show build script didnt rerun when target rustflags changed 2024-04-08 10:47:37 -04:00
Ed Page
386c4b6a65 refactor(toml): Consistently don't include pkgid
This is the only error we do this for and we have the context for what
manifest we are parsing.
By removing this, it makes it easier to adjust lifetimes in the short
term.
2024-03-27 12:53:49 -05:00
Ed Page
4ab2797f36 feat(lock): Print lockfile changes on all commands 2024-03-12 13:39:56 -05:00
Ed Page
14646e6af6 test: Make edition explicit on packages 2024-02-22 11:37:03 -06:00
Ed Page
831847e5f0 fix(rustc): Always pass --edition to rustc
On [Internals](https://internals.rust-lang.org/t/idea-rustc-cargo-should-warn-on-unspecified-edition/20309),
the idea came up for warning on unset Edition.
I am working on the cargo warning but if rustc ever wants to do so,
they'd be blocked on cargo ensuring `--edition` is always set.
Hence this change.
2024-02-28 15:35:41 -06:00
Ed Page
e7e8d8748a fix(compiler): Clarify we're showing a profile name 2024-02-08 14:01:39 -06:00
Ed Page
675224b3a0 test(config): Shift to config.toml 2024-01-26 13:40:46 -06: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
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
Chris Denton
4ef503fc2d
Don't rely on mtime to test changes 2023-12-08 20:32:28 +00:00