Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
amrbashir committed Jul 3, 2024
1 parent 1333d74 commit 2eaf041
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions crates/nsis-process/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ impl DerefMut for OwnedHandle {

#[cfg(test)]
mod tests {

use super::*;

#[test]
Expand All @@ -359,19 +360,27 @@ mod tests {
}

#[test]
#[cfg(feature = "test")]
fn spawn_with_spaces() {
extern crate std;
use alloc::format;
use alloc::string::ToString;

let current = std::env::current_dir().unwrap();

let dir = current.join("dir space");
std::fs::create_dir_all(dir).unwrap();
std::fs::create_dir_all(&dir).unwrap();

let systemroot = std::env::var("SYSTEMROOT").unwrap_or_else(|_| "C:\\Windows".to_owned());

let systemroot = std::env::var("SYSTEMROOT").unwrap_or("C:\\Windows");
let cmd = format!("{systemroot}\\System32\\cmd.exe");
let cmd_out = dir.join("cmdout.exe");

let cmd = format!("{systemroot}\\System32\\cmd.exe");
let cmd_out = dir.join("cmdout.exe");
std::fs::copy(cmd, &cmd_out).unwrap();

std::fs::copy(cmd, cmd_out).unwrap();
assert!(unsafe { run_as_user(cmd_out.display().to_string().as_str(), "/c timeout 3") });

unsafe { run_as_user(cmd_out.display().to_string().as_str(), "/c timeout 3") };
std::thread::sleep(std::time::Duration::from_secs(5));
std::fs::remove_file(cmd_out).unwrap();
}
}

0 comments on commit 2eaf041

Please sign in to comment.