Skip to content

Commit

Permalink
Fix test that creates external data file.
Browse files Browse the repository at this point in the history
* The file itself is moved into an ignored data directory, so it never shows up in VCS.
* The model is dropped before deleting the file, so it can be deleted (this is important on Windows).
  • Loading branch information
KarelPeeters committed Oct 26, 2023
1 parent 9371671 commit 94c8d91
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 3 additions & 0 deletions data/ignored/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# ignore everything except .gitignore, ensuring this directory actually exists
*
!.gitignore
10 changes: 7 additions & 3 deletions src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1510,9 +1510,10 @@ mod tests {

#[test]
fn set_str_param() {
let output_path = "data/ignored/test.vbc";
let mut model = Model::new()
.hide_output()
.set_str_param("visual/vbcfilename", "test.vbc")
.set_str_param("visual/vbcfilename", output_path)
.unwrap()
.include_default_plugins()
.create_prob("test")
Expand All @@ -1527,8 +1528,11 @@ mod tests {
assert_eq!(status, Status::Optimal);
assert_eq!(solved_model.obj_val(), 3.);

assert!(Path::new("test.vbc").exists());
fs::remove_file("test.vbc").unwrap();
assert!(Path::new(output_path).exists());

// drop model so the file is closed and it can be removed
drop(solved_model);
fs::remove_file(output_path).unwrap();
}

#[test]
Expand Down

0 comments on commit 94c8d91

Please sign in to comment.