mirror of
https://gitlab.com/gabmus/envision.git
synced 2025-08-03 14:49:04 +00:00
feat: create monado runner from profile
This commit is contained in:
parent
fea107c058
commit
8df6e9eebb
1 changed files with 24 additions and 2 deletions
|
@ -6,6 +6,8 @@ use std::{
|
||||||
process::{Child, Command, Stdio},
|
process::{Child, Command, Stdio},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use crate::profile::Profile;
|
||||||
|
|
||||||
pub struct Runner {
|
pub struct Runner {
|
||||||
environment: HashMap<String, String>,
|
environment: HashMap<String, String>,
|
||||||
command: String,
|
command: String,
|
||||||
|
@ -22,8 +24,8 @@ pub enum RunnerStatus {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Runner {
|
impl Runner {
|
||||||
pub fn new(environment: HashMap<String, String>, command: String, args: Vec<String>) -> Runner {
|
pub fn new(environment: HashMap<String, String>, command: String, args: Vec<String>) -> Self {
|
||||||
Runner {
|
Self {
|
||||||
environment,
|
environment,
|
||||||
command,
|
command,
|
||||||
args,
|
args,
|
||||||
|
@ -33,6 +35,17 @@ impl Runner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn monado_runner_from_profile(profile: Profile) -> Self {
|
||||||
|
Self {
|
||||||
|
environment: profile.environment,
|
||||||
|
command: profile.monado_path,
|
||||||
|
args: vec![],
|
||||||
|
stdout: Vec::new(),
|
||||||
|
stderr: Vec::new(),
|
||||||
|
process: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn start(&mut self) {
|
pub fn start(&mut self) {
|
||||||
match self.process {
|
match self.process {
|
||||||
Some(_) => panic!("Cannot reuse existing Runner"),
|
Some(_) => panic!("Cannot reuse existing Runner"),
|
||||||
|
@ -135,6 +148,8 @@ impl Runner {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
use crate::profile::load_profile;
|
||||||
|
|
||||||
use super::{Runner, RunnerStatus};
|
use super::{Runner, RunnerStatus};
|
||||||
use core::time;
|
use core::time;
|
||||||
use std::{collections::HashMap, thread::sleep};
|
use std::{collections::HashMap, thread::sleep};
|
||||||
|
@ -177,4 +192,11 @@ mod tests {
|
||||||
runner.save_stdout("./target/testout/testlog".into());
|
runner.save_stdout("./target/testout/testlog".into());
|
||||||
runner.save_stderr("./target/testout/testlog".into());
|
runner.save_stderr("./target/testout/testlog".into());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn can_create_from_profile() {
|
||||||
|
Runner::monado_runner_from_profile(
|
||||||
|
load_profile(&"./test/files/profile.json".to_string()).unwrap(),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue