mirror of
https://github.com/rust-lang/cargo.git
synced 2025-10-01 11:30:39 +00:00
test: Migrate remaining build with_json tests to snapbox
This commit is contained in:
parent
f92e54faf9
commit
c18765a152
@ -4131,7 +4131,6 @@ fn panic_abort_compiles_with_panic_abort() {
|
|||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[expect(deprecated)]
|
|
||||||
#[cargo_test]
|
#[cargo_test]
|
||||||
fn compiler_json_error_format() {
|
fn compiler_json_error_format() {
|
||||||
let p = project()
|
let p = project()
|
||||||
@ -4160,148 +4159,98 @@ fn compiler_json_error_format() {
|
|||||||
|
|
||||||
let output = |fresh| {
|
let output = |fresh| {
|
||||||
r#"
|
r#"
|
||||||
{
|
[
|
||||||
"reason":"compiler-artifact",
|
{
|
||||||
"package_id":"path+file:///[..]/foo#0.5.0",
|
"executable": null,
|
||||||
"manifest_path": "[..]",
|
"features": [],
|
||||||
"target":{
|
"fresh": $FRESH,
|
||||||
"kind":["custom-build"],
|
"manifest_path": "[ROOT]/foo/Cargo.toml",
|
||||||
"crate_types":["bin"],
|
"package_id": "path+[ROOTURL]/foo#0.5.0",
|
||||||
"doc": false,
|
"reason": "compiler-artifact",
|
||||||
"doctest": false,
|
"target": {
|
||||||
"edition": "2015",
|
"kind": ["custom-build"],
|
||||||
"name":"build-script-build",
|
"...": "{...}"
|
||||||
"src_path":"[..]build.rs",
|
},
|
||||||
"test": false
|
"...": "{...}"
|
||||||
},
|
},
|
||||||
"profile": {
|
{
|
||||||
"debug_assertions": true,
|
"manifest_path": "[ROOT]/foo/bar/Cargo.toml",
|
||||||
"debuginfo": 0,
|
"package_id": "path+[ROOTURL]/foo/bar#0.5.0",
|
||||||
"opt_level": "0",
|
"reason": "compiler-message",
|
||||||
"overflow_checks": true,
|
"target": {
|
||||||
"test": false
|
"kind": ["lib"],
|
||||||
},
|
"...": "{...}"
|
||||||
"executable": null,
|
},
|
||||||
"features": [],
|
"...": "{...}"
|
||||||
"filenames": "{...}",
|
},
|
||||||
"fresh": $FRESH
|
{
|
||||||
}
|
"executable": null,
|
||||||
|
"features": [],
|
||||||
{
|
"fresh": $FRESH,
|
||||||
"reason":"compiler-message",
|
"manifest_path": "[ROOT]/foo/bar/Cargo.toml",
|
||||||
"package_id":"path+file:///[..]/bar#0.5.0",
|
"package_id": "path+[ROOTURL]/foo/bar#0.5.0",
|
||||||
"manifest_path": "[..]",
|
"reason": "compiler-artifact",
|
||||||
"target":{
|
"target": {
|
||||||
"kind":["lib"],
|
"kind": ["lib"],
|
||||||
"crate_types":["lib"],
|
"...": "{...}"
|
||||||
"doc": true,
|
},
|
||||||
"doctest": true,
|
"...": "{...}"
|
||||||
"edition": "2015",
|
},
|
||||||
"name":"bar",
|
{
|
||||||
"src_path":"[..]lib.rs",
|
"cfgs": [
|
||||||
"test": true
|
"xyz"
|
||||||
},
|
],
|
||||||
"message":"{...}"
|
"env": [],
|
||||||
}
|
"linked_libs": [],
|
||||||
|
"linked_paths": [],
|
||||||
{
|
"out_dir": "[ROOT]/foo/target/debug/build/foo-[HASH]/out",
|
||||||
"reason":"compiler-artifact",
|
"package_id": "path+[ROOTURL]/foo#0.5.0",
|
||||||
"profile": {
|
"reason": "build-script-executed"
|
||||||
"debug_assertions": true,
|
},
|
||||||
"debuginfo": 2,
|
{
|
||||||
"opt_level": "0",
|
"manifest_path": "[ROOT]/foo/Cargo.toml",
|
||||||
"overflow_checks": true,
|
"package_id": "path+[ROOTURL]/foo#0.5.0",
|
||||||
"test": false
|
"reason": "compiler-message",
|
||||||
},
|
"target": {
|
||||||
"executable": null,
|
"kind": ["bin"],
|
||||||
"features": [],
|
"...": "{...}"
|
||||||
"package_id":"path+file:///[..]/bar#0.5.0",
|
},
|
||||||
"manifest_path": "[..]",
|
"...": "{...}"
|
||||||
"target":{
|
},
|
||||||
"kind":["lib"],
|
{
|
||||||
"crate_types":["lib"],
|
"features": [],
|
||||||
"doc": true,
|
"fresh": $FRESH,
|
||||||
"doctest": true,
|
"manifest_path": "[ROOT]/foo/Cargo.toml",
|
||||||
"edition": "2015",
|
"package_id": "path+[ROOTURL]/foo#0.5.0",
|
||||||
"name":"bar",
|
"reason": "compiler-artifact",
|
||||||
"src_path":"[..]lib.rs",
|
"target": {
|
||||||
"test": true
|
"kind": ["bin"],
|
||||||
},
|
"...": "{...}"
|
||||||
"filenames":[
|
},
|
||||||
"[..].rlib",
|
"...": "{...}"
|
||||||
"[..].rmeta"
|
},
|
||||||
],
|
{
|
||||||
"fresh": $FRESH
|
"reason": "build-finished",
|
||||||
}
|
"success": true
|
||||||
|
},
|
||||||
{
|
"{...}"
|
||||||
"reason":"build-script-executed",
|
]
|
||||||
"package_id":"path+file:///[..]/foo#0.5.0",
|
"#
|
||||||
"linked_libs":[],
|
|
||||||
"linked_paths":[],
|
|
||||||
"env":[],
|
|
||||||
"cfgs":["xyz"],
|
|
||||||
"out_dir": "[..]target/debug/build/foo-[..]/out"
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
"reason":"compiler-message",
|
|
||||||
"package_id":"path+file:///[..]/foo#0.5.0",
|
|
||||||
"manifest_path": "[..]",
|
|
||||||
"target":{
|
|
||||||
"kind":["bin"],
|
|
||||||
"crate_types":["bin"],
|
|
||||||
"doc": true,
|
|
||||||
"doctest": false,
|
|
||||||
"edition": "2015",
|
|
||||||
"name":"foo",
|
|
||||||
"src_path":"[..]main.rs",
|
|
||||||
"test": true
|
|
||||||
},
|
|
||||||
"message":"{...}"
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
"reason":"compiler-artifact",
|
|
||||||
"package_id":"path+file:///[..]/foo#0.5.0",
|
|
||||||
"manifest_path": "[..]",
|
|
||||||
"target":{
|
|
||||||
"kind":["bin"],
|
|
||||||
"crate_types":["bin"],
|
|
||||||
"doc": true,
|
|
||||||
"doctest": false,
|
|
||||||
"edition": "2015",
|
|
||||||
"name":"foo",
|
|
||||||
"src_path":"[..]main.rs",
|
|
||||||
"test": true
|
|
||||||
},
|
|
||||||
"profile": {
|
|
||||||
"debug_assertions": true,
|
|
||||||
"debuginfo": 2,
|
|
||||||
"opt_level": "0",
|
|
||||||
"overflow_checks": true,
|
|
||||||
"test": false
|
|
||||||
},
|
|
||||||
"executable": "[..]/foo/target/debug/foo[EXE]",
|
|
||||||
"features": [],
|
|
||||||
"filenames": "{...}",
|
|
||||||
"fresh": $FRESH
|
|
||||||
}
|
|
||||||
|
|
||||||
{"reason": "build-finished", "success": true}
|
|
||||||
"#
|
|
||||||
.replace("$FRESH", fresh)
|
.replace("$FRESH", fresh)
|
||||||
|
.is_json()
|
||||||
|
.against_jsonlines()
|
||||||
|
.unordered()
|
||||||
};
|
};
|
||||||
|
|
||||||
// Use `jobs=1` to ensure that the order of messages is consistent.
|
// Use `jobs=1` to ensure that the order of messages is consistent.
|
||||||
p.cargo("build -v --message-format=json --jobs=1")
|
p.cargo("build -v --message-format=json --jobs=1")
|
||||||
.with_json_contains_unordered(&output("false"))
|
.with_stdout_data(output("false"))
|
||||||
.run();
|
.run();
|
||||||
|
|
||||||
// With fresh build, we should repeat the artifacts,
|
// With fresh build, we should repeat the artifacts,
|
||||||
// and replay the cached compiler warnings.
|
// and replay the cached compiler warnings.
|
||||||
p.cargo("build -v --message-format=json --jobs=1")
|
p.cargo("build -v --message-format=json --jobs=1")
|
||||||
.with_json_contains_unordered(&output("true"))
|
.with_stdout_data(output("true"))
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4321,7 +4270,6 @@ fn wrong_message_format_option() {
|
|||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[expect(deprecated)]
|
|
||||||
#[cargo_test]
|
#[cargo_test]
|
||||||
fn message_format_json_forward_stderr() {
|
fn message_format_json_forward_stderr() {
|
||||||
let p = project()
|
let p = project()
|
||||||
@ -4330,54 +4278,42 @@ fn message_format_json_forward_stderr() {
|
|||||||
.build();
|
.build();
|
||||||
|
|
||||||
p.cargo("rustc --release --bin foo --message-format JSON")
|
p.cargo("rustc --release --bin foo --message-format JSON")
|
||||||
.with_json_contains_unordered(
|
.with_stdout_data(
|
||||||
r#"
|
str![[r#"
|
||||||
{
|
[
|
||||||
"reason":"compiler-message",
|
{
|
||||||
"package_id":"path+file:///[..]/foo#0.5.0",
|
"manifest_path": "[ROOT]/foo/Cargo.toml",
|
||||||
"manifest_path": "[..]",
|
"message": "{...}",
|
||||||
"target":{
|
"package_id": "path+[ROOTURL]/foo#0.5.0",
|
||||||
"kind":["bin"],
|
"reason": "compiler-message",
|
||||||
"crate_types":["bin"],
|
"target": {
|
||||||
"doc": true,
|
"kind": ["bin"],
|
||||||
"doctest": false,
|
"...": "{...}"
|
||||||
"edition": "2015",
|
},
|
||||||
"name":"foo",
|
"...": "{...}"
|
||||||
"src_path":"[..]",
|
},
|
||||||
"test": true
|
{
|
||||||
},
|
"features": [],
|
||||||
"message":"{...}"
|
"fresh": false,
|
||||||
}
|
"manifest_path": "[ROOT]/foo/Cargo.toml",
|
||||||
|
"package_id": "path+[ROOTURL]/foo#0.5.0",
|
||||||
{
|
"reason": "compiler-artifact",
|
||||||
"reason":"compiler-artifact",
|
"target": {
|
||||||
"package_id":"path+file:///[..]/foo#0.5.0",
|
"kind": ["bin"],
|
||||||
"manifest_path": "[..]",
|
"...": "{...}"
|
||||||
"target":{
|
},
|
||||||
"kind":["bin"],
|
"...": "{...}"
|
||||||
"crate_types":["bin"],
|
},
|
||||||
"doc": true,
|
{
|
||||||
"doctest": false,
|
"reason": "build-finished",
|
||||||
"edition": "2015",
|
"success": true
|
||||||
"name":"foo",
|
},
|
||||||
"src_path":"[..]",
|
"{...}"
|
||||||
"test": true
|
]
|
||||||
},
|
"#]]
|
||||||
"profile":{
|
.is_json()
|
||||||
"debug_assertions":false,
|
.against_jsonlines()
|
||||||
"debuginfo":0,
|
.unordered(),
|
||||||
"opt_level":"3",
|
|
||||||
"overflow_checks": false,
|
|
||||||
"test":false
|
|
||||||
},
|
|
||||||
"executable": "{...}",
|
|
||||||
"features":[],
|
|
||||||
"filenames": "{...}",
|
|
||||||
"fresh": false
|
|
||||||
}
|
|
||||||
|
|
||||||
{"reason": "build-finished", "success": true}
|
|
||||||
"#,
|
|
||||||
)
|
)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user