Expand description
Tools that judge the project’s source as text.
A linter, a formatter or a spell checker that a test script runs reads the files of the instrumented workspace, and fails on code nobody wrote: Biome on probe calls it would format otherwise, cspell on Supercov’s own names, knip on the runtime the files now import. ESLint and Prettier are Node programs, and the preload hands them the authored text of each file they read. A native program cannot be handed anything.
Such a tool is started through a launcher in the workspace’s own
node_modules/.bin, which calls back into this binary. It then runs in a
view of the workspace that holds every file as its author wrote it: a
directory beside the workspace with a hard link to each file the run did
not rewrite, and the authored text of each one it did. What the tool
writes there is the workspace’s too, as if it had run in it.
A tool that changes a source file, a formatter with --write or a linter
with --fix, changes the authored text. The workspace holds what was
instrumented from the text before, and written over that file the change
would leave it unmeasured: Prettier did exactly that through the preload,
and a file whose tests passed read 0% covered. The new text is kept
beside the instrumented copy instead. Tools that run later in the command
read it, the tests run the copy that is measured, and when the command
ends the change is the project’s, as the command meant it to be.
Structs§
- Source
Changes - The source files the command’s tools changed, by what became of each.
Constants§
- SOURCE_
TOOLS - The tools measured to fail on an instrumented workspace and to pass in its
source view. Anything else that reads source as text can be named in
SUPERCOV_SOURCE_TOOLS. - SOURCE_
TOOLS_ VARIABLE - Names added to
SOURCE_TOOLS, separated by commas. - SOURCE_
TOOL_ COMMAND - The hidden command a launcher runs:
supercov __source-tool <tool> <args>.
Functions§
- apply_
source_ changes - Give the project the changes the command’s tools made to its source files. Each was made to the text the run started from, so it is applied only where the project still has that text.
- clear_
source_ changes - Forget the changes a command before this one left behind.
- launcher
- The launcher that stands in for
toolwhere a shell starts it. - launcher_
for - What stands in a workspace’s
.binfor the filenameof the project’s.binattools, when that file starts a tool that judges source. - launching_
binary - This binary, by a path a shell and
cmd.execan both be given. - path_
with_ launchers - PATH for the test command with launchers first for the source tools it
has: a package manager’s script finds a project’s own tool in the
workspace’s
.bin, butsupercov -- biome check, and a tool installed for the whole machine, are found here. A name that is not on PATH gets no launcher, so a script that asks whether a tool is installed hears what it heard. - place_
launchers - Put launchers in a
.binthe workspace already has as a directory of its own, which is how a workspace package’s dependencies are laid out: for each source tool the project’s.binattoolshas, in place of the entry the copy attohas for it. - run_
source_ tool - Run
toolwithargumentsin the source view of the workspace this process was started in, and return its exit status. Outside a workspace of a run, the tool runs where it was started. - source_
tools - The names a launcher is written for.
- source_
view_ path - Where the source view of a workspace is kept: beside the directory that holds the workspaces, under the same name.
- write_
launcher - Write a launcher where
pathis, replacing what is there. Never through it: in a workspace whose dependencies are hard links, the file there is the project’s own.