Skip to content

Commit dc9dc6b

Browse files
committed
fix(s040): the hot-reload test waits past the mtime second (the polling backend on the gate's runners); TRINITY_SKILLS_POLL=1 forces the poll
Run 35623752961: gate and fips have no inotifywait, the registry polls once a second, and the poll compares mtimes at one-second resolution, so an edit inside the file's first second was no change. Under the forced poll on this machine the edit arrives in about 1.2 s. Signed-off-by: Ayla Croft <aylacroft@proton.me>
1 parent 58a253c commit dc9dc6b

8 files changed

Lines changed: 20 additions & 12 deletions

File tree

‎lib/trinity/skills/registry.ex‎

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -301,22 +301,27 @@ defmodule Trinity.Skills.Registry do
301301
end
302302

303303
# inotify needs the `inotifywait` executable; without it, and on any platform file_system
304-
# has no native backend for, poll once a second (AC3's 2 s still holds).
304+
# has no native backend for, poll once a second (AC3's 2 s still holds; the poll compares
305+
# mtimes at one-second resolution). `TRINITY_SKILLS_POLL=1` forces the poll, so the
306+
# fallback can be exercised on a machine that has inotifywait.
305307
defp backend do
306-
case :os.type() do
307-
{:unix, :linux} ->
308-
if System.find_executable("inotifywait"),
309-
do: [],
310-
else: [backend: :fs_poll, interval: 1_000]
308+
poll = [backend: :fs_poll, interval: 1_000]
311309

312-
{:unix, :darwin} ->
310+
cond do
311+
System.get_env("TRINITY_SKILLS_POLL") == "1" ->
312+
poll
313+
314+
match?({:unix, :linux}, :os.type()) ->
315+
if System.find_executable("inotifywait"), do: [], else: poll
316+
317+
match?({:unix, :darwin}, :os.type()) ->
313318
[]
314319

315-
{:win32, _} ->
320+
match?({:win32, _}, :os.type()) ->
316321
[]
317322

318-
_ ->
319-
[backend: :fs_poll, interval: 1_000]
323+
true ->
324+
poll
320325
end
321326
end
322327

40.6 KB
Loading
124 KB
Loading
58.9 KB
Loading
82 KB
Loading
83.1 KB
Loading
270 KB
Loading

‎test/trinity/skills/registry_test.exs‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,11 @@ defmodule Trinity.Skills.RegistryTest do
123123
Registry.rescan()
124124
assert Skills.get("watched").description == "Before."
125125
# inotifywait establishes its watches a moment after it starts and says nothing when it
126-
# has; an edit before that is missed (one run in three without this pause).
127-
Process.sleep(500)
126+
# has; an edit before that is missed (one run in three without a pause). And the polling
127+
# backend the registry picks where inotifywait is absent (the gate's runners, run
128+
# 35623752961) compares mtimes at one-second resolution: an edit inside the second the
129+
# file was written in is no change to it. So the edit waits a second and a bit.
130+
Process.sleep(1_100)
128131

129132
File.write!(
130133
Path.join([dir, "watched", "SKILL.md"]),

0 commit comments

Comments
 (0)