Commit graph

75 commits

Author SHA1 Message Date
Weihang Lo
f9fd4ff4ee
fix(json-msg): use pkgid spec in in JSON messages
In 12914 we stabilized pkgid spec as unique package identifier for
`cargo metadata`. However, we forgot to make the same change to
JSON message format[^1]. This PR does so.

Note that the `package_id` field in JSON message is not clearly stated
as "opaque", so it might be considered as a breaking change to some extent.

[^1]: https://doc.rust-lang.org/nightly/cargo/reference/external-tools.html#compiler-messages
2024-01-17 11:31:19 -05:00
Weihang Lo
77da514529
test: move --keep-going suggestion match tests to UI tests
We don't want to overly match to suggestion help from clap.
2023-08-22 19:21:09 +01:00
Weihang Lo
4d0958587b
refactor(arg): use UnknownArgumentValueParser to suggest arg for unknown args 2023-08-22 17:24:40 +01:00
bors
7b61184ad1 Auto merge of #12498 - Kobzol:run-verbose-print-env, r=arlosi
Print environment variables for `cargo run` in extra verbose mode
2023-08-17 05:32:16 +00:00
Jakub Beránek
4eac5a1fd1
Add test for environment variables in verbose mode for cargo bench 2023-08-16 13:47:39 +02:00
Weihang Lo
689defd4ba
test: relax assertions of panic message (again) 2023-08-14 19:32:39 +01:00
Weihang Lo
5ae529b24e
feat: remove --keep-going from cargo test/bench
It confuses people that both `--no-fail-fast` and `--keep-going` exist
on `cargo test` and `cargo bench` but with slightly different behavior.
The intended use cases for `--keep-going` involve build commands like
`build`/`check`/`clippy` but never `test`/`bench`.

Hence, this commit removes `--keep-going` from `test`/`bench` and
provides guidance of `--no-fail-fast` instead.

If people really want to build as many tests as possible, they can also
do it in two steps:

    cargo build --tests --keep-going
    cargo test --test --no-fail-fast
2023-08-11 14:29:02 +01:00
Weihang Lo
b9e70ec0a2
test: relax assertions of panic handler message format 2023-07-29 17:12:46 +01:00
Scott Schafer
ab18bd40d5 refactor(testsuite): Replace [project] with [package] 2022-09-26 09:51:16 -06:00
Eric Huss
23735d4c09 Rework test error handling 2022-08-27 19:23:30 -07:00
Eric Huss
1c3640e05c Add requirements to cargo_test. 2022-07-30 19:36:58 -07:00
Danil Hendra Suryawan
e04d7772e4 No printing executable names when running benches with json message format 2022-05-24 20:44:54 +07:00
Yerkebulan Tulibergenov
0b74ea2f76 display bench exec info differently 2022-02-02 08:17:09 -08:00
Yerkebulan Tulibergenov
ed579b66e2 add short path name for executables 2022-01-31 10:37:02 -08:00
Yerkebulan Tulibergenov
a6c1459f37 fix tests 2022-01-30 23:59:54 -08:00
Vaibhav
bef4d79ff2 Print executable name on cargo test --no-run.
Closes #9957

Signed-off-by: Vaibhav <vrongmeal@gmail.com>
2021-10-05 23:47:38 +05:30
Eric Huss
6dff99781d Remove with_either_contains.
It isn't needed anymore, and I would prefer to not keep around unused code.
It can always be added back if ever needed again.
2021-06-16 09:44:29 -07:00
Simonas Kazlauskas
548300b20f Add the path to the manifest in json output
This allows consumers of the json messages to avoid guessing where
exactly the package root is. Having access to the package root is
difficult by virtue of requiring logic to guess its location by e.g.
walking filesystem from the source file.

This guessing logic becomes further complicated in presence of
workspaces and nigh impossible to implement correctly in instances where
artifacts end up produced from paths above the package root (e.g.
`../foo.rs`).

Since Cargo has access to this data in the first place, there doesn't
seem to be much reason to force consumers to invent their own, possibly
flawed, logic.
2021-03-04 20:09:51 +02:00
Gus Wynn
04c8372217 fix test suite 2021-02-21 14:37:42 -08:00
ayazhafiz
e831dd12a8 Publish target's "doc" setting when emitting metadata
Prior to this commit `cargo metadata` would not emit the value of a
target's "doc" setting, used by `cargo doc` to determine whether
documentation should be generated. However, this information is useful
for machine programs interested in such targets, and the information is
already made available on the internal representation of a target, so
this commit just exposes that during target serialization for emit.

cf https://github.com/deadlinks/cargo-deadlinks/issues/99
2020-11-17 19:54:17 -06:00
Weihang Lo
8f0664f02a
test: normalize raw string indentation. 2020-10-10 07:44:57 +08:00
Weihang Lo
a06ec889f4
test(bench): glob support for package selection 2020-10-05 01:24:42 +08:00
Eric Huss
6f8c7d5a87 Normalize raw string indentation. 2020-09-26 17:59:58 -07:00
Oliver Scherer
95b22d2874 Emit the test field in cargo metadata 2020-07-30 09:50:46 +02:00
Alex Tokarev
19a9579031 Warn on missing required-features
Co-authored-by: Eric Huss <eric@huss.org>
2020-07-26 13:01:18 +03:00
Eric Huss
eac3b66bd4 Rework how Cargo computes the rustc file outputs. 2020-05-05 14:32:52 -07:00
Eric Huss
c889bbfba8 Add "build-finished" JSON message. 2020-04-04 18:56:50 -07:00
Jiajie Chen
9f07c83417 Don't create hardlink for library test, integrations tests and benches, fixing #7960 2020-03-05 13:03:49 +08:00
Eric Huss
83571aee56 Minor testsuite organization. 2019-11-24 18:42:45 -08:00
Dan Aloni
375a46f18b Merge remote-tracking branch 'origin/master' into custom-profile-pr-rfc 2019-09-18 08:56:13 +03:00
Alex Crichton
9115b2c326 Extract support directory to its own crate
Extract out all our test support code to its own standalone crate so it
can be shared between multiple test suites if necessary.
2019-09-16 11:47:09 -07:00
Dan Aloni
f0896975be Merge remote-tracking branch 'origin/master' into custom-profile-pr-rfc 2019-09-08 21:43:41 +03:00
k-nasa
7176df01d6 Change --all to --workspace 2019-09-03 17:14:34 -07:00
Dan Aloni
23e613d552 Merge remote-tracking branch 'origin/master' into custom-profile-pr-rfc 2019-08-09 11:50:55 +03:00
Vadim Petrochenkov
01aae39ee7 tests: Enable features to fix unstabilized #[bench] 2019-07-31 22:46:29 +03:00
Dan Aloni
87183146d9 Merge remote-tracking branch 'origin/master' into custom-profile-pr-rfc 2019-06-20 16:18:42 +03:00
Dan Aloni
03b054392d tests: fix nightly-only test with regard to the Finished line 2019-06-09 20:32:09 +03:00
Jethro Beekman
0e0d968825 Update #[test] attribute on all tests in the testsuite
sed -i 's/^#\[test\]/#[cargo_test]/' $(rg -l '^#\[test\]')

Manual fixes:
* proc_macro::proc_macro_doctest
2019-06-07 12:41:26 -07:00
vlad20012
e1d433d30f Add doctest field into metadata
Some tools can support rust doctests (e.g. highlighting
or launching). So it should be possible to find out if
doctests are enabled for a target or not. This commit
adds `doctest` field to `cargo metadata` output.
2019-05-17 18:39:23 +03:00
Alex Crichton
fecb724643 Format with cargo fmt 2018-12-08 03:19:47 -08:00
Dale Wijnand
04ddd4d0fc
Upgrade to Rust 2018 2018-12-06 20:18:35 +01:00
Dale Wijnand
020efe02f5
Trim the bench test so it cannot be non-deterministic 2018-12-01 18:35:31 +00:00
Dale Wijnand
c78cd0ceb7
Ignore filenames, to avoid extra Windows file
Apparently on Windows it creates an .exe & a .pdb.
2018-11-30 23:15:31 +00:00
Dale Wijnand
282f238d93
Include executable in JSON output. 2018-11-30 22:12:30 +00:00
Zach Lute
b020d3789a Resolve merge conflicts with test string changes. 2018-09-09 16:48:57 -07:00
Zach Lute
89f43938fe Print file paths instead of file:// URLs.
This change ensures cargo will output file paths in the expected format
(C:\foo\... on Windows, /foo/... elsewhere). Previously it would output
file:// URLs instead.

To support this change, additional changes were made to the test suite
string processing such that [ROOT] is now replaced with the appropriate
file path root for the platform.

The CWD template was also updated to use [CWD] like other replacement
templates and to do the replacement on the expected value rather than
the actual value to avoid replacing things we don't expect with CWD.
2018-09-07 19:42:59 -07:00
Alex Crichton
3d0290398a Stabilize edition key and add cargo new --edition
This commit stabilizes the `edition` key in `Cargo.toml`, both in the
`[package]` section and inside subtargets. Additionally the `cargo new` and
`cargo init` subcommands have been enhanced with a `--edition` flag to allow
explicitly specifying the edition to be generated.

This commit does not yet change the default edition that's generated.

Closes #5980
2018-09-06 11:28:10 -07:00
Matthias Krüger
2cd9cce6e3 clippy: resolve all warnings about useless format!() 2018-09-03 11:38:29 +02:00
Dale Wijnand
d5fc8dc3a7
Introduce the CWD macro in test output asserting
Avoids dealing with things like CWD changing.
2018-08-30 11:05:29 +02:00
Dale Wijnand
570fe8927d
Remove hamcrest existing_file() 2018-08-29 10:26:12 +02:00