Skip to content

Add regression tests for the critical-review bug fixes - #76

Merged
zeehio merged 2 commits into
develfrom
claude/alpsnmr-critical-review-jmrdcl
Jul 11, 2026
Merged

Add regression tests for the critical-review bug fixes#76
zeehio merged 2 commits into
develfrom
claude/alpsnmr-critical-review-jmrdcl

Conversation

@zeehio

@zeehio zeehio commented Jul 11, 2026

Copy link
Copy Markdown
Member

Summary

Adds 128 new tests (93 → 221 passing), each targeting a specific silent-data-corruption/security bug fixed during a prior critical review, rather than general/blanket coverage. Tests live in the existing (or newly created, correspondingly-named) test file for the R/ source file they cover — not grouped by when/why they were written:

  • test-read_bruker.Rread_orig_file()'s single-token-line handling, read_bin_data()'s file-open error reporting, nmr_read_bruker_fid()'s acqus-driven byte order/dtype/TD/SW_h parsing and data-frame return.
  • test-jdx.Rprocess_block()'s single-token data-line handling and XUNITS/.OBSERVE FREQUENCY validation.
  • test_adding_metadata.Rnmr_meta_add()'s multi-column join-key handling, nmr_meta_get()'s unknown-groups= validation, nmr_meta_export()'s warning-message formatting.
  • test-peak-fitting.Rget_norm_rmse()'s formula contract (plus a body-introspection guard on its call site), get_peak_bounds()'s NA-on-missing-inflection-point behavior, refine_lorentzian_fit_with_nls()'s error capture, peaklist_fit_lorentzians()'s error accumulation.
  • test-autophase.Rnmr_autophase()'s absorptionOnly passthrough (verified by mocking NMRphasing::NMRphasing) and missing-imaginary-data message summarization.
  • test-normalization.Rnmr_normalize()/norm_pqn()'s divide-by-zero and non-positive-factor guards, method="value" validation.
  • test_interpolation.Rnmr_interpolate_1D()'s out-of-native-range warning.
  • test-nmr-data-analysis.Rbp_VIP_analysis()'s permutation behavior and single-class-resample recovery (functional tests plus source-introspection invariant checks).
  • test-plsda.R (new) — plot_plsda_samples()/plot_plsda_multimodel()'s graphics-device cleanup, verified by forcing a mixOmics::plotIndiv failure.
  • test-plots.R (new) — plot()'s >20-sample subsampling notice.
  • test_rDolphin.Rfiles_to_rDolphin()'s label-to-numeric-code mapping message.
  • test-download_MTBLS242.R (new) — the zip-slip guard, tested against a genuinely constructed malicious zip archive (network access mocked out, no real downloads).
  • test-nmr_dataset_load_save.R (new) — nmr_dataset_load()'s class validation.

No R/ source files were changed — all the underlying fixes were already merged in prior PRs (#71, #73).

Test plan

  • Full suite: devtools::test()[ FAIL 0 | WARN 1 | SKIP 1 | PASS 221 ]
    • The 1 skip is pre-existing (rDolphin not installed in this environment)
    • The 1 warning is the expected side-effect of a test intentionally triggering a file-open failure — not a test failure
  • Confirmed no R/ source files were modified (tests-only diff)

claude added 2 commits July 11, 2026 08:16
Adds 128 new tests (93 -> 221 passing) across 7 files, one per area
from the original critical review, each targeting the specific
silent-corruption/security bugs found and fixed there rather than
general coverage:

- test-io-corruption-fixes.R: bruker.R/import_jdx.R parsing
  off-by-ones, missing-field validation, and the nmr_read_bruker_fid
  rewrite (acqus-driven byte order/dtype/TD/SW_h, data-frame return).
- test-nmr-meta-fixes.R: nmr_meta_add's multi-column join-key
  truncation, nmr_meta_get's unknown-groups validation, and
  nmr_meta_export's warning message formatting.
- test-area-estimation-fixes.R: get_norm_rmse's argument-collision
  fix (including a body-introspection guard on the call site),
  get_peak_bounds's NA sentinel, refine_lorentzian_fit_with_nls's
  error capture, and peaklist_fit_lorentzians's error accumulation.
- test-signal-processing-fixes.R: nmr_autophase's absorptionOnly
  passthrough (verified via a mocked NMRphasing binding) and message
  truncation, nmr_normalize's divide-by-zero/non-positive-factor
  guards and method="value" validation, nmr_interpolate's
  out-of-range warning.
- test-stats-fixes.R: bp_VIP_analysis's permutation fix and
  seq_along fix (functional tests plus source-introspection
  backstops), and the PDF device-leak fix in plsda.R's plotting
  functions (forced via a mocked mixOmics::plotIndiv failure).
- test-plots-rdolphin-fixes.R: plots.R's silent-subsampling notice,
  to_rDolphin_blood.R's label-encoding message.
- test-security-fixes.R: the zip-slip guard in download_MTBLS242
  (against a genuinely constructed malicious zip, network mocked
  out) and nmr_dataset_load's class validation.

No R/ source files were changed; all fixes were already merged in
prior PRs. Full suite: 221 passed, 0 failed, 1 pre-existing skip
(rDolphin not installed).
The previous commit added 7 standalone "-fixes" files grouped by
review batch. Moved each test into the existing (or a newly created,
correspondingly-named) test file for the R/ source file it actually
covers, and reworded test names/comments to describe expected
behavior directly instead of referencing "the critical review" or
"previously had a bug" - a fix's own history isn't relevant once it's
just normal test coverage.

- bruker.R/import_jdx.R tests -> test-read_bruker.R / test-jdx.R
- nmr_meta.R tests -> test_adding_metadata.R
- area_estimation.R tests -> test-peak-fitting.R
- nmr_autophase.R/nmr_normalize.R/nmr_interpolate.R tests ->
  test-autophase.R / test-normalization.R / test_interpolation.R
- nmr_data_analysis.R (bp_VIP_analysis) tests -> test-nmr-data-analysis.R
- plsda.R tests -> new test-plsda.R (no prior dedicated file)
- plots.R tests -> new test-plots.R (no prior dedicated file)
- to_rDolphin_blood.R test -> test_rDolphin.R
- download_MTBLS242.R tests -> new test-download_MTBLS242.R
- nmr_dataset_load_save.R tests -> new test-nmr_dataset_load_save.R

All 221 tests still pass (same count as before the reorg) - no
assertions were added, removed, or weakened, only relocated/reframed.
@zeehio
zeehio merged commit 6b4d74e into devel Jul 11, 2026
2 checks passed
@zeehio
zeehio deleted the claude/alpsnmr-critical-review-jmrdcl branch July 11, 2026 12:29
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.

2 participants