@@ -4,6 +4,7 @@ use cargo_test_support::basic_manifest;
44use cargo_test_support:: compare:: assert_e2e;
55use cargo_test_support:: git;
66use cargo_test_support:: paths;
7+ use cargo_test_support:: prelude:: * ;
78use cargo_test_support:: project;
89use cargo_test_support:: registry;
910use cargo_test_support:: registry:: Package ;
@@ -953,3 +954,190 @@ source = "patched+registry+https://github.com/rust-lang/crates.io-index?name=bar
953954"## ] ] ;
954955 assert_e2e ( ) . eq ( actual, expected) ;
955956}
957+
958+ #[ cargo_test( requires_patch) ]
959+ fn cargo_metadata ( ) {
960+ let p = patched_project ( ) ;
961+
962+ p. cargo ( "generate-lockfile" )
963+ . masquerade_as_nightly_cargo ( & [ "patch-files" ] )
964+ . with_stderr_data ( str![ [ r#"
965+ [UPDATING] `dummy-registry` index
966+ [DOWNLOADING] crates ...
967+ [DOWNLOADED] bar v1.0.0 (registry `dummy-registry`)
968+ [PATCHING] bar v1.0.0
969+ [LOCKING] 2 packages to latest compatible versions
970+
971+ "# ] ] )
972+ . run ( ) ;
973+
974+ p. cargo ( "metadata" )
975+ . masquerade_as_nightly_cargo ( & [ "patch-files" ] )
976+ . with_stdout_data ( str![ [ r#"
977+ {
978+ "metadata": null,
979+ "packages": [
980+ {
981+ "authors": [],
982+ "categories": [],
983+ "default_run": null,
984+ "dependencies": [],
985+ "description": null,
986+ "documentation": null,
987+ "edition": "2015",
988+ "features": {},
989+ "homepage": null,
990+ "id": "patched+registry+https://github.com/rust-lang/crates.io-index?name=bar&version=1.0.0&patch=patches%2Fhello.patch#bar@1.0.0",
991+ "keywords": [],
992+ "license": null,
993+ "license_file": null,
994+ "links": null,
995+ "manifest_path": "[ROOT]/home/.cargo/patched-src/github.com-1ecc6299db9ec823/bar-1.0.0/46806b943777e31e/Cargo.toml",
996+ "metadata": null,
997+ "name": "bar",
998+ "publish": null,
999+ "readme": null,
1000+ "repository": null,
1001+ "rust_version": null,
1002+ "source": "patched+registry+https://github.com/rust-lang/crates.io-index?name=bar&version=1.0.0&patch=patches%2Fhello.patch",
1003+ "targets": [
1004+ {
1005+ "crate_types": [
1006+ "lib"
1007+ ],
1008+ "doc": true,
1009+ "doctest": true,
1010+ "edition": "2015",
1011+ "kind": [
1012+ "lib"
1013+ ],
1014+ "name": "bar",
1015+ "src_path": "[ROOT]/home/.cargo/patched-src/github.com-1ecc6299db9ec823/bar-1.0.0/46806b943777e31e/src/lib.rs",
1016+ "test": true
1017+ }
1018+ ],
1019+ "version": "1.0.0"
1020+ },
1021+ {
1022+ "authors": [],
1023+ "categories": [],
1024+ "default_run": null,
1025+ "dependencies": [
1026+ {
1027+ "features": [],
1028+ "kind": null,
1029+ "name": "bar",
1030+ "optional": false,
1031+ "registry": null,
1032+ "rename": null,
1033+ "req": "^1",
1034+ "source": "registry+https://github.com/rust-lang/crates.io-index",
1035+ "target": null,
1036+ "uses_default_features": true
1037+ }
1038+ ],
1039+ "description": null,
1040+ "documentation": null,
1041+ "edition": "2015",
1042+ "features": {},
1043+ "homepage": null,
1044+ "id": "path+[ROOTURL]/foo#0.0.0",
1045+ "keywords": [],
1046+ "license": null,
1047+ "license_file": null,
1048+ "links": null,
1049+ "manifest_path": "[ROOT]/foo/Cargo.toml",
1050+ "metadata": null,
1051+ "name": "foo",
1052+ "publish": [],
1053+ "readme": null,
1054+ "repository": null,
1055+ "rust_version": null,
1056+ "source": null,
1057+ "targets": [
1058+ {
1059+ "crate_types": [
1060+ "bin"
1061+ ],
1062+ "doc": true,
1063+ "doctest": false,
1064+ "edition": "2015",
1065+ "kind": [
1066+ "bin"
1067+ ],
1068+ "name": "foo",
1069+ "src_path": "[ROOT]/foo/src/main.rs",
1070+ "test": true
1071+ }
1072+ ],
1073+ "version": "0.0.0"
1074+ }
1075+ ],
1076+ "resolve": {
1077+ "nodes": [
1078+ {
1079+ "dependencies": [],
1080+ "deps": [],
1081+ "features": [],
1082+ "id": "patched+registry+https://github.com/rust-lang/crates.io-index?name=bar&version=1.0.0&patch=patches%2Fhello.patch#bar@1.0.0"
1083+ },
1084+ {
1085+ "dependencies": [
1086+ "patched+registry+https://github.com/rust-lang/crates.io-index?name=bar&version=1.0.0&patch=patches%2Fhello.patch#bar@1.0.0"
1087+ ],
1088+ "deps": [
1089+ {
1090+ "dep_kinds": [
1091+ {
1092+ "kind": null,
1093+ "target": null
1094+ }
1095+ ],
1096+ "name": "bar",
1097+ "pkg": "patched+registry+https://github.com/rust-lang/crates.io-index?name=bar&version=1.0.0&patch=patches%2Fhello.patch#bar@1.0.0"
1098+ }
1099+ ],
1100+ "features": [],
1101+ "id": "path+[ROOTURL]/foo#0.0.0"
1102+ }
1103+ ],
1104+ "root": "path+[ROOTURL]/foo#0.0.0"
1105+ },
1106+ "target_directory": "[ROOT]/foo/target",
1107+ "version": 1,
1108+ "workspace_default_members": [
1109+ "path+[ROOTURL]/foo#0.0.0"
1110+ ],
1111+ "workspace_members": [
1112+ "path+[ROOTURL]/foo#0.0.0"
1113+ ],
1114+ "workspace_root": "[ROOT]/foo"
1115+ }
1116+ "# ] ] . json ( ) )
1117+ . run ( ) ;
1118+ }
1119+
1120+ #[ cargo_test( requires_patch) ]
1121+ fn cargo_pkgid ( ) {
1122+ let p = patched_project ( ) ;
1123+
1124+ p. cargo ( "generate-lockfile" )
1125+ . masquerade_as_nightly_cargo ( & [ "patch-files" ] )
1126+ . with_stderr_data ( str![ [ r#"
1127+ [UPDATING] `dummy-registry` index
1128+ [DOWNLOADING] crates ...
1129+ [DOWNLOADED] bar v1.0.0 (registry `dummy-registry`)
1130+ [PATCHING] bar v1.0.0
1131+ [LOCKING] 2 packages to latest compatible versions
1132+
1133+ "# ] ] )
1134+ . run ( ) ;
1135+
1136+ p. cargo ( "pkgid bar" )
1137+ . masquerade_as_nightly_cargo ( & [ "patch-files" ] )
1138+ . with_stdout_data ( str![ [ r#"
1139+ patched+registry+https://github.com/rust-lang/crates.io-index?name=bar&version=1.0.0&patch=patches%2Fhello.patch#bar@1.0.0
1140+
1141+ "# ] ] )
1142+ . run ( ) ;
1143+ }
0 commit comments