Skip to content

Commit

Permalink
rust: try to work around windows permission problem during testing
Browse files Browse the repository at this point in the history
  • Loading branch information
randommm committed Feb 18, 2024
1 parent c06599c commit f9d581e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions rust/tests/model.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mod common;
use std::{f64::consts::PI, ffi::CString, fs::remove_file};
use std::{f64::consts::PI, ffi::CString, fs::remove_file, fs::rename};

use common::{get_model, model_dir};

Expand Down Expand Up @@ -50,7 +50,14 @@ fn model_compiling() {
base.push(name);
let lib_path = base.join(format!("{}_model.so", name));
let stan_path = base.join(format!("{}.stan", name));
remove_file(lib_path).unwrap();
// try to remove .so file, otherwise try to rename it
remove_file(lib_path.as_path()).unwrap_or_else(|_| {
rename(
lib_path.as_path(),
lib_path.to_str().unwrap().to_owned() + "_old",
)
.unwrap()
});
compile_model(stan_path, vec![], vec![], None).unwrap();

let (lib, data) = get_model(name);
Expand Down

0 comments on commit f9d581e

Please sign in to comment.