Skip to content

Commit 049390a

Browse files
refactor: remove common test utilities and replace with direct file path handling in tests
1 parent bd0b0b4 commit 049390a

4 files changed

Lines changed: 19 additions & 29 deletions

File tree

benches/function_parse.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::time::{Duration, Instant};
22

3-
use criterion::{BenchmarkId, Criterion, Throughput, black_box, criterion_group, criterion_main};
3+
use criterion::{BenchmarkId, Criterion, Throughput, criterion_group, criterion_main};
4+
use std::hint::black_box;
45
use rayon::prelude::*;
56

67
use parser::{ParserError, parse};
@@ -156,7 +157,7 @@ fn benchmark_parallel_threshold(c: &mut Criterion) {
156157

157158
// Read each test file only once
158159
for &filename in TEST_FILESNAMES_BASE {
159-
let file_extension = filename.split('.').last().unwrap_or("unknown");
160+
let file_extension = filename.split('.').next_back().unwrap_or("unknown");
160161
let group_name = format!("Parallel {} Processing", file_extension.to_uppercase());
161162
let mut group = c.benchmark_group(&group_name);
162163

tests/common/mod.rs

Lines changed: 0 additions & 20 deletions
This file was deleted.

tests/endpoints.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
mod common;
2-
3-
use common::test_file_path;
1+
use std::path::PathBuf;
42

53
// Note: The endpoint tests require the web module to be exposed publicly.
64
// For now, we'll keep this as a placeholder. The web functionality can be tested
@@ -21,7 +19,9 @@ fn test_file_paths_exist() {
2119
];
2220

2321
for name in file_names {
24-
let path = test_file_path(name);
22+
let path = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
23+
.join("tests/assets")
24+
.join(name);
2525
assert!(path.exists(), "Test file should exist: {:?}", path);
2626
}
2727
}

tests/parsing.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
mod common;
1+
use std::{fs, path::PathBuf};
22

3-
use common::read_test_file;
43
use parser::parse;
54
use rayon::prelude::*;
65

@@ -67,7 +66,17 @@ grey07;2070;Laura;Grey"
6766
#[test]
6867
fn parse_success() {
6968
let (file_names, expected_texts) = get_test_data();
70-
let data: Vec<Vec<u8>> = file_names.iter().map(|name| read_test_file(name)).collect();
69+
let data: Vec<Vec<u8>> = file_names
70+
.iter()
71+
.map(|name| {
72+
fs::read(
73+
PathBuf::from(env!("CARGO_MANIFEST_DIR"))
74+
.join("tests/assets")
75+
.join(name),
76+
)
77+
.unwrap()
78+
})
79+
.collect();
7180

7281
let result: Vec<String> = data.par_iter().map(|d| parse(d).unwrap()).collect();
7382

0 commit comments

Comments
 (0)