Mirrors a directory into the sandbox incrementally (design notes §10.2).
The inputs are the files under dirs (recursively; directories named in :skip, by
default _build, deps, .git, node_modules and .elixir_ls, are left out, and
so are symbolic links to directories) and the root files. Each one's wanted content
is its override (a metamutant) when given, else the file itself (mix.exs through
Juggernaut.Sandbox.MixExs). A file is written only when the wanted content differs
from what the sandbox holds, so Mix sees only real changes, and every sandbox file with
no input is deleted. Those are found by walking the sandbox with the same skips (unless
prune: false), so a lost manifest, or a file a test or a mutant wrote, never stays
behind.
Every mirrored file gets its input's permission bits (an override gets the bits of the file it replaces), so a script a test runs stays executable, and a change of mode alone is mirrored too.
The manifest (<sandbox>.json, format 3) records, per file, the hash of the content
written, the size, mtime and mode of its input, and the size, mtime and mode the
sandbox file had after the sync. An input with the same size, mtime and mode and no
override, whose sandbox file still has its recorded size, mtime and mode, is not read
again. A sandbox file changed since (by a test or a mutant run with the sandbox as
working directory) is read, compared and restored. Known limit: a same-size change within the second of the sync
is not seen, because mtimes are in seconds.
Reads come from the source directory; every write is under the sandbox, which may not
be the source root, one of the mirrored directories, or above them, nor anywhere under
the source root except below a skipped directory (such as _build): every file git
lists is an input, so a sandbox elsewhere in the tree would be mirrored into itself.
Summary
Functions
The manifest file of sandbox.
Syncs root into sandbox. Options: :dirs, :files (root files), :overrides
(%{relative path => content}) :skip (directory names left out, default ["_build", "deps", ".git", "node_modules", ".elixir_ls"]) and
:prune (default true; false deletes only files the manifest names, leaving files
others wrote in the sandbox, such as a dependency's build output).
The directory names a sync leaves out by default.
Types
@type report() :: %{ written: [String.t()], deleted: [String.t()], kept: non_neg_integer() }
Functions
The manifest file of sandbox.
@spec run(Path.t(), Path.t(), keyword()) :: {:ok, report()} | {:error, Juggernaut.Error.t()}
Syncs root into sandbox. Options: :dirs, :files (root files), :overrides
(%{relative path => content}) :skip (directory names left out, default ["_build", "deps", ".git", "node_modules", ".elixir_ls"]) and
:prune (default true; false deletes only files the manifest names, leaving files
others wrote in the sandbox, such as a dependency's build output).
@spec skip() :: [String.t()]
The directory names a sync leaves out by default.