okami.mom/albedo
git clone https://git.nkp.pet/okami.mom/albedo
61c43ca
main
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 () -> 15Root = os : getenv ( "ALBEDO_TEST_TMP" , "/tmp/albedo-tests" ), 16Dir = filename : join ( Root , "gleam-" ++ os : getpid ()), 17ok = filelib : ensure_path ( Dir ), 18UserHome = filename : join ( Dir , "user-home" ), 19ok = filelib : ensure_path ( UserHome ), 20persistent_term : put ( ?MODULE , Dir ), 21true = os : putenv ( "ALBEDO_HOME" , Dir ), 22true = os : putenv ( "TMPDIR" , Dir ), 23true = os : putenv ( "HOME" , UserHome ), 24%% A detached kernel a test never stopped ends soon after, not in an hour. 25true = os : putenv ( "ALBEDO_KERNEL_GRACE_SECONDS" , "20" ), 26nil . 27 28cleanup () -> 29_ = file : del_dir_r ( persistent_term : get ( ?MODULE )), 30nil .