|
6 | 6 | use bitcoin::hashes::Hash;
|
7 | 7 | use reqwest::Client;
|
8 | 8 | use serde::{Deserialize, Serialize};
|
| 9 | +use std::io::BufRead; |
9 | 10 | use std::os::unix::fs::PermissionsExt;
|
10 | 11 | use std::path::{Path, PathBuf};
|
11 | 12 | use std::process::{Child, Command};
|
@@ -37,11 +38,33 @@ struct Server(Child);
|
37 | 38 |
|
38 | 39 | impl Server {
|
39 | 40 | fn launch(filename: &str) -> Self {
|
40 |
| - Self( |
41 |
| - Command::new(filename) |
42 |
| - .spawn() |
43 |
| - .expect("failed to start server"), |
44 |
| - ) |
| 41 | + //let mut command = Command::new(filename); |
| 42 | + |
| 43 | + let mut command = Command::new("stdbuf"); |
| 44 | + command |
| 45 | + .arg("-oL") // Line buffering for stdout |
| 46 | + .arg(filename) |
| 47 | + .stdout(std::process::Stdio::piped()); |
| 48 | + |
| 49 | + command.stdout(std::process::Stdio::piped()); // Capture stdout |
| 50 | + |
| 51 | + let mut child = command.spawn().expect("failed to start server"); |
| 52 | + |
| 53 | + // Take stdout handle from child |
| 54 | + let stdout = child.stdout.take().unwrap(); |
| 55 | + |
| 56 | + // Spawn a thread to process the output, so we can print it indented for clarity. |
| 57 | + std::thread::spawn(move || { |
| 58 | + let reader = std::io::BufReader::new(stdout); |
| 59 | + for line in reader.lines() { |
| 60 | + match line { |
| 61 | + Ok(line) => println!("\t\t{}", line), |
| 62 | + Err(e) => eprintln!("Error reading line: {}", e), |
| 63 | + } |
| 64 | + } |
| 65 | + }); |
| 66 | + |
| 67 | + Self(child) |
45 | 68 | }
|
46 | 69 | }
|
47 | 70 |
|
@@ -127,7 +150,8 @@ pub async fn test_simulators_after_pairing(
|
127 | 150 | download_simulators().await.unwrap()
|
128 | 151 | };
|
129 | 152 | for simulator_filename in simulator_filenames {
|
130 |
| - println!("Simulator tests using {}", simulator_filename); |
| 153 | + println!(); |
| 154 | + println!("\tSimulator tests using {}", simulator_filename); |
131 | 155 | let _server = Server::launch(&simulator_filename);
|
132 | 156 | let noise_config = Box::new(bitbox_api::NoiseConfigNoCache {});
|
133 | 157 | let bitbox = bitbox_api::BitBox::<bitbox_api::runtime::TokioRuntime>::from_simulator(
|
|
0 commit comments