File tree Expand file tree Collapse file tree 2 files changed +53
-3
lines changed Expand file tree Collapse file tree 2 files changed +53
-3
lines changed Original file line number Diff line number Diff line change @@ -60,7 +60,7 @@ struct VendorConfig {
60
60
#[ serde( rename_all = "lowercase" , untagged) ]
61
61
enum VendorSource {
62
62
Directory {
63
- directory : PathBuf ,
63
+ directory : String ,
64
64
} ,
65
65
Registry {
66
66
registry : Option < String > ,
@@ -298,7 +298,10 @@ fn sync(
298
298
config. insert (
299
299
merged_source_name. to_string ( ) ,
300
300
VendorSource :: Directory {
301
- directory : opts. destination . to_path_buf ( ) ,
301
+ // Windows-flavour paths are valid here on Windows but Unix.
302
+ // This backslash normalization is for making output paths more
303
+ // cross-platform compatible.
304
+ directory : opts. destination . to_string_lossy ( ) . replace ( "\\ " , "/" ) ,
302
305
} ,
303
306
) ;
304
307
} else if !dest_dir_already_exists {
Original file line number Diff line number Diff line change @@ -69,6 +69,53 @@ directory = "vendor"
69
69
. run ( ) ;
70
70
}
71
71
72
+ #[ cargo_test]
73
+ fn vendor_path_specified ( ) {
74
+ let p = project ( )
75
+ . file (
76
+ "Cargo.toml" ,
77
+ r#"
78
+ [package]
79
+ name = "foo"
80
+ version = "0.1.0"
81
+
82
+ [dependencies]
83
+ log = "0.3.5"
84
+ "# ,
85
+ )
86
+ . file ( "src/lib.rs" , "" )
87
+ . build ( ) ;
88
+
89
+ Package :: new ( "log" , "0.3.5" ) . publish ( ) ;
90
+
91
+ let path = if cfg ! ( windows) {
92
+ r#"deps\.vendor"#
93
+ } else {
94
+ "deps/.vendor"
95
+ } ;
96
+
97
+ let output = p
98
+ . cargo ( "vendor --respect-source-config" )
99
+ . arg ( path)
100
+ . exec_with_output ( )
101
+ . unwrap ( ) ;
102
+ // Assert against original output to ensure that
103
+ // path is normalized by `ops::vendor` on Windows.
104
+ assert_eq ! (
105
+ & String :: from_utf8( output. stdout) . unwrap( ) ,
106
+ r#"
107
+ [source.crates-io]
108
+ replace-with = "vendored-sources"
109
+
110
+ [source.vendored-sources]
111
+ directory = "deps/.vendor"
112
+ "#
113
+ ) ;
114
+
115
+ let lock = p. read_file ( "deps/.vendor/log/Cargo.toml" ) ;
116
+ assert ! ( lock. contains( "version = \" 0.3.5\" " ) ) ;
117
+ }
118
+
72
119
fn add_vendor_config ( p : & Project ) {
73
120
p. change_file (
74
121
".cargo/config" ,
@@ -117,7 +164,7 @@ fn package_exclude() {
117
164
. publish ( ) ;
118
165
119
166
p. cargo ( "vendor --respect-source-config" ) . run ( ) ;
120
- let csum = dbg ! ( p. read_file( "vendor/bar/.cargo-checksum.json" ) ) ;
167
+ let csum = p. read_file ( "vendor/bar/.cargo-checksum.json" ) ;
121
168
assert ! ( csum. contains( ".include" ) ) ;
122
169
assert ! ( !csum. contains( ".exclude" ) ) ;
123
170
assert ! ( !csum. contains( ".dotdir/exclude" ) ) ;
You can’t perform that action at this time.
0 commit comments