okami.mom/albedo

git clone https://git.nkp.pet/okami.mom/albedo

Aly Raffauffeat(api)!: migrate daemon and clients to protocol 361c43ca

main
1.3 KiB30 linesraw
1%% Native tests discover settings under ALBEDO_HOME and instructions and skills
2%% under HOME. Both roots belong to this run so developer files cannot change
3%% the tests' compositions or discovery work.
4%%
5%% The directory is the run's scratch space: <root>/gleam-<pid> under the root
6%% the Python suites share (test/scratch.py). It is also TMPDIR, so every file a
7%% test writes is removed with it when the run ends, and a run that died first
8%% is swept by the next Python suite, which removes the <name>-<pid> directories
9%% of processes that no longer exist. Kernels keep their run directories under
10%% it too, and leave when it disappears.
11-module(albedo_test_home).
12-export([isolate/0, cleanup/0]).
13
14isolate() ->
15    Root = os:getenv("ALBEDO_TEST_TMP", "/tmp/albedo-tests"),
16    Dir = filename:join(Root, "gleam-" ++ os:getpid()),
17    ok = filelib:ensure_path(Dir),
18    UserHome = filename:join(Dir, "user-home"),
19    ok = filelib:ensure_path(UserHome),
20    persistent_term:put(?MODULE, Dir),
21    true = os:putenv("ALBEDO_HOME", Dir),
22    true = os:putenv("TMPDIR", Dir),
23    true = os:putenv("HOME", UserHome),
24    %% A detached kernel a test never stopped ends soon after, not in an hour.
25    true = os:putenv("ALBEDO_KERNEL_GRACE_SECONDS", "20"),
26    nil.
27
28cleanup() ->
29    _ = file:del_dir_r(persistent_term:get(?MODULE)),
30    nil.