mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-21 08:41:35 +00:00
test-support: Add ability to add new local dependencies to Cargo.toml
This commit is contained in:
@ -42,6 +42,8 @@ pub fn project() -> Project {
|
|||||||
[lib]
|
[lib]
|
||||||
crate-type = ["cdylib"]
|
crate-type = ["cdylib"]
|
||||||
|
|
||||||
|
# XXX: It is important that `[dependencies]` is the last section
|
||||||
|
# here, so that `add_local_dependency` functions correctly!
|
||||||
[dependencies]
|
[dependencies]
|
||||||
wasm-bindgen = {{ path = '{}' }}
|
wasm-bindgen = {{ path = '{}' }}
|
||||||
"#, IDX.with(|x| *x), dir.display())),
|
"#, IDX.with(|x| *x), dir.display())),
|
||||||
@ -142,6 +144,20 @@ impl Project {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn add_local_dependency(&mut self, name: &str, path: &str) -> &mut Project {
|
||||||
|
{
|
||||||
|
let cargo_toml = self.files
|
||||||
|
.iter_mut()
|
||||||
|
.find(|f| f.0 == "Cargo.toml")
|
||||||
|
.expect("should have Cargo.toml file!");
|
||||||
|
cargo_toml.1.push_str(name);
|
||||||
|
cargo_toml.1.push_str(" = { path = \"");
|
||||||
|
cargo_toml.1.push_str(path);
|
||||||
|
cargo_toml.1.push_str("\" }");
|
||||||
|
}
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
pub fn test(&mut self) {
|
pub fn test(&mut self) {
|
||||||
let root = root();
|
let root = root();
|
||||||
drop(fs::remove_dir_all(&root));
|
drop(fs::remove_dir_all(&root));
|
||||||
|
Reference in New Issue
Block a user