Skip to content

Commit

Permalink
print stdout of rama services in background
Browse files Browse the repository at this point in the history
rama-cli integration tests of services
  • Loading branch information
glendc committed Jun 2, 2024
1 parent 9a3e526 commit 35291a8
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions tests/cli_tests/utils/mod.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#![allow(dead_code)]

use std::{
io::{BufRead, BufReader, Lines},
process::{Child, ChildStdout},
io::{BufRead, BufReader},
process::Child,
thread,
};

#[derive(Debug)]
/// A wrapper around a rama service process.
pub struct RamaService {
stdout: Lines<BufReader<ChildStdout>>,
process: Child,
}

Expand Down Expand Up @@ -39,7 +39,14 @@ impl RamaService {
}
}

Self { stdout, process }
thread::spawn(move || {
for line in stdout {
let line = line.unwrap();
println!("rama ip >> {}", line);
}
});

Self { process }
}

/// Start the rama echo service with the given port.
Expand Down Expand Up @@ -68,12 +75,14 @@ impl RamaService {
}
}

Self { stdout, process }
}
thread::spawn(move || {
for line in stdout {
let line = line.unwrap();
println!("rama echo >> {}", line);
}
});

/// try to read a line from the stdout of the service
pub fn read_stdout_line(&mut self) -> Option<String> {
self.stdout.next().and_then(|r| r.ok())
Self { process }
}

/// Run any rama cmd
Expand Down

0 comments on commit 35291a8

Please sign in to comment.