Page: a changed file belongs to a session root
Job: explanation
Level: mid grug (level 2 of 6)
Source lines:
SageFs.Core/LiveTestFileRouting.fs:61#eitherOnSageFs.Core/LiveTestWatcherCore.fs:187#isScratchName
a changed file belongs to a session root
this page says why the code has this shape and what a reader must be careful of.
why this exists
Several sessions can be open at once, each with its own working directory. When a file changes, the watcher has to decide which sessions care. combines activation rules, and SageFs.Core/LiveTestFileRouting.fs:61#eitherOn keeps generated scratch files out of that decision.SageFs.Core/LiveTestWatcherCore.fs:187#isScratchName
run sed -n '61,72p' SageFs.Core/LiveTestFileRouting.fs
It prints:
let eitherOn (first: LiveTestingActivation) (second: LiveTestingActivation) : LiveTestingActivation =
match first, second with
| LiveTestingActivation.Inactive, LiveTestingActivation.Inactive -> LiveTestingActivation.Inactive
| LiveTestingActivation.Active, LiveTestingActivation.Active
| LiveTestingActivation.Active, LiveTestingActivation.Inactive
| LiveTestingActivation.Inactive, LiveTestingActivation.Active -> LiveTestingActivation.Active
/// The sessions whose working directory is the most specific one containing `path`. Sessions
/// that share that directory all own the path. A session with no working directory owns nothing.
let owners (roots: SessionRoot list) (path: string) : SessionId list =
let dirSessions =
roots
The cited file SageFs.Core/LiveTestFileRouting.fs ships with this site at the same path. Run the command from the school folder, or open SageFs.Core/LiveTestFileRouting.fs.
what breaks
A watcher that treats every changed file as belonging to every session reruns unrelated tests. A watcher that uses the process working directory misses a session opened in another checkout.
where it fits
Repo paths resolve where files are. This module decides who owns a file after it changes.
try it
Run the grep above from this repository root. Then open two sessions in different folders and change one file. Only the session whose root contains that file should see its tests rerun.
reference: every connection to this page
This is reference. The next page in the reading order is at the bottom of the page.
path order: repo paths are found at runtime
flowchart LR A0["repo paths are found at runtime"] H["you are here: a changed file belongs to a session root"] A0 --> H
grill: say it out loud, then tap
Grug asks. Say the answer out loud, then tap. Grug remembers what you miss and asks again in the pop quiz.
a badge says two things: the number is its level, the colour is the kind of answer it asks for. The six levels are level 1 of 6 recall a fact; level 2 of 6 recall a detail; level 3 of 6 trace a path; level 4 of 6 trace a longer path; level 5 of 6 predict or judge; level 6 of 6 judge a transfer. Colour and level are independent: a high-level question can still ask for a fact, and the colour tells you which it is.
try first, then show answer
1. The one whose root contains the file
Routing is by declared session root, so only the session whose directory contains the file should react.
try first, then show answer
WorkingDirectory
WorkingDirectory on a session root is the path the watcher compares against a changed file.
try first, then show answer
3. It is classified as scratch and left out
Scratch names are classified before routing, so generated files do not start test runs.
try first, then show answer
eitherOn
eitherOn joins two activation rules before the route is decided.