Commit graph

174 commits

Author SHA1 Message Date
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
Adrian
b7b5a093a1
Fix cargo errors counter 2023-11-29 18:47:14 +02:00
Eric Huss
0afd943dad Fix some test output validation. 2023-11-15 15:10:18 -08:00
David Hotham
962d89a8d8
fix error message for duplicate links 2023-11-14 17:53:58 +00:00
Ed Page
293f2250d6 feat(doc): Print the generated docs links
I've wanted something like this myself.  I dislike using `--open`
because I tend to move up to re-run my `cargo doc` run but then have to
edit it to remove `--open`.
Also makes it annoying when opening docs when `cargo doc` is wrapped by
a tool like `make`.

This was previously attempted in #5592:
- Unlike the request in #5562, this aligns with #5592 in always printing
  rather than using a flag as this seems generally useful
- Unlike #5592, this prints as an alternative to "Opening" to keep
  things light
- Unlike #5592, this prints afterwards as the link is only valid then

Fixes #5562
2023-10-19 10:51:56 -05:00
Matheus Z Marchiore
380719da35 feat: add package name and version to warning messages 2023-10-11 16:52:30 -03:00
hi-rustin
7cbc858b71 Add some tests 2023-08-28 09:29:17 +08:00
hi-rustin
4bdeb53cb5 Bail out an error when using cargo:: in custom build script
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-07-27 23:00:52 +08:00
Arpad Borsos
18e290c0e4
Enable doctest-in-workspace by default
This stabilizes and enables the `-Z doctest-in-workspace` flag by default.

Also adds another testcase to make sure that the `include!()` and `file!()` macros interact well together.
2023-06-17 19:34:34 +02:00
Weihang Lo
64a1f204f3
refactor: only when -C debuginfo > 0 will spilt-debuginfo be passed
It was unnecessary to pass `spilt-debuginfo` if there is no debuginfo.
Tests are touched here only for matching rustflags invocation stderr
in the original test suite.
2023-05-31 20:43:57 +01:00
Eric Huss
16ac6fae11 Re-enable code_generation test on Windows 2023-05-29 12:01:02 -07:00
Adrián Ortiz
db457d950f Fixing issue https://github.com/rust-lang/cargo/issues/10834:
- Adding display of which target failed to compile
- Consistent messages for warnings/errors.
- Fixing assertions on related tests.
2023-03-07 06:45:26 +01:00
Scott Schafer
9708e6f62d refactor: Make two tests stderr not match their test name 2023-02-20 11:09:05 -06:00
Rémy Rakic
7ccda69f70 do not display message to enable debuginfo when it's already enabled 2023-01-31 22:36:20 +00:00
Rémy Rakic
9d9b7fef2d improve debuginfo error message when build script fails 2023-01-31 22:36:20 +00:00
Rémy Rakic
3be6c93a22 update optional_build_dep_and_required_normal_dep test expectations
This test dynamically enables a shared build/runtime dependency, and
therefore doesn't trigger the build/runtime sharing reuse optimization,
as the build dep is initially built without debuginfo for optimization
purposes.
2023-01-31 22:36:20 +00:00
Rémy Rakic
7dfabdc681 add build script failure test when requesting backtraces
it displays an additional message on how to improve these backtraces, now that
debuginfo is turned off most of the time in `dev.build-override`.
2023-01-31 20:12:52 +00:00
Rémy Rakic
6848006cbe update tests for build deps debuginfo optimization 2023-01-31 20:12:52 +00:00
arriven
9e01c8bbcf skip mtime checks for paths in $CARGO_HOME 2023-01-24 08:27:33 +00:00
Dinu Blanovschi
0beb5fe93d Simple explanations for why cargo rebuilds crates 2022-12-28 16:27:50 +01:00
Jon Gjengset
724a1977ce Make cargo forward pre-existing CARGO if set
Currently, Cargo will always set `$CARGO` to point to what it detects
its own path to be (using `std::env::current_exe`). Unfortunately, this
runs into trouble when Cargo is used as a library, or when `current_exe`
is not actually the binary itself (e.g., when invoked through Valgrind
or `ld.so`), since `$CARGO` will not point at something that can be used
as `cargo`. This, in turn, means that users can't currently rely on
`$CARGO` to do the right thing, and will sometimes have to invoke
`cargo` directly from `$PATH` instead, which may not reflect the `cargo`
that's currently in use.

This patch makes Cargo re-use the existing value of `$CARGO` if it's
already set in the environment. For Cargo subcommands, this will mean
that the initial invocation of `cargo` in `cargo foo` will set `$CARGO`,
and then Cargo-as-a-library inside of `cargo-foo` will inherit that
(correct) value instead of overwriting it with the incorrect value
`cargo-foo`. For other execution environments that do not have `cargo`
in their call stack, it gives them the opportunity to set a working
value for `$CARGO`.

One note about the implementation of this is that the test suite now
needs to override `$CARGO` explicitly so that the _user's_ `$CARGO` does
not interfere with the contents of the tests. It _could_ remove `$CARGO`
instead, but overriding it seemed less error-prone.

Fixes #10119.
Fixes #10113.
2022-10-25 13:51:27 -07:00
Arlo Siemsen
d51ed05324 Fix deadlock when build scripts are waiting for input on stdin 2022-10-12 11:46:51 -05:00
Scott Schafer
ab18bd40d5 refactor(testsuite): Replace [project] with [package] 2022-09-26 09:51:16 -06:00
Eric Huss
7eb007ddbf Add reasons to all ignored tests. 2022-08-02 12:24:00 -07:00
Scott Schafer
c239e407e7 add a reason to masquerade_as_nightly_cargo so it is searchable 2022-07-15 21:32:23 -05:00
bors
39ad1039d9 Auto merge of #10600 - tmfink:doc-build-script-link-order, r=ehuss
doc: discuss build script instruction order

### What does this PR try to resolve?

It is currently not documented that the order of build script `cargo:` instructions may be relevant to linking.

This has caused issues such as: https://github.com/rust-lang/rust/issues/96328

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

Build/view documentation.

### Additional information

- Cargo maintainers should fact check my wording.
- We may need to discuss if this should also be documented for `rustc`
- Maintainers should ensure that this change does not prevent a change in what is currently unspecified behavior. Perhaps `cargo` will want to rearrange link arguments itself to resolve issues in the future?
2022-05-25 00:50:02 +00:00
Travis Finkenauer
43ce1e7a98 Test that link argument order is maintained
Patch provided by @ehuss
2022-05-24 12:45:20 -07:00
bors
9fa2bba679 Auto merge of #10281 - Gnurfos:depinfo_relative, r=ehuss
Fix use of .. in dep-info-basedir

### Summary

This allows setting, in .cargo/config's dep-info-basedir, some relative path that goes above the crate's directory.

### Motivation

In a setup like this:

```
repo_root
├── Makefile
├── some_c_things
│   └── foo.c
└── rust_things
    ├── Cargo.toml
    └─── src
        └── lib.rs
```

If you want the generated .d files to be includable directly in the Makefile (without post-processing), you need them to mention paths relative to the root, like:

rust_things/target/....: rust_things/src/lib.rs

### Implementation

For this you need to have relative paths with parent directories (in this case ..) in dep-info-basedir, which does not work without the change in this PR (due to render_filename doing only strip_prefix, while the basedir still contains literal ..s).

Let me know if this change is acceptable. Another implementation could be to canonicalize in ConfigRelativePath::resolve_path instead, especially since that struct outputs absolute paths. But that would have it access the filesystem, while it currently doesn't.
2022-05-07 19:49:54 +00:00
Jon Gjengset
f23894d93f Make rustflags logic more linear 2022-02-23 16:36:14 -08:00
Jon Gjengset
745329c3b1 Remove env_var from test names that don't use env 2022-02-23 16:35:41 -08:00
Jon Gjengset
4f41727106 Enable propagating rustflags to build scripts
This patch implements more complete logic for applying rustflags to
build scripts and other host artifacts. In the default configuration, it
only makes build scripts (and plugins and whatnot) pick up on
`rustflags` from `[host]`, which fixes #10206 but otherwise preserves
existing behavior in all its inconsistent glory. The same is the case if
`target-applies-to-host` is explicitly set to `false`.

When `target-applies-to-host` is explicitly set to `true`, rustflags
will start to be applied in the same way that `linker` and `runner` are
today -- namely they'll be applied from `[target.<host triple>]` and
from `RUSTFLAGS`/`build.rustflags` if `--target <host triple>` is given.
2022-02-18 10:50:08 -08:00
Jon Gjengset
040f0d10a6 Simplify unused build scripts in tests
The tests in question all tail to even build the build script, so the
contents of `main` don't matter, and make the tests seem more complex
than they really are.
2022-02-17 10:33:23 -08:00
Jon Gjengset
90a61d183f Run target-applies-to-host tests on stable 2022-02-17 10:31:10 -08:00
Seb E
e5ff81b0e7 Fix use of .. in dep-info-basedir config 2022-01-12 10:37:32 +01: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
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
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
Weihang Lo
d22623466d
Show original version_req for locked dependency
When encounter resolver error with locked dependency, we now show
original version req along with the exact locked version.
2021-09-20 11:31:59 +08:00
Eric Huss
c4e92ac69a Improve "wrong output" error. 2021-09-11 16:34:09 -07:00
Weihang Lo
a5f8bc94f5
Improve resolver message for validate_links 2021-08-24 00:39:38 +08:00
Weihang Lo
0afd40b4de
Update tests to display dep-req info for dep-chain 2021-08-24 00:39:38 +08:00
bors
adde602238 Auto merge of #9601 - jonhoo:fix-9600, r=ehuss
Inform build scripts of rustc compiler context

Fixes #9600.
2021-07-20 21:27:35 +00:00
Jon Gjengset
1cbce47051 Remove RUSTC_VERSION envvar 2021-07-15 17:53:21 -07:00