Skip to content

Commit

Permalink
test: run threading tests in a short loop
Browse files Browse the repository at this point in the history
to make sure there are no threading issues
  • Loading branch information
eugenesvk committed Dec 9, 2024
1 parent 674d7be commit bbb1289
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions tests/osakit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,8 @@ use trash::{
TrashContext,
};
use trash_tests::{get_unique_name, init_logging}; // not pub, so import directly
// use std::ffi::OsStr;
// use std::os::unix::ffi::OsStrExt;
use std::fs::File;
use std::path::PathBuf;
// use std::process::Command;

use libtest_mimic::{Arguments, Trial};
#[ignore]
Expand Down Expand Up @@ -46,16 +43,19 @@ pub fn test_main_thread_delete_with_finder_osakit_with_info() {
let mut path2 = PathBuf::from(get_unique_name());
path1.set_extension(r#"a"b,"#);
path2.set_extension(r#"x80=%80 slash=\ pc=% quote=" comma=,"#);
File::create_new(&path1).unwrap();
File::create_new(&path2).unwrap();
let trashed_items = trash_ctx.delete_all_with_info(&[path1.clone(), path2.clone()]).unwrap().unwrap(); //Ok + Some trashed paths
assert!(File::open(&path1).is_err()); // original files deleted
assert!(File::open(&path2).is_err());
for item in trashed_items {
let trashed_path = item.id;
assert!(!File::open(&trashed_path).is_err()); // returned trash items exist
std::fs::remove_file(&trashed_path).unwrap(); // clean up
assert!(File::open(&trashed_path).is_err()); // cleaned up trash items
for _i in 1..10 {
// run a few times since previously threading issues didn't always appear on 1st run
File::create_new(&path1).unwrap();
File::create_new(&path2).unwrap();
let trashed_items = trash_ctx.delete_all_with_info(&[path1.clone(), path2.clone()]).unwrap().unwrap(); //Ok + Some trashed paths
assert!(File::open(&path1).is_err()); // original files deleted
assert!(File::open(&path2).is_err());
for item in trashed_items {
let trashed_path = item.id;
assert!(!File::open(&trashed_path).is_err()); // returned trash items exist
std::fs::remove_file(&trashed_path).unwrap(); // clean up
assert!(File::open(&trashed_path).is_err()); // cleaned up trash items
}
}

// test a single file (in case returned paths aren't an array anymore)
Expand Down

0 comments on commit bbb1289

Please sign in to comment.