Skip to content

Commit

Permalink
Kill ord on drop
Browse files Browse the repository at this point in the history
  • Loading branch information
casey committed Jan 13, 2023
1 parent 4156fc0 commit 72cac60
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions tests/preview.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
use super::*;

struct KillOnDrop(std::process::Child);

impl Drop for KillOnDrop {
fn drop(&mut self) {
self.0.kill().unwrap()
}
}

#[test]
#[ignore]
fn run() {
Expand All @@ -12,12 +20,10 @@ fn run() {
.port();

let builder = CommandBuilder::new(format!("preview --http-port {port} foo.txt"))
.rpc_server(&rpc_server)
.write("foo.txt", "TEST_INSCRIPTION");

let mut command = builder.command();
.write("foo.txt", "foo")
.rpc_server(&rpc_server);

let mut child = command.spawn().unwrap();
let _child = KillOnDrop(builder.command().spawn().unwrap());

for attempt in 0.. {
if let Ok(response) = reqwest::blocking::get(format!("http://127.0.0.1:{port}/status")) {
Expand All @@ -41,6 +47,4 @@ fn run() {
.unwrap()
.contains("<a href=/inscription/")
);

child.kill().unwrap();
}

0 comments on commit 72cac60

Please sign in to comment.