From 26d3e7b46eda7720e9439ba5c0f96befefa306c1 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Tue, 23 Jul 2024 13:49:38 -0500 Subject: [PATCH] test: Migrate json install doc to snapbox --- tests/testsuite/doc.rs | 184 +++++++++++++++++++++++------------------ 1 file changed, 104 insertions(+), 80 deletions(-) diff --git a/tests/testsuite/doc.rs b/tests/testsuite/doc.rs index 713c841c5ad3..9c427b98a918 100644 --- a/tests/testsuite/doc.rs +++ b/tests/testsuite/doc.rs @@ -1879,24 +1879,29 @@ 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", + "children": "{...}", + "code": "{...}", + "level": "error", + "message": "{...}", + "rendered": "{...}", + "spans": "{...}" + }, + "package_id": "path+[ROOTURL]/foo#0.0.1", + "reason": "compiler-message", + "target": "{...}" + }, + "{...}" +] +"##]] + .is_json() + .against_jsonlines(), ) .run(); } @@ -1911,76 +1916,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", + .with_stdout_data( + str![[r#" +[ + { + "executable": null, + "features": [], + "filenames": [ + "[ROOT]/foo/target/debug/deps/libfoo-[HASH].rmeta" + ], + "fresh": false, "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 - }, + "package_id": "path+[ROOTURL]/foo#0.0.1", "profile": "{...}", - "features": [], - "filenames": ["[ROOT]/foo/target/debug/deps/libfoo-[..].rmeta"], - "executable": null, - "fresh": false -} - -{ "reason": "compiler-artifact", - "package_id": "path+file:///[..]/foo#0.0.1", + "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/foo/index.html" + ], + "fresh": false, "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 - }, + "package_id": "path+[ROOTURL]/foo#0.0.1", "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", + "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", - "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"], - "executable": null, - "fresh": false -} - -{"reason":"build-finished","success":true} -"#, + "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(); }