fix(test): resolve test_data_dir from CI PVC layout (ohlcv/ES.FUT)

CI PVC structure is /data/test-data/ohlcv/ES.FUT, local is
test_data/ES.FUT. test_data_dir() now searches both layouts
and checks both FOXHUNT_TEST_DATA and TEST_DATA_DIR env vars.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
jgrusewski
2026-03-17 09:36:07 +01:00
parent 472dffd0f3
commit e0dced887f

View File

@@ -94,21 +94,33 @@ pub(super) fn assert_finite_f32(val: f32, name: &str) {
/// `test_data/ES.FUT` relative to the workspace root.
/// Returns `None` if the directory doesn't exist.
pub(super) fn test_data_dir() -> Option<String> {
if let Ok(dir) = std::env::var("FOXHUNT_TEST_DATA") {
if std::path::Path::new(&dir).exists() {
return Some(dir);
// Check env vars: FOXHUNT_TEST_DATA (explicit), TEST_DATA_DIR (CI PVC root)
for var in &["FOXHUNT_TEST_DATA", "TEST_DATA_DIR"] {
if let Ok(dir) = std::env::var(var) {
let path = std::path::Path::new(&dir);
// Search for ES.FUT in common layouts:
// 1. $DIR/ES.FUT (direct)
// 2. $DIR/ohlcv/ES.FUT (CI PVC layout)
for sub in &["ES.FUT", "ohlcv/ES.FUT"] {
let candidate = path.join(sub);
if candidate.exists() {
return Some(candidate.to_string_lossy().into_owned());
}
}
}
}
// Auto-detect: workspace_root/test_data/ES.FUT (single symbol, no cross-symbol mixing)
// Auto-detect from workspace root: test_data/ES.FUT or test_data/ohlcv/ES.FUT
let manifest = std::env::var("CARGO_MANIFEST_DIR").unwrap_or_default();
let workspace = std::path::Path::new(&manifest)
.parent() // crates/
.and_then(|p| p.parent()) // repo root
.unwrap_or(std::path::Path::new("../.."));
let es_dir = workspace.join("test_data").join("ES.FUT");
if es_dir.exists() {
Some(es_dir.to_string_lossy().into_owned())
} else {
None
let test_data = workspace.join("test_data");
for sub in &["ES.FUT", "ohlcv/ES.FUT"] {
let candidate = test_data.join(sub);
if candidate.exists() {
return Some(candidate.to_string_lossy().into_owned());
}
}
None
}