Skip to content

Commit

Permalink
Remove unused TestProcess::id
Browse files Browse the repository at this point in the history
  • Loading branch information
djc committed Jun 15, 2024
1 parent 37651ff commit 68deacd
Showing 1 changed file with 0 additions and 11 deletions.
11 changes: 0 additions & 11 deletions src/currentprocess.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ use std::{
sync::{Arc, Mutex},
};

#[cfg(feature = "test")]
use rand::{thread_rng, Rng};
use tracing_subscriber::util::SubscriberInitExt;

pub mod filesource;
Expand Down Expand Up @@ -287,7 +285,6 @@ pub struct TestProcess {
pub cwd: PathBuf,
pub args: Vec<String>,
pub vars: HashMap<String, String>,
pub id: u64,
pub stdin: filesource::TestStdinInner,
pub stdout: filesource::TestWriterInner,
pub stderr: filesource::TestWriterInner,
Expand All @@ -305,20 +302,12 @@ impl TestProcess {
cwd: cwd.as_ref().to_path_buf(),
args: args.iter().map(|s| s.as_ref().to_string()).collect(),
vars,
id: TestProcess::new_id(),
stdin: Arc::new(Mutex::new(Cursor::new(stdin.to_string()))),
stdout: Arc::new(Mutex::new(Vec::new())),
stderr: Arc::new(Mutex::new(Vec::new())),
}
}

fn new_id() -> u64 {
let low_bits: u64 = std::process::id() as u64;
let mut rng = thread_rng();
let high_bits = rng.gen_range(0..u32::MAX) as u64;
high_bits << 32 | low_bits
}

/// Extracts the stdout from the process
pub fn get_stdout(&self) -> Vec<u8> {
self.stdout
Expand Down

0 comments on commit 68deacd

Please sign in to comment.