@@ -926,3 +926,155 @@ source = "patched+registry+https://github.com/rust-lang/crates.io-index?name=bar
926
926
"# ;
927
927
assert_match_exact ( expected, & actual) ;
928
928
}
929
+
930
+ #[ cargo_test( requires_patch) ]
931
+ fn cargo_metadata ( ) {
932
+ let p = patched_project ( ) ;
933
+
934
+ p. cargo ( "generate-lockfile" )
935
+ . masquerade_as_nightly_cargo ( & [ "patch-files" ] )
936
+ . with_stderr (
937
+ "\
938
+ [UPDATING] `dummy-registry` index
939
+ [DOWNLOADING] crates ...
940
+ [DOWNLOADED] bar v1.0.0 (registry `dummy-registry`)
941
+ [PATCHING] bar v1.0.0
942
+ [LOCKING] [..]
943
+ " ,
944
+ )
945
+ . run ( ) ;
946
+
947
+ p. cargo ( "metadata" )
948
+ . masquerade_as_nightly_cargo ( & [ "patch-files" ] )
949
+ . with_json (
950
+ r#"
951
+ {
952
+ "packages": [
953
+ {
954
+ "name": "bar",
955
+ "version": "1.0.0",
956
+ "id": "patched+registry+https://github.com/rust-lang/crates.io-index?name=bar&version=1.0.0&patch=patches%2Fhello.patch#[email protected] ",
957
+ "license": null,
958
+ "license_file": null,
959
+ "description": null,
960
+ "source": "patched+registry+https://github.com/rust-lang/crates.io-index?name=bar&version=1.0.0&patch=patches%2Fhello.patch",
961
+ "dependencies": [],
962
+ "targets": [
963
+ {
964
+ "kind": [
965
+ "lib"
966
+ ],
967
+ "crate_types": [
968
+ "lib"
969
+ ],
970
+ "name": "bar",
971
+ "src_path": "[..]/.cargo/patched-src/github.lhy31512.workers.dev-[..]/bar-1.0.0/[..]/src/lib.rs",
972
+ "edition": "2015",
973
+ "doc": true,
974
+ "doctest": true,
975
+ "test": true
976
+ }
977
+ ],
978
+ "features": {},
979
+ "manifest_path": "[..]/.cargo/patched-src/github.lhy31512.workers.dev-[..]/bar-1.0.0/[..]/Cargo.toml",
980
+ "metadata": null,
981
+ "publish": null,
982
+ "authors": [],
983
+ "categories": [],
984
+ "keywords": [],
985
+ "readme": null,
986
+ "repository": null,
987
+ "homepage": null,
988
+ "documentation": null,
989
+ "edition": "2015",
990
+ "links": null,
991
+ "default_run": null,
992
+ "rust_version": null
993
+ },
994
+ {
995
+ "name": "foo",
996
+ "version": "0.0.0",
997
+ "id": "[..]",
998
+ "license": null,
999
+ "license_file": null,
1000
+ "description": null,
1001
+ "source": null,
1002
+ "dependencies": "{...}",
1003
+ "targets": "{...}",
1004
+ "features": {},
1005
+ "manifest_path": "[..]",
1006
+ "metadata": null,
1007
+ "publish": [],
1008
+ "authors": [],
1009
+ "categories": [],
1010
+ "keywords": [],
1011
+ "readme": null,
1012
+ "repository": null,
1013
+ "homepage": null,
1014
+ "documentation": null,
1015
+ "edition": "2015",
1016
+ "links": null,
1017
+ "default_run": null,
1018
+ "rust_version": null
1019
+ }
1020
+ ],
1021
+ "workspace_members": "{...}",
1022
+ "workspace_default_members": "{...}",
1023
+ "resolve": {
1024
+ "nodes": [
1025
+ {
1026
+ "id": "patched+registry+https://github.com/rust-lang/crates.io-index?name=bar&version=1.0.0&patch=patches%2Fhello.patch#[email protected] ",
1027
+ "dependencies": [],
1028
+ "deps": [],
1029
+ "features": []
1030
+ },
1031
+ {
1032
+ "id": "[..]foo#0.0.0",
1033
+ "dependencies": [
1034
+ "patched+registry+https://github.com/rust-lang/crates.io-index?name=bar&version=1.0.0&patch=patches%2Fhello.patch#[email protected] "
1035
+ ],
1036
+ "deps": [
1037
+ {
1038
+ "name": "bar",
1039
+ "pkg": "patched+registry+https://github.com/rust-lang/crates.io-index?name=bar&version=1.0.0&patch=patches%2Fhello.patch#[email protected] ",
1040
+ "dep_kinds": "{...}"
1041
+ }
1042
+ ],
1043
+ "features": []
1044
+ }
1045
+ ],
1046
+ "root": "[..]"
1047
+ },
1048
+ "target_directory": "[..]",
1049
+ "version": 1,
1050
+ "workspace_root": "[..]",
1051
+ "metadata": null
1052
+ }
1053
+ "# ,
1054
+ )
1055
+
1056
+ . run ( ) ;
1057
+ }
1058
+
1059
+ #[ cargo_test( requires_patch) ]
1060
+ fn cargo_pkgid ( ) {
1061
+ let p = patched_project ( ) ;
1062
+
1063
+ p. cargo ( "generate-lockfile" )
1064
+ . masquerade_as_nightly_cargo ( & [ "patch-files" ] )
1065
+ . with_stderr (
1066
+ "\
1067
+ [UPDATING] `dummy-registry` index
1068
+ [DOWNLOADING] crates ...
1069
+ [DOWNLOADED] bar v1.0.0 (registry `dummy-registry`)
1070
+ [PATCHING] bar v1.0.0
1071
+ [LOCKING] [..]
1072
+ " ,
1073
+ )
1074
+ . run ( ) ;
1075
+
1076
+ p. cargo ( "pkgid bar" )
1077
+ . masquerade_as_nightly_cargo ( & [ "patch-files" ] )
1078
+ . with_stdout ( "patched+registry+https://github.com/rust-lang/crates.io-index?name=bar&version=1.0.0&patch=patches%2Fhello.patch#[email protected] " )
1079
+ . run ( ) ;
1080
+ }
0 commit comments