mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-03-16 02:00:51 +00:00
test-support: Add ability to add new local dependencies to Cargo.toml
This commit is contained in:
parent
1a9e031ed0
commit
9e24dabe9c
@ -42,6 +42,8 @@ pub fn project() -> Project {
|
||||
[lib]
|
||||
crate-type = ["cdylib"]
|
||||
|
||||
# XXX: It is important that `[dependencies]` is the last section
|
||||
# here, so that `add_local_dependency` functions correctly!
|
||||
[dependencies]
|
||||
wasm-bindgen = {{ path = '{}' }}
|
||||
"#, IDX.with(|x| *x), dir.display())),
|
||||
@ -142,6 +144,20 @@ impl Project {
|
||||
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) {
|
||||
let root = root();
|
||||
drop(fs::remove_dir_all(&root));
|
||||
|
Loading…
x
Reference in New Issue
Block a user