File tree Expand file tree Collapse file tree 2 files changed +92
-1
lines changed Expand file tree Collapse file tree 2 files changed +92
-1
lines changed Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ pub struct Workspace<'cfg> {
28
28
config : & ' cfg Config ,
29
29
30
30
// This path is a path to where the current cargo subcommand was invoked
31
- // from. That is, this is the `--manifest-path` argument to Cargo, and
31
+ // from. That is the `--manifest-path` argument to Cargo, and
32
32
// points to the "main crate" that we're going to worry about.
33
33
current_manifest : PathBuf ,
34
34
@@ -363,6 +363,10 @@ impl<'cfg> Workspace<'cfg> {
363
363
}
364
364
365
365
for path in paths:: ancestors ( manifest_path) . skip ( 2 ) {
366
+ if path. ends_with ( "target/package" ) {
367
+ break ;
368
+ }
369
+
366
370
let ances_manifest_path = path. join ( "Cargo.toml" ) ;
367
371
debug ! ( "find_root - trying {}" , ances_manifest_path. display( ) ) ;
368
372
if ances_manifest_path. exists ( ) {
Original file line number Diff line number Diff line change @@ -1027,3 +1027,90 @@ fn package_metadata() {
1027
1027
) ,
1028
1028
) ;
1029
1029
}
1030
+
1031
+ #[ test]
1032
+ fn cargo_metadata_path_to_cargo_toml_project ( ) {
1033
+ let p = project ( "foo" )
1034
+ . file (
1035
+ "Cargo.toml" ,
1036
+ r#"
1037
+ [workspace]
1038
+ members = ["bar"]
1039
+ "# ,
1040
+ )
1041
+ . file ( "bar/Cargo.toml" , & basic_lib_manifest ( "bar" ) )
1042
+ . file ( "bar/src/lib.rs" , "" )
1043
+ . build ( ) ;
1044
+
1045
+ assert_that (
1046
+ p. cargo ( "package" )
1047
+ . arg ( "--manifest-path" )
1048
+ . arg ( p. root ( ) . join ( "bar/Cargo.toml" ) )
1049
+ . cwd ( p. root ( ) . parent ( ) . unwrap ( ) ) ,
1050
+ execs ( ) . with_status ( 0 )
1051
+ ) ;
1052
+
1053
+ assert_that (
1054
+ p. cargo ( "metadata" )
1055
+ . arg ( "--manifest-path" )
1056
+ . arg ( p. root ( ) . join ( "target/package/bar-0.5.0/Cargo.toml" ) ) ,
1057
+ execs ( ) . with_status ( 0 ) . with_json (
1058
+ r#"
1059
+ {
1060
+ "packages": [
1061
+ {
1062
+ "authors": [
1063
+ "wycats@example.com"
1064
+ ],
1065
+ "categories": [],
1066
+ "dependencies": [],
1067
+ "description": null,
1068
+ "features": {},
1069
+ "id": "bar 0.5.0 ([..])",
1070
+ "keywords": [],
1071
+ "license": null,
1072
+ "license_file": null,
1073
+ "manifest_path": "[..]Cargo.toml",
1074
+ "metadata": null,
1075
+ "name": "bar",
1076
+ "readme": null,
1077
+ "repository": null,
1078
+ "source": null,
1079
+ "targets": [
1080
+ {
1081
+ "crate_types": [
1082
+ "lib"
1083
+ ],
1084
+ "kind": [
1085
+ "lib"
1086
+ ],
1087
+ "name": "bar",
1088
+ "src_path": "[..]src[/]lib.rs"
1089
+ }
1090
+ ],
1091
+ "version": "0.5.0"
1092
+ }
1093
+ ],
1094
+ "resolve": {
1095
+ "nodes": [
1096
+ {
1097
+ "dependencies": [],
1098
+ "features": [],
1099
+ "id": "bar 0.5.0 ([..])"
1100
+ }
1101
+ ],
1102
+ "root": "bar 0.5.0 (path+file:[..])"
1103
+ },
1104
+ "target_directory": "[..]",
1105
+ "version": 1,
1106
+ "workspace_members": [
1107
+ "bar 0.5.0 (path+file:[..])"
1108
+ ],
1109
+ "workspace_root": "[..]"
1110
+ }
1111
+ "#
1112
+ ) ,
1113
+ ) ;
1114
+ }
1115
+
1116
+
You can’t perform that action at this time.
0 commit comments