Repository navigation
Share fixture-writing helpers across tests - #15267
Merged
Merged
Conversation
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.
Collaborator
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Member
Author
|
CI failure is on main too. I'll fix in another PR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #14784. Its new
tests/unit/preview-extension-brand.test.tswrites fixtures with 20 directDeno.writeTextFileSynccalls, whiletests/unit/tools/check-runtime-boundary.test.tsalready had a privatewriteFixturedoing the same thing: create the parent directories, then write a file at a slash-separated path. Many other tests repeat that pattern by hand.writeFixturenow lives intests/utils.ts, with awriteDefaultProject(dir)next to it for the default-type_quarto.ymlthat 20 test sites wrote by hand. Around 20 test files that created a directory only to write a file into it go throughwriteFixture. 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. Itstestscount intools/runtime-boundary-baseline.jsongoes from 895 to 773. #15223 also changes that file, so whichever PR merges second regenerates it with--update-baseline.Checklist
I have (if applicable):
AI-assisted PR