Skip to content

Commit 22d4ef2

Browse files
committed
Add buildtest for BuildBuilder::patch_with_path
1 parent a5a4cfc commit 22d4ef2

File tree

5 files changed

+50
-0
lines changed

5 files changed

+50
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[package]
2+
name = "path-based-patch"
3+
version = "0.1.0"
4+
authors = ["Pietro Albini <[email protected]>"]
5+
edition = "2018"
6+
7+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
8+
9+
[dependencies]
10+
empty-library = "1.0.0"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[package]
2+
name = "empty-library"
3+
version = "1.0.1"
4+
authors = ["Pietro Albini <[email protected]>"]
5+
edition = "2018"
6+
7+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
8+
9+
[dependencies]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
pub fn dummy() {
2+
println!("This is coming from the patch!");
3+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
fn main() {
2+
println!("Hello, world!");
3+
empty_library::dummy();
4+
}

tests/buildtest/mod.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,30 @@ fn test_hello_world() {
2626
});
2727
}
2828

29+
#[test]
30+
fn path_based_patch() {
31+
runner::run("path-based-patch", |run| {
32+
run.build(SandboxBuilder::new().enable_networking(false), |builder| {
33+
builder
34+
.patch_with_path("empty-library", "./patch")
35+
.run(move |build| {
36+
let storage = rustwide::logging::LogStorage::new(LevelFilter::Info);
37+
rustwide::logging::capture(&storage, || -> Result<_, Error> {
38+
build.cargo().args(&["run"]).run()?;
39+
Ok(())
40+
})?;
41+
42+
assert!(storage.to_string().contains("[stdout] Hello, world!\n"));
43+
assert!(storage
44+
.to_string()
45+
.contains("[stdout] This is coming from the patch!\n"));
46+
Ok(())
47+
})
48+
})?;
49+
Ok(())
50+
});
51+
}
52+
2953
#[test]
3054
fn test_process_lines() {
3155
runner::run("process-lines", |run| {

0 commit comments

Comments
 (0)