Skip to content

Chore/add tests - #120

Open
rogerssam wants to merge 13 commits into
mainfrom
chore/add-tests
Open

Chore/add tests#120
rogerssam wants to merge 13 commits into
mainfrom
chore/add-tests

Conversation

@rogerssam

@rogerssam rogerssam commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Main objective of this PR is:

  • updating to 100% test coverage and
  • improving test/build runtimes.

Fixes #108. Should also fix #116.

Summary

Speeds up the test suite and R CMD check, and closes the remaining coverage gaps.

Vignettes - major change

  • Vignettes are pre-computed from .qmd.orig sources, so R CMD build/check only render markdown rather than re-running every optimisation twice per platform. A scheduled workflow still executes the real sources across all five OS/R combinations.

Tests

  • Split test-speed.R into five files to take advantage of parallelism in testthat.
  • Cut factorial iteration budgets, which were larger than their assertions needed.
  • Fixed a broken assertion in the alternative-separator factorial test: it compared an optimised factorial score against a non-factorial baseline, and only passed because of the huge budget.
  • Removed dead commented-out assertions and label-only comments from the tests.

Other house keeping

  • Added grid_factors validation — a malformed value previously failed with "missing value where TRUE/FALSE needed".
  • Guarded the .onAttach version check behind an interactive check, a SPEED_NO_VERSION_CHECK env var, and a 2s timeout.

Locally: test suite 177s → 123s, R CMD check 922s → 221s, coverage 99.82% → 100%.

@rogerssam
rogerssam requested a review from wvjgsuhp August 10, 2026 00:54
Comment thread R/speed.R

@wvjgsuhp wvjgsuhp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't check data-raw machinery. Felt bad typing this, but going ahead anyway.
test-speed.R growing large started to itch me, so ty for the scratch.

Comment thread R/design_utils.R
Comment on lines +193 to +197
# Direct callers bypass `.verify_grid_factors()`, so fall back to the name
# patterns below rather than indexing a malformed `grid_factors`.
named_dims <- is.list(grid_factors) &&
all(c("dim1", "dim2") %in% names(grid_factors)) &&
all(lengths(grid_factors[c("dim1", "dim2")]) == 1)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels overkill unless we are expecting calls from outside speed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nah that's fair. I think in a lot of these cases, if people play silly games, they win silly errors.

Comment thread R/speed.R

# Checked for every call shape, since `infer_row_col()` below uses it whether
# or not `optimise` was supplied.
.verify_grid_factors(grid_factors)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be buried under the prior .verify...s.

Comment thread R/utils.R
Comment on lines +213 to +214
# `speed()` rejects a per-level `grid_factors`, so this arm is only
# reachable by calling `create_speed_input()` directly.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should still keep grid_factors flexible between optimizing levels.
E.g., maybe there are experimental designs depending on row/col and time/height.
I can see that such designs gonna be very complex and rare tho.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we do class(test_data) = c('design', class(test_data)) instead of calling speed?
Maybe keep only 1 test for speed call.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I like this idea. The plotting machinery doesn't need the design to run (except for one case to make sure it works).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would devtools::build_vignettes() suffice so we don't have to explicitly test these?

@rogerssam rogerssam mentioned this pull request Aug 13, 2026
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.

Test: add test for generate_neighbour Can we speed up examples and test cases?

2 participants