Skip to content

Commit c07c682

Browse files
committed
fix tests
1 parent c49c6fc commit c07c682

3 files changed

Lines changed: 53 additions & 13 deletions

File tree

.github/workflows/ci.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,23 @@ jobs:
2727
- uses: actions/checkout@v4
2828
- uses: dtolnay/rust-toolchain@stable
2929
- uses: Swatinem/rust-cache@v2
30-
- name: cargo build (workspace)
31-
run: cargo build --workspace --all-targets
30+
31+
# Build only the odx-rs core here. odx-py is a Python cdylib whose
32+
# link step needs `-undefined dynamic_lookup` on macOS (configured in
33+
# python/.cargo/config.toml, only visible when cargo runs from
34+
# python/). The actual cdylib build happens in the python-tests job
35+
# via maturin, which sets the right flags. We `cargo check` it here
36+
# so Rust-level errors are still caught — `check` skips codegen and
37+
# linking entirely.
38+
- name: cargo build (odx-rs)
39+
run: cargo build -p odx-rs --all-targets
40+
41+
- name: cargo check (odx-py)
42+
run: cargo check -p odx-py
43+
3244
- name: cargo test (odx-rs)
3345
run: cargo test -p odx-rs --lib
46+
3447
- name: cargo test (integration)
3548
run: cargo test -p odx-rs --tests
3649

src/descoteaux_sh.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,7 @@ mod tests {
818818
// produced silently-wrong peak amplitudes during pyAFQ aodf
819819
// import.
820820
let sh: Vec<f32> = (0..ncoeffs_for(4, true))
821-
.map(|i| ((i as f32 * 0.137).sin() * 0.3 + (i as f32 * 0.21).cos() * 0.1))
821+
.map(|i| (i as f32 * 0.137).sin() * 0.3 + (i as f32 * 0.21).cos() * 0.1)
822822
.collect();
823823

824824
let test_dirs = [

src/formats/tortoise_mapmri.rs

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,23 @@ fn robust_positive_percentile(values: &[f32], percentile: f32) -> f32 {
552552
#[cfg(test)]
553553
mod tests {
554554
use super::*;
555+
use std::path::PathBuf;
556+
557+
/// Returns the three Tortoise fixture paths if all three exist on disk,
558+
/// else `None`. The fixtures live outside the repo (in a sibling
559+
/// `test_data/` directory) and aren't checked in, so CI runners and
560+
/// fresh clones won't have them — those test runs skip cleanly via the
561+
/// `else { return; }` pattern in each test below.
562+
fn tortoise_fixtures() -> Option<(PathBuf, PathBuf, PathBuf)> {
563+
let coeff = PathBuf::from("../test_data/xx_mapmri.nii");
564+
let tensor = PathBuf::from("../test_data/xx_L1_DT.nii");
565+
let uvec = PathBuf::from("../test_data/xx_uvec.nii");
566+
if coeff.exists() && tensor.exists() && uvec.exists() {
567+
Some((coeff, tensor, uvec))
568+
} else {
569+
None
570+
}
571+
}
555572

556573
#[test]
557574
fn infers_tortoise_radial_order_four_from_fixture_coeff_count() {
@@ -560,12 +577,16 @@ mod tests {
560577

561578
#[test]
562579
fn real_fixture_selected_voxel_projects_to_finite_sh() {
580+
let Some((coeff_path, tensor_path, uvec_path)) = tortoise_fixtures() else {
581+
eprintln!("Tortoise fixtures not found at ../test_data/; skipping.");
582+
return;
583+
};
563584
let (coeff_dims, _, coeff_data) =
564-
mrtrix::load_nifti_f32_volume(Path::new("../test_data/xx_mapmri.nii")).unwrap();
585+
mrtrix::load_nifti_f32_volume(&coeff_path).unwrap();
565586
let (tensor_dims, _, tensor_data) =
566-
mrtrix::load_nifti_f32_volume(Path::new("../test_data/xx_L1_DT.nii")).unwrap();
587+
mrtrix::load_nifti_f32_volume(&tensor_path).unwrap();
567588
let (uvec_dims, _, uvec_data) =
568-
mrtrix::load_nifti_f32_volume(Path::new("../test_data/xx_uvec.nii")).unwrap();
589+
mrtrix::load_nifti_f32_volume(&uvec_path).unwrap();
569590
let (dims3, ncoeffs) = normalize_trailing_channels(
570591
&coeff_dims,
571592
Path::new("xx_mapmri.nii"),
@@ -607,10 +628,12 @@ mod tests {
607628

608629
#[test]
609630
fn real_fixture_has_two_coeff_supported_zero_uvec_voxels() {
610-
let (coeff_dims, _, coeff_data) =
611-
mrtrix::load_nifti_f32_volume(Path::new("../test_data/xx_mapmri.nii")).unwrap();
612-
let (uvec_dims, _, uvec_data) =
613-
mrtrix::load_nifti_f32_volume(Path::new("../test_data/xx_uvec.nii")).unwrap();
631+
let Some((coeff_path, _, uvec_path)) = tortoise_fixtures() else {
632+
eprintln!("Tortoise fixtures not found at ../test_data/; skipping.");
633+
return;
634+
};
635+
let (coeff_dims, _, coeff_data) = mrtrix::load_nifti_f32_volume(&coeff_path).unwrap();
636+
let (uvec_dims, _, uvec_data) = mrtrix::load_nifti_f32_volume(&uvec_path).unwrap();
614637
let (dims3, ncoeffs) = normalize_trailing_channels(
615638
&coeff_dims,
616639
Path::new("xx_mapmri.nii"),
@@ -641,12 +664,16 @@ mod tests {
641664

642665
#[test]
643666
fn fixture_tensor_export_order_produces_positive_eigenvalues() {
667+
let Some((coeff_path, tensor_path, uvec_path)) = tortoise_fixtures() else {
668+
eprintln!("Tortoise fixtures not found at ../test_data/; skipping.");
669+
return;
670+
};
644671
let (coeff_dims, _, coeff_data) =
645-
mrtrix::load_nifti_f32_volume(Path::new("../test_data/xx_mapmri.nii")).unwrap();
672+
mrtrix::load_nifti_f32_volume(&coeff_path).unwrap();
646673
let (tensor_dims, _, tensor_data) =
647-
mrtrix::load_nifti_f32_volume(Path::new("../test_data/xx_L1_DT.nii")).unwrap();
674+
mrtrix::load_nifti_f32_volume(&tensor_path).unwrap();
648675
let (uvec_dims, _, uvec_data) =
649-
mrtrix::load_nifti_f32_volume(Path::new("../test_data/xx_uvec.nii")).unwrap();
676+
mrtrix::load_nifti_f32_volume(&uvec_path).unwrap();
650677
let (dims3, ncoeffs) = normalize_trailing_channels(
651678
&coeff_dims,
652679
Path::new("xx_mapmri.nii"),

0 commit comments

Comments
 (0)