Skip to content

Fix test for v1.9 change#302

Merged
cderv merged 22 commits into
mainfrom
fix-tests
May 21, 2026
Merged

Fix test for v1.9 change#302
cderv merged 22 commits into
mainfrom
fix-tests

Conversation

@cderv
Copy link
Copy Markdown
Member

@cderv cderv commented May 20, 2026

Updates the test suite for upstream Quarto v1.9 behaviour changes, replaces the fragile metadata snapshot tests with a stable helper plus focused integration coverage, and shores up test skips for missing optional dependencies.

Quarto v1.9 adaptations

Metadata args refactor and tests

  • Extract cli_arg_metadata() from quarto_render() as a pure helper building --metadata-file args; treats explicit metadata_file = NULL as omitted, and uses on.exit to clean up the temp YAML file on error
  • Replace three native-AST metadata snapshots (which churned on every Quarto-injected metadata change) with unit tests of cli_arg_metadata() plus integration tests that use a Lua filter to allowlist metadata keys — covers both metadata= override of a top-level _quarto.yml key and temp-file cleanup on write failure

Test infrastructure

Adapted for #301

Default is now in v1.9
````
❯ quarto list extensions
Id              Version    Contributes
julia-engine    0.1.0
orange-book     0.1.0      formats
````
@cderv cderv marked this pull request as draft May 20, 2026 08:57
cderv added 21 commits May 20, 2026 11:11
Verify now that extension is in the list before trying to remove.

And only test for no extension for quarto before v1.9 due to #301
Pure function that builds the --metadata-file CLI args from the
metadata list and metadata_file path. Returns the args plus the
temp file path (when one was written) so the caller can register
cleanup.

No behavior change yet — quarto_render() still uses its inline
implementation. Next commit wires the helper in.
Replace the inline metadata branch (~14 lines) with a single
call to the extracted helper. Behavior preserved: same args
produced, same temp file cleanup via on.exit. Explicit
metadata_file = NULL is now treated as omitted instead of
hitting yaml::read_yaml(NULL).
Renders a project with a _quarto.yml containing a custom-key value
and verifies that quarto_render(metadata = ...) overrides the key.
A Lua filter strips all metadata except an allowlist so the
native-AST snapshot stays small and stable across Quarto versions
(no churn from injected engines metadata or similar).

Note: toc-title is a format-level option consumed by Quarto before
pandoc sees it, so it does not appear in native AST metadata. The
test uses a top-level document metadata key instead, which is the
correct surface for verifying --metadata-file override behaviour.
The three native-AST snapshot tests for the metadata/metadata_file
args were testing Quarto's downstream Pandoc behavior, not the R
wrapper's contribution. They also churned whenever Quarto changed
what it injects into native output (most recently an engines
MetaList with absolute extension paths).

Coverage now lives in:
- test-metadata-args.R: unit tests of cli_arg_metadata() (no Quarto)
- test-metadata-render.R: one integration test exercising override
  of a top-level _quarto.yml key via a Lua filter that allowlists
  the metadata keys we care about, keeping the snapshot stable.
- Add skip_if_not_installed("withr") to three tests in
  test-metadata-args.R that use withr:: calls. withr is in Suggests,
  not Imports, so the no-Quarto CI cell (which may not install
  suggested packages) needs the guard.
- Rename metadata-nested-override.test.out to
  metadata-toplevel-override.test.out — the test demonstrates a
  top-level key override, not a nested format key (which would not
  appear in native AST output).
Theme tests require brand.yml package (used by bslib::bs_theme(brand=)).
Since brand.yml is in bslib's Suggests, it's not installed transitively.
gdtools::font_set_liberation() can fail with confusing errors when the
cache directory cannot be created (e.g., permission issues).
See davidgohel/gdtools#82
Covers the on.exit unlink branch in cli_arg_metadata() added in
ea36f05. Without coverage a regression could silently leak temp files
on write failures.
Quarto CLI prepends `Quarto version: X.Y.Z` to stderr whenever the log
level is DEBUG, which is auto-enabled by GitHub Actions when a workflow
is re-run with debug logging. That prefix line breaks any consumer that
parses CLI stderr — in our case `quarto_list_extensions()` was feeding
the line to `read.table(header = TRUE)`, where it became the header row
and `df$Id` resolved to NULL.

Strip the line in `quarto_list_extensions()` before parsing, and in the
shared snapshot transform so error-output snapshots stay stable across
debug and non-debug runs.

See quarto-dev/quarto-cli#14532 for the
upstream behaviour.
@cderv cderv marked this pull request as ready for review May 21, 2026 11:34
@cderv cderv merged commit 65ad2a4 into main May 21, 2026
19 checks passed
@cderv cderv deleted the fix-tests branch May 21, 2026 11:43
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