Skip to content

Share fixture-writing helpers across tests - #15267

Merged
cderv merged 4 commits into
mainfrom
task/writefixture-shared-helper
Nov 3, 2026
Merged

cderv merged 4 commits into
mainfrom
task/writefixture-shared-helper

Conversation

@cderv

@cderv cderv commented Nov 3, 2026

Copy link
Copy Markdown
Member

Follow-up to #14784. Its new tests/unit/preview-extension-brand.test.ts writes fixtures with 20 direct Deno.writeTextFileSync calls, while tests/unit/tools/check-runtime-boundary.test.ts already had a private writeFixture doing the same thing: create the parent directories, then write a file at a slash-separated path. Many other tests repeat that pattern by hand.

writeFixture now lives in tests/utils.ts, with a writeDefaultProject(dir) next to it for the default-type _quarto.yml that 20 test sites wrote by hand. Around 20 test files that created a directory only to write a file into it go through writeFixture. Directories that matter on their own keep their explicit creation: a cwd, a directory later made unreadable before the test, an empty directory a test asserts on.

The runtime boundary check counts direct Deno.* calls per scope so the Node migration can only lower them. Its tests count in tools/runtime-boundary-baseline.json goes from 895 to 773. #15223 also changes that file, so whichever PR merges second regenerates it with --update-baseline.

Checklist

I have (if applicable):

  • referenced the GitHub issue this PR closes
  • updated the appropriate changelog in the PR
  • ensured the present test suite passes
  • added new tests
  • created a separate documentation PR in Quarto's website repo and linked it to this PR
AI-assisted PR
  • AI tool used: Claude Code
  • Codebase grounding: local clone
  • Human review: I have reviewed, tested, and verified the AI-generated content before submitting.

cderv added 3 commits November 3, 2026 15:18
check-runtime-boundary.test.ts had a local writeFixture that creates parent
directories and writes a file at a slash-separated relative path, while
preview-extension-brand.test.ts (#14784) did the same by hand with 20 direct
Deno.writeTextFileSync calls. Move writeFixture to tests/utils.ts and route
every fixture write in both files through it. The three inline project
fixtures in preview-extension-brand.test.ts now call writeProject, which
writes the same files.

The tests scope of the runtime boundary baseline drops from 895 back to 875.
Twenty test sites wrote the same default-type _quarto.yml by hand, sixteen
of them in brand.test.ts's repeated setups. Add writeDefaultProject to
tests/utils.ts on top of writeFixture and use it in brand.test.ts,
check-info-project.test.ts, preview-brand-cache.test.ts and
preview-extension-brand.test.ts. Fixtures that write custom _quarto.yml
content (a render list, a title, per-case content) keep their own writes.

The tests scope of the runtime boundary baseline drops from 875 to 856.
Many tests created a directory with ensureDirSync or Deno.mkdirSync only to
write a file into it. writeFixture creates missing parent directories, so
those pairs collapse into one call. Directories that matter on their own
stay explicit: cwd targets, chmod'ed or empty directories, and roots that
must exist before any file is written. Fixtures whose directory is later
made unreadable (the locked/ directory) now get it from writeFixture; the
mode before the chmod is the same.

The tests scope of the runtime boundary baseline drops from 856 to 773.
@posit-snyk-bot

posit-snyk-bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@cderv

cderv commented Nov 3, 2026

Copy link
Copy Markdown
Member Author

CI failure is on main too. I'll fix in another PR

@cderv
cderv merged commit bd5161d into main Nov 3, 2026
10 of 52 checks passed
@cderv
cderv deleted the task/writefixture-shared-helper branch November 3, 2026 15:33
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