Skip to content

Commit

Permalink
Fix tests on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasschafer committed Nov 30, 2024
1 parent 2de5d52 commit 1e603c7
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions tests/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use scooter::{
App, EventHandler, ReplaceResult, ReplaceState, Screen, SearchFields, SearchResult, SearchState,
};
use std::cmp::max;
use std::fs::{create_dir_all, File};
use std::fs::{self, create_dir_all, File};
use std::io::Write;
use std::mem;
use std::path::{Path, PathBuf};
Expand Down Expand Up @@ -139,6 +139,24 @@ macro_rules! create_test_files {
};
}

fn collect_files(dir: &Path, base: &Path, files: &mut Vec<String>) {
for entry in fs::read_dir(dir).unwrap() {
let path = entry.unwrap().path();
if path.is_file() {
let rel_path = path
.strip_prefix(base)
.unwrap()
.to_str()
.unwrap()
.to_string()
.replace("\\", "/");
files.push(rel_path);
} else if path.is_dir() {
collect_files(&path, base, files);
}
}
}

macro_rules! assert_test_files {
($temp_dir:expr, $($name:expr => {$($line:expr),+ $(,)?}),+ $(,)?) => {
{
Expand Down Expand Up @@ -166,18 +184,6 @@ macro_rules! assert_test_files {
let mut expected_files: Vec<String> = vec![$($name.to_string()),+];
expected_files.sort();

fn collect_files(dir: &Path, base: &Path, files: &mut Vec<String>) {
for entry in fs::read_dir(dir).unwrap() {
let path = entry.unwrap().path();
if path.is_file() {
let rel_path = path.strip_prefix(base).unwrap().to_str().unwrap().to_string();
files.push(rel_path);
} else if path.is_dir() {
collect_files(&path, base, files);
}
}
}

let mut actual_files = Vec::new();
collect_files(
$temp_dir.path(),
Expand Down

0 comments on commit 1e603c7

Please sign in to comment.