feat(service): started service
This commit is contained in:
@@ -6,14 +6,10 @@ use std::io::{self, Write};
|
||||
use std::path::PathBuf;
|
||||
use std::process::{Command, Output};
|
||||
use std::str;
|
||||
use std::sync::LazyLock;
|
||||
use std::sync::OnceLock;
|
||||
|
||||
// Absolute path of the nextsync executable
|
||||
static EXE_PATH: LazyLock<PathBuf> = LazyLock::new(|| {
|
||||
let mut exe_path = env::current_dir().unwrap();
|
||||
exe_path = exe_path.join("target/debug/nextsync");
|
||||
exe_path
|
||||
});
|
||||
static EXE_PATH: OnceLock<PathBuf> = OnceLock::new();
|
||||
|
||||
pub struct ClientTest {
|
||||
volume: String, // temp dir for the test
|
||||
@@ -30,9 +26,11 @@ pub fn get_random_test_id() -> String {
|
||||
|
||||
impl ClientTest {
|
||||
pub fn new(id: &str) -> Self {
|
||||
// init the EXE_PATH for the first time
|
||||
let _ = &*EXE_PATH;
|
||||
|
||||
let _ = EXE_PATH.get_or_init(|| {
|
||||
let mut exe_path = env::current_dir().unwrap();
|
||||
exe_path = exe_path.join("target/debug/nextsync");
|
||||
exe_path
|
||||
});
|
||||
let mut test_id = id.to_string();
|
||||
test_id.push_str("_");
|
||||
test_id.push_str(&get_random_test_id());
|
||||
@@ -106,7 +104,7 @@ impl ClientTest {
|
||||
}
|
||||
|
||||
pub fn exec(&mut self, args: &str) -> Output {
|
||||
let output = Command::new(&*EXE_PATH.to_str().unwrap())
|
||||
let output = Command::new(EXE_PATH.get().unwrap().to_str().unwrap())
|
||||
.current_dir(self.volume.clone())
|
||||
.args(args.split(" "))
|
||||
.output()
|
||||
|
||||
Reference in New Issue
Block a user