Skip to content

Integrate two old_to_integrate tests; harden test discovery#80

Open
torwager wants to merge 2 commits into
masterfrom
test/integrate-old-tests
Open

Integrate two old_to_integrate tests; harden test discovery#80
torwager wants to merge 2 commits into
masterfrom
test/integrate-old-tests

Conversation

@torwager

Copy link
Copy Markdown
Contributor

What

Salvages two of the three quarantined tests in Unit_tests/old_to_integrate/ into the real, discovered suite, and hardens test discovery against the failure mode that put them in quarantine in the first place.

Converted + integrated

  • image_vector/canlab_test_check_roi_extraction.m (from old_to_integrate/check_roi_extraction.m). The original printed PASS/FAIL but never asserted. Now a functiontests test that asserts multi-region 'unique_mask_values' extraction and invariance of region averages across a write→reload round-trip (RelTol 1e-3 / AbsTol 1e-2 absorbs single-precision NIfTI rounding). Complements the existing canlab_test_extract_roi (single-mask only) — no overlap.
  • image_vector/canlab_test_resampling_pattern_expression.m (from old_to_integrate/resampling_pattern_expression_unit_test1.m). The original only plotted. Now asserts SIIPS pattern expression is stable (corr > 0.99) across default/nearest/spline resampling; skips gracefully if SIIPS is unavailable.

Discovery hardening (the recommended robustness fix)

  • helpers/canlab_safe_suite_from_file.m + one-line change in canlab_run_all_tests.m: wrap TestSuite.fromFile so a stray canlab_test_*.m that is not a valid test (old plain-assert script, or function name ≠ filename) is warn-skipped instead of throwing NonTestFile and aborting discovery of the entire suite.
  • canlab_test_runner_robustness.m: pins that behavior (non-test file → warn + empty + ok=false; valid file → loads). State-independent (uses lastwarn, not verifyWarning).

Not integrated

old_to_integrate/jackknife_similarity_unit_test.m stays put — it's an 802-line metric-sensitivity characterization/figure script, not a unit test; its only real assertions duplicate the existing jackknife smoke test.

Verification

Full default suite (walkthroughs excluded): 147 passed, 0 failed, 2 incomplete locally. The 4 new tests are discovered and pass; the 2 incompletes are pre-existing environment skips. No regressions.

🤖 Generated with Claude Code

torwager and others added 2 commits June 19, 2026 19:57
Convert two quarantined standalone scripts into real matlab.unittest tests
and move them into the discovered suite, and make the runner robust against
non-test files that match the canlab_test_*.m glob.

- image_vector/canlab_test_check_roi_extraction.m: converts
  old_to_integrate/check_roi_extraction.m. The original printed PASS/FAIL but
  never asserted. Now asserts multi-region 'unique_mask_values' extraction and
  invariance of the region averages across a write->reload round-trip
  (RelTol 1e-3 / AbsTol 1e-2 absorbs single-precision NIfTI rounding).
  Complements canlab_test_extract_roi (single-mask only).
- image_vector/canlab_test_resampling_pattern_expression.m: converts
  old_to_integrate/resampling_pattern_expression_unit_test1.m, which only
  plotted. Now asserts SIIPS pattern expression is stable (corr > 0.99) across
  default/nearest/spline resampling; skips if SIIPS is unavailable.
- helpers/canlab_safe_suite_from_file.m + canlab_run_all_tests.m: wrap
  TestSuite.fromFile so a stray non-test canlab_test_*.m is warn-skipped
  instead of throwing NonTestFile and aborting discovery of the whole suite.
- canlab_test_runner_robustness.m: pins that behavior (non-test file ->
  warn + empty + ok=false; valid file -> loads).

Old originals removed from old_to_integrate (jackknife_similarity_unit_test.m
stays - it is a characterization/figure script, not a unit test).

Full default suite after: 147 passed, 0 failed, 2 incomplete (pre-existing
environment skips).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The five xval_*_unit_test.m files at the Unit_tests root were genuine tests
(real assertions, no graphics, deterministic, bundled DPSP / synthetic data)
but were plain-assert functions named outside the canlab_test_* convention,
so the runner never discovered them.

Convert each into a functiontests file under a new predictive_model/ subdir:
the model is fit once in setupOnce (skipped via assumeTrue if the DPSP sample
data is absent) and cached, and the assertions are split into focused test
functions using tc.verify* for granular reporting. Behavior preserved.

- predictive_model/canlab_test_xval_SVM.m
- predictive_model/canlab_test_xval_SVR.m
- predictive_model/canlab_test_xval_regression_multisubject.m
- predictive_model/canlab_test_xval_regression_multisubject_featureselect.m
- predictive_model/canlab_test_xval_discriminant_classifier.m
- helpers/canlab_get_dpsp_hot_warm.m: shared DPSP Hot/Warm loader.

Old xval_*_unit_test.m removed. New suite: 25 test points, all pass, ~7.5s.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant