mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00
Auto merge of #14402 - epage:snap, r=weihanglo
test: Migrate some json tests to snapbox ### What does this PR try to resolve? This is part of #14039 ### How should we test and review this PR? ### Additional information This was unblocked because of assert-rs/snapbox#350
This commit is contained in:
commit
9a170d718d
6
Cargo.lock
generated
6
Cargo.lock
generated
@ -2169,7 +2169,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"windows-targets 0.48.5",
|
||||
"windows-targets 0.52.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -3216,9 +3216,9 @@ checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67"
|
||||
|
||||
[[package]]
|
||||
name = "snapbox"
|
||||
version = "0.6.16"
|
||||
version = "0.6.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "027c936207f85d10d015e21faf5c676c7e08c453ed371adf55c0874c443ca77a"
|
||||
checksum = "840b73eb3148bc3cbc10ebe00ec9bc6d96033e658d022c4adcbf3f35596fd64a"
|
||||
dependencies = [
|
||||
"anstream",
|
||||
"anstyle",
|
||||
|
@ -92,7 +92,7 @@ sha2 = "0.10.8"
|
||||
shell-escape = "0.1.5"
|
||||
similar = "2.6.0"
|
||||
supports-hyperlinks = "3.0.0"
|
||||
snapbox = { version = "0.6.16", features = ["diff", "dir", "term-svg", "regex", "json"] }
|
||||
snapbox = { version = "0.6.17", features = ["diff", "dir", "term-svg", "regex", "json"] }
|
||||
tar = { version = "0.4.41", default-features = false }
|
||||
tempfile = "3.10.1"
|
||||
thiserror = "1.0.63"
|
||||
|
@ -1879,24 +1879,25 @@ fn doc_message_format() {
|
||||
|
||||
p.cargo("doc --message-format=json")
|
||||
.with_status(101)
|
||||
.with_json_contains_unordered(
|
||||
r#"
|
||||
{
|
||||
"message": {
|
||||
"$message_type": "diagnostic",
|
||||
"children": "{...}",
|
||||
"code": "{...}",
|
||||
"level": "error",
|
||||
"message": "{...}",
|
||||
"rendered": "{...}",
|
||||
"spans": "{...}"
|
||||
},
|
||||
"package_id": "path+file:///[..]/foo#0.0.1",
|
||||
"manifest_path": "[..]",
|
||||
"reason": "compiler-message",
|
||||
"target": "{...}"
|
||||
}
|
||||
"#,
|
||||
.with_stdout_data(
|
||||
str![[r##"
|
||||
[
|
||||
{
|
||||
"manifest_path": "[ROOT]/foo/Cargo.toml",
|
||||
"message": {
|
||||
"$message_type": "diagnostic",
|
||||
"level": "error",
|
||||
"...": "{...}"
|
||||
},
|
||||
"package_id": "path+[ROOTURL]/foo#0.0.1",
|
||||
"reason": "compiler-message",
|
||||
"target": "{...}"
|
||||
},
|
||||
"{...}"
|
||||
]
|
||||
"##]]
|
||||
.is_json()
|
||||
.against_jsonlines(),
|
||||
)
|
||||
.run();
|
||||
}
|
||||
@ -1911,76 +1912,95 @@ fn doc_json_artifacts() {
|
||||
.build();
|
||||
|
||||
p.cargo("doc --message-format=json")
|
||||
.with_json_contains_unordered(
|
||||
r#"
|
||||
{
|
||||
"reason": "compiler-artifact",
|
||||
"package_id": "path+file:///[..]/foo#0.0.1",
|
||||
"manifest_path": "[ROOT]/foo/Cargo.toml",
|
||||
"target":
|
||||
{
|
||||
"kind": ["lib"],
|
||||
"crate_types": ["lib"],
|
||||
"name": "foo",
|
||||
"src_path": "[ROOT]/foo/src/lib.rs",
|
||||
"edition": "2015",
|
||||
"doc": true,
|
||||
"doctest": true,
|
||||
"test": true
|
||||
},
|
||||
"profile": "{...}",
|
||||
"features": [],
|
||||
"filenames": ["[ROOT]/foo/target/debug/deps/libfoo-[..].rmeta"],
|
||||
.with_stdout_data(
|
||||
str![[r#"
|
||||
[
|
||||
{
|
||||
"executable": null,
|
||||
"fresh": false
|
||||
}
|
||||
|
||||
{
|
||||
"reason": "compiler-artifact",
|
||||
"package_id": "path+file:///[..]/foo#0.0.1",
|
||||
"manifest_path": "[ROOT]/foo/Cargo.toml",
|
||||
"target":
|
||||
{
|
||||
"kind": ["lib"],
|
||||
"crate_types": ["lib"],
|
||||
"name": "foo",
|
||||
"src_path": "[ROOT]/foo/src/lib.rs",
|
||||
"edition": "2015",
|
||||
"doc": true,
|
||||
"doctest": true,
|
||||
"test": true
|
||||
},
|
||||
"profile": "{...}",
|
||||
"features": [],
|
||||
"filenames": ["[ROOT]/foo/target/doc/foo/index.html"],
|
||||
"executable": null,
|
||||
"fresh": false
|
||||
}
|
||||
|
||||
{
|
||||
"reason": "compiler-artifact",
|
||||
"package_id": "path+file:///[..]/foo#0.0.1",
|
||||
"filenames": [
|
||||
"[ROOT]/foo/target/debug/deps/libfoo-[HASH].rmeta"
|
||||
],
|
||||
"fresh": false,
|
||||
"manifest_path": "[ROOT]/foo/Cargo.toml",
|
||||
"target":
|
||||
{
|
||||
"kind": ["bin"],
|
||||
"crate_types": ["bin"],
|
||||
"name": "somebin",
|
||||
"src_path": "[ROOT]/foo/src/bin/somebin.rs",
|
||||
"edition": "2015",
|
||||
"doc": true,
|
||||
"doctest": false,
|
||||
"test": true
|
||||
},
|
||||
"package_id": "path+[ROOTURL]/foo#0.0.1",
|
||||
"profile": "{...}",
|
||||
"features": [],
|
||||
"filenames": ["[ROOT]/foo/target/doc/somebin/index.html"],
|
||||
"reason": "compiler-artifact",
|
||||
"target": {
|
||||
"crate_types": [
|
||||
"lib"
|
||||
],
|
||||
"doc": true,
|
||||
"doctest": true,
|
||||
"edition": "2015",
|
||||
"kind": [
|
||||
"lib"
|
||||
],
|
||||
"name": "foo",
|
||||
"src_path": "[ROOT]/foo/src/lib.rs",
|
||||
"test": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"executable": null,
|
||||
"fresh": false
|
||||
}
|
||||
|
||||
{"reason":"build-finished","success":true}
|
||||
"#,
|
||||
"features": [],
|
||||
"filenames": [
|
||||
"[ROOT]/foo/target/doc/foo/index.html"
|
||||
],
|
||||
"fresh": false,
|
||||
"manifest_path": "[ROOT]/foo/Cargo.toml",
|
||||
"package_id": "path+[ROOTURL]/foo#0.0.1",
|
||||
"profile": "{...}",
|
||||
"reason": "compiler-artifact",
|
||||
"target": {
|
||||
"crate_types": [
|
||||
"lib"
|
||||
],
|
||||
"doc": true,
|
||||
"doctest": true,
|
||||
"edition": "2015",
|
||||
"kind": [
|
||||
"lib"
|
||||
],
|
||||
"name": "foo",
|
||||
"src_path": "[ROOT]/foo/src/lib.rs",
|
||||
"test": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"executable": null,
|
||||
"features": [],
|
||||
"filenames": [
|
||||
"[ROOT]/foo/target/doc/somebin/index.html"
|
||||
],
|
||||
"fresh": false,
|
||||
"manifest_path": "[ROOT]/foo/Cargo.toml",
|
||||
"package_id": "path+[ROOTURL]/foo#0.0.1",
|
||||
"profile": "{...}",
|
||||
"reason": "compiler-artifact",
|
||||
"target": {
|
||||
"crate_types": [
|
||||
"bin"
|
||||
],
|
||||
"doc": true,
|
||||
"doctest": false,
|
||||
"edition": "2015",
|
||||
"kind": [
|
||||
"bin"
|
||||
],
|
||||
"name": "somebin",
|
||||
"src_path": "[ROOT]/foo/src/bin/somebin.rs",
|
||||
"test": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"reason": "build-finished",
|
||||
"success": true
|
||||
}
|
||||
]
|
||||
"#]]
|
||||
.is_json()
|
||||
.against_jsonlines(),
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
@ -741,43 +741,48 @@ fn metabuild_json_artifact() {
|
||||
let p = basic_project();
|
||||
p.cargo("check --message-format=json")
|
||||
.masquerade_as_nightly_cargo(&["metabuild"])
|
||||
.with_json_contains_unordered(
|
||||
r#"
|
||||
{
|
||||
"executable": null,
|
||||
"features": [],
|
||||
"filenames": "{...}",
|
||||
"fresh": false,
|
||||
"package_id": "path+file:///[..]/foo#0.0.1",
|
||||
"manifest_path": "[..]",
|
||||
"profile": "{...}",
|
||||
"reason": "compiler-artifact",
|
||||
"target": {
|
||||
"crate_types": [
|
||||
"bin"
|
||||
],
|
||||
"doc": false,
|
||||
"doctest": false,
|
||||
"edition": "2018",
|
||||
"kind": [
|
||||
"custom-build"
|
||||
],
|
||||
"name": "metabuild-foo",
|
||||
"src_path": "[..]/foo/target/.metabuild/metabuild-foo-[..].rs",
|
||||
"test": false
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
"cfgs": [],
|
||||
"env": [],
|
||||
"linked_libs": [],
|
||||
"linked_paths": [],
|
||||
"package_id": "path+file:///[..]/foo#0.0.1",
|
||||
"out_dir": "[..]",
|
||||
"reason": "build-script-executed"
|
||||
}
|
||||
"#,
|
||||
.with_stdout_data(
|
||||
str![[r#"
|
||||
[
|
||||
"{...}",
|
||||
{
|
||||
"executable": null,
|
||||
"features": [],
|
||||
"filenames": "{...}",
|
||||
"fresh": false,
|
||||
"manifest_path": "[ROOT]/foo/Cargo.toml",
|
||||
"package_id": "path+[ROOTURL]/foo#0.0.1",
|
||||
"profile": "{...}",
|
||||
"reason": "compiler-artifact",
|
||||
"target": {
|
||||
"crate_types": [
|
||||
"bin"
|
||||
],
|
||||
"doc": false,
|
||||
"doctest": false,
|
||||
"edition": "2018",
|
||||
"kind": [
|
||||
"custom-build"
|
||||
],
|
||||
"name": "metabuild-foo",
|
||||
"src_path": "[ROOT]/foo/target/.metabuild/metabuild-foo-[HASH].rs",
|
||||
"test": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"cfgs": [],
|
||||
"env": [],
|
||||
"linked_libs": [],
|
||||
"linked_paths": [],
|
||||
"out_dir": "[ROOT]/foo/target/debug/build/foo-[HASH]/out",
|
||||
"package_id": "path+[ROOTURL]/foo#0.0.1",
|
||||
"reason": "build-script-executed"
|
||||
},
|
||||
"{...}"
|
||||
]
|
||||
"#]]
|
||||
.is_json()
|
||||
.against_jsonlines(),
|
||||
)
|
||||
.run();
|
||||
}
|
||||
@ -791,37 +796,39 @@ fn metabuild_failed_build_json() {
|
||||
p.cargo("check --message-format=json")
|
||||
.masquerade_as_nightly_cargo(&["metabuild"])
|
||||
.with_status(101)
|
||||
.with_json_contains_unordered(
|
||||
r#"
|
||||
{
|
||||
"message": {
|
||||
"$message_type": "diagnostic",
|
||||
"children": "{...}",
|
||||
"code": "{...}",
|
||||
"level": "error",
|
||||
"message": "cannot find function `metabuild`[..]",
|
||||
"rendered": "{...}",
|
||||
"spans": "{...}"
|
||||
},
|
||||
"package_id": "path+file:///[..]/foo#0.0.1",
|
||||
"manifest_path": "[..]",
|
||||
"reason": "compiler-message",
|
||||
"target": {
|
||||
"crate_types": [
|
||||
"bin"
|
||||
],
|
||||
"doc": false,
|
||||
"doctest": false,
|
||||
"edition": "2018",
|
||||
"kind": [
|
||||
"custom-build"
|
||||
],
|
||||
"name": "metabuild-foo",
|
||||
"src_path": null,
|
||||
"test": false
|
||||
}
|
||||
}
|
||||
"#,
|
||||
.with_stdout_data(
|
||||
str![[r#"
|
||||
[
|
||||
"{...}",
|
||||
{
|
||||
"manifest_path": "[ROOT]/foo/Cargo.toml",
|
||||
"message": {
|
||||
"level": "error",
|
||||
"message": "cannot find function `metabuild` in crate `mb`",
|
||||
"...": "{...}"
|
||||
},
|
||||
"package_id": "path+[ROOTURL]/foo#0.0.1",
|
||||
"reason": "compiler-message",
|
||||
"target": {
|
||||
"crate_types": [
|
||||
"bin"
|
||||
],
|
||||
"doc": false,
|
||||
"doctest": false,
|
||||
"edition": "2018",
|
||||
"kind": [
|
||||
"custom-build"
|
||||
],
|
||||
"name": "metabuild-foo",
|
||||
"src_path": null,
|
||||
"test": false
|
||||
}
|
||||
},
|
||||
"{...}"
|
||||
]
|
||||
"#]]
|
||||
.is_json()
|
||||
.against_jsonlines(),
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user