Skip to content

Commit 378e292

Browse files
committed
test: cargo-vendor with path specified
1 parent 6651781 commit 378e292

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

tests/testsuite/vendor.rs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,53 @@ directory = "vendor"
6969
.run();
7070
}
7171

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+
72119
fn add_vendor_config(p: &Project) {
73120
p.change_file(
74121
".cargo/config",

0 commit comments

Comments
 (0)